如何确定AVCaptureDevice是否具有焦点

时间:2013-06-25 19:57:31

标签: objective-c avfoundation avcapturedevice

我已成功启用setSubjectAreaChangeMonitoringEnabled:

self.videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[self.videoDevice lockForConfiguration:nil]; //you must lock before setting torch mode
[self.videoDevice setSubjectAreaChangeMonitoringEnabled:YES];
[self.videoDevice unlockForConfiguration];

在启动方法中,我包含了以下通知:

[[NSNotificationCenter defaultCenter] addObserver: self
                                         selector: @selector(areWeFocused:)
                                             name: AVCaptureDeviceSubjectAreaDidChangeNotification
                                           object: nil];

然后我有areWeFocused方法(我知道这是错误的,但我需要帮助):

- (void)areWeFocused:(NSNotification *) notification {
    BOOL adjusting = [self.videoDevice isAdjustingFocus];
    if (!adjusting) {
        //NSLog(@"I have focus");
    } else {
        NSLog(@"NOT");
    }
}

如果取消注释我的NSLog始终打印我有焦点,但评论该行我永远不会得到。如何检测我们是否关注焦点?顺便说一句:对焦模式是自动对焦和连续自动对焦

感谢您的帮助。

0 个答案:

没有答案