android-vision icon indicating copy to clipboard operation
android-vision copied to clipboard

Need full screen camera and the scanning for barcode should be done in between a rectangular square

Open urlAkash opened this issue 8 years ago • 14 comments

How to make a middle section of the camera activity bordered and the scanning should be done between that section!!

urlAkash avatar Dec 24 '15 13:12 urlAkash

Maybe this would help?:

https://github.com/googlesamples/android-vision/issues/23

pm0733464 avatar Mar 30 '16 17:03 pm0733464

@urlAkash did you find any solution, i am looking for exactly same thing?

khurramengr avatar Jul 25 '16 11:07 khurramengr

@khurramengr Kindly look this link http://stackoverflow.com/questions/32999813/preview-size-for-barcode-scanner-from-vision-api/34156158#34156158

And for rectangular square, You have to draw one rectangular at camera activity java file

AkashAndi avatar Jul 25 '16 12:07 AkashAndi

@urlAkash that's what I've already done, i need to know how do we feed the Bar Code Scanning Algorithm some portion(the portion which is inside the rectangle) of each Camera frame so that it processes only that specific region for BarCode and not the entire frame. To be more specific take a look inside the CameraSource class

outputFrame = new Frame.Builder()
                        .setImageData(mPendingFrameData, mPreviewSize.getWidth(),
                                mPreviewSize.getHeight(), ImageFormat.NV21)
                        .setId(mPendingFrameId)
                        .setTimestampMillis(mPendingTimeMillis)
                        .setRotation(mRotation)
                        .build();

here we are building the Frame from mPendingFrameData, which is the entire frame data from camera.

I need to know how do we crop the frame here so that we could send the cropped Frame to this code

 try {
                mDetector.receiveFrame(outputFrame);
            } catch (Throwable t) {
                Log.e(TAG, "Exception thrown from receiver.", t);
            } finally {
                mCamera.addCallbackBuffer(data.array());
            }

khurramengr avatar Jul 25 '16 15:07 khurramengr

When I had drawn a border on the camera activity,

The barcode will get scanned if it is within that border(ROI).

I didn't coded anything to make scanning between that region of interest but I don't know why it happens.

I had just drawn one Rectangle box above the camera activity and then when I scan a barcode, It would be scanned if it is within the ROI.

I don't know why but it happens.

But after making it full screen the aspect ratio doesn't remains well, that's why I had made the camera view as of 4:3 Ratio Height and Width then it looks fine.

Thanks & Regards,

Akash Dubey,

URL Software Global Inc

On Mon, Jul 25, 2016 at 9:29 PM, Khurram Shehzad [email protected] wrote:

@urlAkash https://github.com/urlAkash that's what I've already done, i need to know how do we feed the Bar Code Scanning Algorithm some portion(the portion which is inside the rectangle) of each Camera frame so that it processes only that specific region for BarCode and not the entire frame. To be more specific take a look inside the CameraSource class

outputFrame = new Frame.Builder() .setImageData(mPendingFrameData, mPreviewSize.getWidth(), mPreviewSize.getHeight(), ImageFormat.NV21) .setId(mPendingFrameId) .setTimestampMillis(mPendingTimeMillis) .setRotation(mRotation) .build(); here we are building the Frame from mPendingFrameData, which is the entire frame data from camera. I need to know how do we crop the frame here so that we could send the cropped Frame to this code try { mDetector.receiveFrame(outputFrame); } catch (Throwable t) { Log.e(TAG, "Exception thrown from receiver.", t); } finally { mCamera.addCallbackBuffer(data.array()); }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/googlesamples/android-vision/issues/54#issuecomment-234997550, or mute the thread https://github.com/notifications/unsubscribe-auth/APqqozd-HXL0Gkofk8SueryJYgXNAqPHks5qZN1dgaJpZM4G7FWp .

urlAkash avatar Jul 26 '16 06:07 urlAkash

In my case i had multiple bar codes in a single frame of camera but when i try to scan that frame it picks up some random bar code(which was outside the rectangle), i am currently looking for mechanism through which i could crop the Frame before passing to the BarCodeScanner. In your case of Aspect Ratio issue try out this wrapper of vision API https://github.com/EdwardvanRaak/MaterialBarcodeScanner, this guy has done some pretty good job to adjust the CameraPreview with proper aspect ratio.

khurramengr avatar Jul 26 '16 06:07 khurramengr

Hi, khurramengr have you got any solution. I have also a same requirement.In my camera preview there are multiple bar code present but I need only center one witch is in my custom rectangle( like zxing lib sample).I have done something with vision API. But it always detect random one.

https://cloud.githubusercontent.com/assets/10453203/19023016/e7ee57be-8901-11e6-8215-aef5fcf58d99.png

dibakarece avatar Oct 12 '16 11:10 dibakarece

You'll have to manually process the frames before feeding them to FrameProcessor, i.e construct the Bitmap from available data and then process that bitmap somehow that it contains your region of interest only, and then feed that bitmap to FrameProcessor.

On Wed, Oct 12, 2016 at 4:18 PM, Dibakar Mistry [email protected] wrote:

Hi, khurramengr have you got any solution. I have also a same requirement.In my camera preview there are multiple barcode present but I need only center one witch is in my custom rectangle.

https://cloud.githubusercontent.com/assets/10453203/19023016/e7ee57be- 8901-11e6-8215-aef5fcf58d99.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/googlesamples/android-vision/issues/54#issuecomment-253186323, or mute the thread https://github.com/notifications/unsubscribe-auth/AEBWdxzLRcfVOTnxkjkfplygt3ztYA5Oks5qzMHrgaJpZM4G7FWp .

Best Regards

Khurram Shehzad Computer Engineer ( University of Engineering & Technology (UET) Taxila )

khurramengr avatar Oct 12 '16 13:10 khurramengr

@khurramengr Any sample code to do this? Need to limit detection area due to multiple barcodes inside same frame.

nrazon avatar Jan 07 '17 10:01 nrazon

@nrazon @khurramengr @urlAkash see here http://stackoverflow.com/questions/32299947/mobile-vision-api-concatenate-new-detector-object-to-continue-frame-processing/43915078#43915078

matthewcarlreetz avatar May 11 '17 12:05 matthewcarlreetz

anyone has a solution to this? I, too have a multiple QR on screen. I've noticed that having 4 or more, the scanner cannot read the other. problem there is need to read them all one after another.

WilsonCP avatar Nov 27 '19 06:11 WilsonCP

ok i have solution send me detail

On Wed, Nov 27, 2019 at 11:36 AM Newbie Developer [email protected] wrote:

anyone has a solution to this? I, too have a multiple QR on screen. I've noticed that having 4 or more, the scanner cannot read the other.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/googlesamples/android-vision/issues/54?email_source=notifications&email_token=ADNRQFE47636C5CYHKHWOFTQVYIPZA5CNFSM4BXMKWU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFIO3IA#issuecomment-558951840, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNRQFDAFXH7L7YW5BKB7CDQVYIPZANCNFSM4BXMKWUQ .

visionfaysal avatar Nov 27 '19 07:11 visionfaysal

@nrazon @khurramengr @urlAkash see here http://stackoverflow.com/questions/32299947/mobile-vision-api-concatenate-new-detector-object-to-continue-frame-processing/43915078#43915078

This seems to be a good solution. I'll look into this. Thanks! I'm also stumbled accross this problem and now looking for a solution.

AmilaCG avatar Apr 15 '20 19:04 AmilaCG

Anybody found any solution guys? The above workaround also not working

Ashmeeto4s avatar Oct 23 '21 22:10 Ashmeeto4s