Input frame cropping

For most use cases, only a small portion of the input frame from a camera that contains the features targeted for detections is actually usable and the rest of the frame can be ignored. For example, a portion of the frame at the top might contain clear blue sky where no features will be expected to appear. Live Sense SDK provides the ability to crop such portions from the input frame so as to:

  • reduce the size of the image in turn helping to reduce the processing time for each frame
  • focus more on the interesting portion of the image to get more accurate detections and reduce false detections

Note

This is available for the Road Signs model only.

Set the percentage of the frame to be cropped from all four sides individually before being passed for running recognitions.

All crop percentage values are 0 by default and must vary between 0 and 100.

  • @param leftCropPercent, rightCropPercent - percent of the input frame's total width to be cropped from the left and right, respectively.
  • @param topCropPercent, bottomCropPercent - percent of the input frame's total width to be cropped from the top and bottom, respectively.

@throws IllegalArgumentException - Exception thrown if:

  • any crop percent argument is < 0
  • leftCropPercent + rightCropPercent >= 100
  • topCropPercent + bottomCropPercent >= 100

Progressive zoom

Through extensive experimentation, an approach has been identified that helps to detect features which are farther and would not have been detected unless they were closer. This approach is to progressively zoom in on the center portion of consecutive input frames per every 3 frames. This helps to detect features that to a large extent will lie in the center of the frame earlier and with good accuracy.

The cropping is always focused around the center of the input image, removing portions around the edges of the frame.

Note

This is available for the Road Signs model only.

Method signature

func cropPixelBuffer(_ inputBuffer:CVPixelBuffer) -> (CVPixelBuffer?,CGRect)

Usage

 var imageCropper = LSImageCropper()
 imageCropper._topCropPercent = 50
 imageCropper._enableCenterCrop = true // Set true to incrementally zoom the input frames.
 let output = imageCropper.cropPixelBuffer(pixelBuffer)
if let processedBuffer = output.0{
  //Pass cropped pixelbuffer
  lsdRecognition?.processPixelBuffer(pixelBuffer: processedBuffer, orientation: orientation)
}
else{
  //Fallback
  lsdRecognition?.processPixelBuffer(pixelBuffer: pixelBuffer, orientation: orientation)
}

results matching ""

    No results matching ""