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

.analyzeImage() is not working as expected #1271

Open
sharathguvvala opened this issue Dec 31, 2024 · 6 comments
Open

.analyzeImage() is not working as expected #1271

sharathguvvala opened this issue Dec 31, 2024 · 6 comments

Comments

@sharathguvvala
Copy link

I’m experiencing an issue with the analyzeImage() method in the Mobile Scanner Flutter package. The BarcodeCapture object is often returned as null if the image contains extra content, while it works better when the image has just the barcode.

My use case involves capturing a clear image for barcode detection. Using barcodes.listen captures barcodes immediately, but the images are often shaky or blurry. Since the package doesn’t support direct image capture, I’ve implemented a workaround using the camera package to let users confirm the image before passing it to analyzeImage().

I need to achieve the following:

  • Capture a clear image even if a barcode is not detected.
  • Detect the barcode when available, leaving the final image selection to the user.

Successful Detection
Successful Detection

Detection Failed
Detection Failed

In this case, analyzeImage() fails to detect the barcode despite it being visible. However, the same barcode is successfully detected if I use the barcodes.listen method.

Could you clarify:

  • What mechanism does barcodes.listen use for barcode detection?
  • Can analyzeImage() achieve the same detection reliability?
  • If not, is there a workaround to meet these requirements?

I appreciate your guidance on resolving this issue.

@navaronbracke
Copy link
Collaborator

The barcodes.listen method gets events from an EventSink, which gets events from the camera output analysis.

Some further clarifications:

On Android both the camera output (via start()) and file output (via analyzeImage()) are driven by MLKit's process method.

On iOS and MacOS (post the Vision API migration, hence the different source branch in this comment), both start() and analyzeImage() are driven by VNImageRequestHandler.

I wonder though, if you test on the latest beta (7.0.0-beta.3), does this work on iOS and MacOS ?
I believe this might be either an MLKit issue, or an issue with how the bytes of a file are encoded.

@sharathguvvala
Copy link
Author

sharathguvvala commented Jan 7, 2025

I'm currently using 7.0.0-beta.3, and overall, the analyzeImage() function is working consistently as expected.

However, I've encountered an issue where the analyzeImage method getting stuck in the await call if the provided image does not contain any barcode data.

Is this a known issue? is there any workaround or planned fix to address this behaviour?

@navaronbracke
Copy link
Collaborator

@sharathguvvala I fixed that yesterday in #1274 but I haven't released a new beta version yet. I'll do that later today, so that you can test further.

@sharathguvvala
Copy link
Author

Thanks for the update! I'll test it as soon as the new beta version is released and share my feedback.

@navaronbracke
Copy link
Collaborator

Version 7.0.0-beta.4 includes the fixes for analyzeImage: https://pub.dev/packages/mobile_scanner/versions/7.0.0-beta.4

@Blue-Cheesecake
Copy link

I got similar issue. Tried with version 7.0.0-beta.4 and it works for me. Thanks!

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

3 participants