0

我已成功开启 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 总是打印我有焦点,但评论那行我永远不会得到。我如何检测我们是否在焦点上?顺便说一句:对焦模式是 AutoFocus 和 ContinuousAutoFocus

谢谢您的帮助。

4

0 回答 0