点击聚焦和曝光不起作用
Tap To Focus And Exposure Doesn't Work
一段时间以来,我一直在尝试进行点击对焦,实际上我已经尝试了所有方法,但 none 似乎对我有用。以下是我的 touchesBegan 中的内容,但它不起作用。它应该但它不是。我究竟做错了什么?
var newFocusPoint = CGPoint(x: touchPoint.locationInView(cameraView).x / screenSize.width, y: touchPoint.locationInView(cameraView).y / screenSize.height)
if let cameraDevice = device {
if(cameraDevice.lockForConfiguration(nil)) {
if cameraDevice.focusPointOfInterestSupported {
cameraDevice.focusPointOfInterest = newFocusPoint
cameraDevice.focusMode = AVCaptureFocusMode.ContinuousAutoFocus
}
if cameraDevice.exposurePointOfInterestSupported {
cameraDevice.exposurePointOfInterest = newFocusPoint
cameraDevice.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure
}
cameraDevice.unlockForConfiguration()
}
}
You made minor mistakes in your code, the lines below should fix it.
cameraDevice.focusPointOfInterest = focusPoint
cameraDevice.focusMode = AVCaptureFocusMode.AutoFocus
cameraDevice.exposurePointOfInterest = focusPoint
cameraDevice.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure
一段时间以来,我一直在尝试进行点击对焦,实际上我已经尝试了所有方法,但 none 似乎对我有用。以下是我的 touchesBegan 中的内容,但它不起作用。它应该但它不是。我究竟做错了什么?
var newFocusPoint = CGPoint(x: touchPoint.locationInView(cameraView).x / screenSize.width, y: touchPoint.locationInView(cameraView).y / screenSize.height)
if let cameraDevice = device {
if(cameraDevice.lockForConfiguration(nil)) {
if cameraDevice.focusPointOfInterestSupported {
cameraDevice.focusPointOfInterest = newFocusPoint
cameraDevice.focusMode = AVCaptureFocusMode.ContinuousAutoFocus
}
if cameraDevice.exposurePointOfInterestSupported {
cameraDevice.exposurePointOfInterest = newFocusPoint
cameraDevice.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure
}
cameraDevice.unlockForConfiguration()
}
}
You made minor mistakes in your code, the lines below should fix it.
cameraDevice.focusPointOfInterest = focusPoint
cameraDevice.focusMode = AVCaptureFocusMode.AutoFocus
cameraDevice.exposurePointOfInterest = focusPoint
cameraDevice.exposureMode = AVCaptureExposureMode.ContinuousAutoExposure