我使用下面的代码来聚焦 iPhone 相机。但它不起作用。我从 Apple 的 AVCam 示例代码中获取此代码。我做错什么了吗?有什么方法可以检测 iPhone 是否对焦?
-(void) focusAtPoint:(CGPoint)point
{
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];;
if (device != nil) {
if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {
NSError *error;
if ([device lockForConfiguration:&error]) {
[device setFocusPointOfInterest:point];
[device setFocusMode:AVCaptureFocusModeAutoFocus];
[device unlockForConfiguration];
} else {
NSLog(@"Error in Focus Mode");
}
}
}
}