afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
183 stars 33 forks source link

Example for "Zoom" bindings #70

Closed fryndorfer closed 4 months ago

fryndorfer commented 4 months ago

I recently stumbled across the issue that the camera view cannot focus because some iPhones have multiple cameras and the view does not know which one to use. In #37, it says "But I decided to implement zoom control as it can be done in a way to be compatible with all platforms and gives an ability to select different lenses on iPhones with multiple cameras and Android phones that implement logical multi-camera setup." but I cannot get behind how those added properties are working.

image

Can someone please explain how these properties are working and what I have to do If I'm having the same focus issue as in #37 ?

afriscic commented 4 months ago

Hello.

For iPhones with multiple cameras these properties report the following (they are read only): CurrentZoomFactor - zoom factor that is currently set on the camera MinZoomFactor - minimum zoom factor that you can set MaxZoomFactor - maximum zoom factor that you can set DeviceSwitchZoomFactor - an array of zoom factor that switch the camera on iPhones with multiple built in cameras (eg. 2, 6 - so 1-2 is ultrawide, 2-6 wide, 6 and above telephoto)

Then you can set RequestZoomFactor as desired.

To fix the focusing issue as per the post here the solution is to zoom in little bit so the barcode will be nicely focused. I haven't implemented this in code as this projects targets the whole range of different devices and use cases, but you can experiment and find out what zoom factor works best for a particular device and your use case.

fryndorfer commented 4 months ago

Thank you @afriscic. I was a little bit confused because I thought that I have to manually tell the camera to switch lenses and I didn't know how to do that, but I just tested it now and I noticed that it automatically switches lenses based on the requested zoom factor on my iPhone 12. So, all questions answered. And by the way, really great work you did there, love using your library! 💯