iPhone : camera autofocus observer?

后端 未结 3 487
迷失自我
迷失自我 2020-12-08 05:38

I would like to know if it\'s possible to receive notification about autofocus inside an iPhone application?

I.E, does it exist a way to be notified when autofocus s

3条回答
  •  感情败类
    2020-12-08 05:47

    You can use modern Swift key value observing api to get callbacks when focusing starts and ends by observing AVCaptureDeviceInput.device.isAdjustingFocus property. In the example below, instance of AVCaptureDeviceInput is called captureDeviceInput.

    Example:

    self.focusObservation = observe(\.captureDeviceInput.device.isAdjustingFocus, options: .new) { _, change in
        guard let isAdjustingFocus = change.newValue else { return }
    
        print("isAdjustingFocus = \(isAdjustingFocus)")
    
    }
    

提交回复
热议问题