android-vision
android-vision copied to clipboard
Limit detection area
Right now the API detects every barcode visible in the camera view. Is it possible to limit the detection area so the detection only reads from a rectangle in the middle of the screen?
No.
However, you can get equivalent results by either cropping the input image or filtering results returned by the API after detection has occurred.
See this suggestion on stackoverflow:
http://stackoverflow.com/questions/36405717/android-vision-reduce-bar-code-tracking-window/36428822#36428822
my code...
this hint....."(item as Barcode).BoundingBox.Intersect()"
Rect rect = ((BarcodeScannerActivity)_activity).mPreview.mSurfaceView._clipBounds;
float left;
float right;
float top;
float bottom;
//IList<Point> point = (item as Barcode).CornerPoints;
left = (rect.Left * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Height) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorX;
right = (rect.Right * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Height) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorX;
top = (rect.Top * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Width) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorY;
bottom = (rect.Bottom * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Width) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorY;
if (!(item as Barcode).BoundingBox.Intersect(new Rect((int)left, (int)top, (int)right, (int)bottom)))
{
return;
}
Hi Team,
Help to limit detection area to specific overlay