Scanning QR code with AVCaptureDevice issues on iPhone 14 Pro

Hello,

I am using simple AVCaptureDevice setup to scan QR code from LCD screen, usually the distance is 5 to 15 centimeters. This has been working fine for a long time, with correct focus and everything.

Today I noticed that my iPhone 14 Pro cannot focus on these smaller distances while my developer iPhone SE 2020 can easily detect the QR code in basically all cases.

I have been using this code to create the capture device:

AVCaptureDevice.default(for: .video)

And then some settings:

if videoCaptureDevice.isAutoFocusRangeRestrictionSupported {
       videoCaptureDevice.autoFocusRangeRestriction = .near
 }

if videoCaptureDevice.isFocusModeSupported(.continuousAutoFocus) {
      videoCaptureDevice.focusMode = .continuousAutoFocus
}

As I said, this worked great prior to noticing the issue on iPhone 14 Pro.

After some searching I found recommendations to use another device type like: builtInDualWideCamera and other available types. I tried all of them and they either behave like the default (meaning I cannot scan the code unless I move the phone way out) or they always seem to use the 0.5 Ultra-Wide camera which looks weird and the scanning experience is not ideal.

What is the best approach to have QR scanning with these new phones?

I know you said you attempted to use the other device types, but just to make sure have you tried switching to the builtInTripleCamera? That should work, hopefully.

Ultimately, the problem here is that the minimum focus distance is too large for you to focus on objects as close as you want them to. If you want to fix this in software, I've linked a keynote where apple describes how to apply a zoom factor proportional to the minimum focus distance of the device so that you can zoom differently (for previous devices and all future devices with large minimum focus distances). It's the first section of the video.

https://developer.apple.com/videos/play/wwdc2021/10047/

AVCaptureDevice.default(for: .video) is defaulting to builtInWideCamera device type

On iPhone 14 Pro (Max) the wide angle camera has a higher minimum focal length of 200 mm which is different as compared to its predecessors where it is typically 150 mm. So, on these newer devices it would be safer to choose either builtInDualCamera or builtInTripleCamera instead of using default wide angle camera which would ensure that iOS automatically switches from wide angle to ultra wide angle if necessary to maintain focus.

Hello,

Have you found a fix for this issue? Apple does not seem to respond to this problem. I have also tried to switch to builtInTripleCamera and builtInDualCamera, but no luck.

Thank you!

Scanning QR code with AVCaptureDevice issues on iPhone 14 Pro
 
 
Q