Open JanMisker opened 1 year ago
@thegnuu I see that on iOS the 'Triple Camera' is explicitly requested, is there a specific reason for that? https://github.com/capacitor-community/barcode-scanner/blob/70338f857a230038330b437794320a4034c76039/ios/Plugin/Plugin.swift#L163-L167
I think it defaults to the wide angle (0.5x), I'm not sure if that makes sense?
@JanMisker Not really a reason for it no. I tested with a few settings on my iPhone 14 Pro Max and had the best results scanning codes with this setup, with others my device had issues to properly autofocus codes if they were "too close" to the camera and the results were not the best since the image was too blurry...
This was originally just for testing, maybe another setup would make more sense.
Okay, I'll check with people using scanners in real settings. Maybe we should offer option to change the zoom/camera. For iOS there is a value to read the different zoom levels, but I didn't get it to work properly yet.
Changing the camera and zoom would be ideal, you are absolutely right!
It should be manageable on iOS, but maybe a bit overwhelming on some Android devices with even more cameras and maybe not a proper naming of those, a decent default value should be set non the less I think :)
Started the feature, iOS only for now, https://github.com/capacitor-community/barcode-scanner/pull/212
@thegnuu please have a look at the API (in definition.ts
here https://github.com/JanMisker/barcode-scanner/blob/e5f25d93a27667e194022368e88e5f6cffd410b6/src/definitions.ts#L206) whether it makes sense.
I had a look at Android API and it should be pretty straightforward to implement it, except for the switchOver
feature.
Looks good to me, I am not sure how exactly switchOver
is handled on Android either... I don't even know if things like this are generally available over androidx.camera
or if there are some vendor-specific things.
As far as I was able to research it seems like not all options that the hardware is capable of are available via the general camera APIs. It looks like there is even some sort of whitelisting going on within Android that will only allow certain packages to get full hardware access. Seems a bit strange, but I guess some limitations of general APIs are required regarding the amount of different hardware available...
Btw. is it okay for you if I merge your PRs right away? If you want me to keep it open just create a draft, okay? :)
Yeah sure just merge, if it looks good to you. The ML-Kit branch itself is still pre-release as well so should be fine.
Right now on iOS on iPhone 12 Pro the plugin picks the tele camera when choosing the back-facing camera. This is not the most ideal camera because in practice the scanned area will be quite close to the phone. The plugin should pick a more sensible default, I guess the "1x" one.
Would be nice to also expose the available camera's such that the developer can implement a UI for the end-user to pick a specific one.