Jørgen P. Tjernø

iOS: Tweak autofocus settings

- Disable face-driven autofocus on iOS 15.4+
- Enable continuous autofocus if available
  1 +## NEXT
  2 +
  3 +Improvements:
  4 +* [iOS] No longer automatically focus on faces
  5 +
1 ## 3.0.0 6 ## 3.0.0
2 This big release contains all improvements from the beta releases. 7 This big release contains all improvements from the beta releases.
3 In addition to that, this release contains: 8 In addition to that, this release contains:
@@ -133,6 +133,17 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega @@ -133,6 +133,17 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
133 } 133 }
134 134
135 device.addObserver(self, forKeyPath: #keyPath(AVCaptureDevice.torchMode), options: .new, context: nil) 135 device.addObserver(self, forKeyPath: #keyPath(AVCaptureDevice.torchMode), options: .new, context: nil)
  136 + do {
  137 + try device.lockForConfiguration()
  138 + if device.isFocusModeSupported(focusMode: .continuousAutoFocus) {
  139 + device.focusMode = .continuousAutoFocus
  140 + }
  141 + if #available(iOS 15.4, *) {
  142 + device.automaticallyAdjustsFaceDrivenAutoFocusEnabled = false
  143 + }
  144 + device.unlockForConfiguration()
  145 + } catch {}
  146 +
136 captureSession.beginConfiguration() 147 captureSession.beginConfiguration()
137 148
138 // Add device input 149 // Add device input