googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

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

Open urlAkash opened 8 years ago

urlAkash commented 8 years ago

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

pm0733464 commented 8 years ago

Maybe this would help?:

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

khurramengr commented 8 years ago

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

AkashAndi commented 8 years ago

@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

khurramengr commented 8 years ago

@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());
            }
urlAkash commented 8 years ago

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 notifications@github.com 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 .

khurramengr commented 8 years ago

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.

dibakarece commented 8 years ago

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

khurramengr commented 8 years ago

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 notifications@github.com 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 )

nrazon commented 7 years ago

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

matthewcarlreetz commented 7 years ago

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

WilsonCP commented 5 years ago

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.

visionfaysal commented 5 years ago

ok i have solution send me detail

On Wed, Nov 27, 2019 at 11:36 AM Newbie Developer notifications@github.com 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 .

AmilaCG commented 4 years ago

@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.

Ashmeeto4s commented 3 years ago

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