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.
Method Signature
public void setSideCropPercent(int leftCropPercent, int topCropPercent, int rightCropPercent, int bottomCropPercent);
Usage
RoadSignsModel.Options rsOption = new RoadSignsModel.Options();
rsOption.setSideCropPercent(int leftCropPercent, int topCropPercent, int rightCropPercent, int bottomCropPercent);
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.
The input frame is rotated to its natural orientation based on the rotation value passed to Recognizer#recognizeImage(Bitmap, int, float)
before applying any cropping. This means that the directionality of this method's parameters are interpreted based on the user's view rather than the raw input frame.
An IllegalArgumentException
will be thrown by setSideCropPercent
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
public void setUseIncrementalCenterCrop(boolean useIncrementalCenterCrop);
Usage
RoadSignsModel.Options rsOption = new RoadSignsModel.Options();
rsOption.setUseIncrementalCenterCrop(boolean useIncrementalCenterCrop);
Defines if the Road Signs model should incrementally zoom the input frame on each call to RoadSignsModel#recognizeImage(Bitmap, int, float)
.
Any frame adjustments are applied after any side cropping specified through setSideCropPercent(int, int, int, int)
has been applied.