twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
987 stars 272 forks source link

[#89] Use the Ultra WIde Camera per default if available #102

Closed bennokress closed 1 year ago

bennokress commented 1 year ago

Autofocus on devices that are equipped with an Ultra Wide Camera seems to be off using the default Camera. This is why we select the Ultra Wide Camera per default now.

Fixes #89

bennokress commented 1 year ago

I honestly don't know if a public extension on AVCaptureDevice is the best way to solve this, but I decided to use it in order to be able to provide the "best" camera as a default parameter that is compatible with the current implementation. Let me know if you would like me to implement it differently.

emog commented 1 year ago

@NathanFallet - This fix caused a bug with iPhone 12 Pro and 13 Pro. We faced issue that the camera cannot focus the code-128 on a device. I had to change videCaptureDevice to AVCaptureDevice.default(for: .video) in order to work as expected.

bennokress commented 1 year ago

@emog Okay, that's a problem, but changing it back to AVCaptureDevice.default(for: .video) will just bring back the original issue of #89. It would be best to find a solution inside the new AVCaptureDevice. bestForVideo that fixes your problem and also works for iPhone 14 Pro and future devices.

nathanfallet commented 1 year ago

I'm reopening #89 until we find an appropriate solution then.