capawesome-team / capacitor-mlkit

⚡️ ML Kit plugins for Capacitor. Supports Android and iOS.
https://capawesome.io/plugins/mlkit/
Apache License 2.0
140 stars 39 forks source link

Focus in center/scanning box #119

Open Melynt3 opened 8 months ago

Melynt3 commented 8 months ago

Plugin(s)

Current problem

Im having a problem with losing focus with im zooming or moving my phone, camera is somehow focusing on other elements viewed in camera which sometimes is problematic

Preferred solution

Adding an option to set focus in scanning box or make it possible to focus only on center.

Alternative options

No response

Additional context

No response

Before submitting

KoblerS commented 8 months ago

I have the same problem with iPhone 15 pro max using the barcode functionality. Is there any way to enable autofocus?

robingenz commented 8 months ago

Not yet, but PRs are welcome.

randy-johnson commented 7 months ago

I tried giving this a whirl using the example code here: https://developers.google.com/ml-kit/vision/barcode-scanning/android#java

To enable auto-zooming and customize the experience, you can utilize the setZoomSuggestionOptions() method along with your own ZoomCallback handler and desired maximum zoom ratio, as demonstrated in the code below.

Here is the code in the file: https://github.com/randy-johnson/capacitor-mlkit/pull/1/files#diff-fc2cef0bd325278367eb925e138d31a998df13843c0885139505058aa5dd68deR414-R428

But I get this error when trying to install in my app:

[vite] Internal server error: Failed to resolve entry for package "@capacitor-mlkit/barcode-scanning". The package may have incorrect main/module/exports specified in its package.json.

Here is the line I added to my package.json

"@capacitor-mlkit/barcode-scanning": "github:randy-johnson/capacitor-mlkit/#autofocus",

I'll look into this more tomorrow as it is getting rather late here.

randy-johnson commented 7 months ago

@robingenz, how much would it would it take to sponsor autofocus? I am some issues getting a quality scan and I think it is because of the speed of the scans and the focus? Grabbing scanner app of the app store I can scan a bar code accurate every time but I am not having the same results with this plugin. From what I read focusing before it started taking the scan would prevent the bad scans.

robingenz commented 7 months ago

@randy-johnson Please take a look at After creating an issue.

jacksonpietro commented 4 months ago

Any updates on autofocus? I have a problem reading invoices from Brazil, and the reading difficulty seems to be related to the focus.

randy-johnson commented 4 months ago

We did not end up sponsoring this because it was only available on the Android side and we were having an issue on IOS as well. FWIW, we were able to use the Depracated version: https://github.com/capacitor-community/barcode-scanner and it suited our needs just fine. I am hoping in time the MLKit works better for us.

jacksonpietro commented 4 months ago

@randy-johnson Hey friend, thanks for the tip, I wouldn't have imagined that the deprecated version was working, and for me it also solves the problem. Thanks again for the tip. I also hope the current version provides this capability.