Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add cropRect support for InputImage.fromMediaImage (or similar API to check barcode preview bounds) #491

Open
G00fY2 opened this issue Apr 27, 2022 · 7 comments
Assignees

Comments

@G00fY2
Copy link

G00fY2 commented Apr 27, 2022

What's your feature request? Please describe.
We are using the ML Kit barcode-scanning library in conjunction with CameraX ImageAnalysis.Analyzer. There is currently no sufficient way to limit the area in which ML Kit should search for the barcode (basically making sure the barcode result is inside the preview bounds). E.g. even if cropRect is set, ML Kit will scan the whole image for barcodes. This way the users can't point the camera at a specific barcode without scanning all barcodes which are visible to the camera.

Mobile environment
Android 12
androidx.camera:camera-camera2 1.0.2
com.google.mlkit:barcode-scanning 17.0.2

Additional context
#234 was closed without any updates for over 15 month.

There is no sample to achieve such a common usecase in the vision-quickstart sample project.

In the material-showcase sample project the logic about detecting if the result is inside the overlay starts here:

But this requires a custom GraphicOverlay class which on the other hand depends on a complex CameraSource class which are all build on top of the deprecated default Android Camera framework.

There are suggestions on SO which rely on complex and errorprone bitmap preprocessing.

So in the end there is no developer friendly and reliable way of checking the barcode bounds with the CameraX previous bounds.

@G00fY2 G00fY2 changed the title [Feature request] Add cropRect support (or similar API) for InputImage.fromMediaImage [Feature request] Add cropRect support for InputImage.fromMediaImage (or similar API to check barcode preview bounds) Apr 27, 2022
@zhouyiself
Copy link
Collaborator

Specifying area is not supported currently, can you try to filter out the result instead that not located in your interested area?

@RowanH
Copy link

RowanH commented Jul 8, 2022

@zhouyiself Hi ! Here's our use case - you might have 10 codes in close proximity (imagine a shelf full of boxes with QR codes on them). Flagship phones are so fast at scanning you get back say 5-6 codes very quickly if the phone has some of those QR codes visible. The user only wants the code in the center of the scan area, even though 5 other codes may be visible on the camera view.

There's no way of saying these other 5 codes we don't want, so we have to tell our users, on Android to make sure the phone is very close to the QR code then gradually move the phone back until the QR code scans.

I have an app with both iOS and Android versions, and the android version has a usability flaw as a result of this. I would greatly appreciate if this feature could be added. [ iOS there is the option, and we use it, to crop part of the camera view]

I'm sure there's dozens to hundreds of other developers out there that would love this...

@mujehoxe
Copy link

Well i would like it, because it would reduce the calculation and therefore the energy usage, because we are required to process lots of codes every day.

@vikassable
Copy link

Any update here, we would really appreciate this functionality, thank you!

@RowanH
Copy link

RowanH commented May 19, 2023

Certainly the need is definitely present within our app, at this point I'm close to rewriting that part and looking for alternatives to MLKit..

@hr-roberthoffmann
Copy link

@RowanH Dear Rowan, did you found any alternatives or a solution with MLKit? Have the same problem.
Thank you very much!

@jcho0216
Copy link

any updates yall ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants