0

I have successfully turned on the setSubjectAreaChangeMonitoringEnabled:

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

in start method I have included the following notification:

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

Then I have the areWeFocused method (which I know is wrong but I need help with it):

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

If uncommented my NSLog always prints I have focus, but commenting that line I never get NOT. How can I detect if we are in focus? BTW: Focus mode is AutoFocus and ContinuousAutoFocus

Thank you for your help.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Patricia
  • 5,019
  • 14
  • 72
  • 152
  • Found the answer here: http://stackoverflow.com/questions/9100357/iphone-camera-autofocus-observer – Patricia Jun 27 '13 at 21:12
  • Found the answer in another question. http://stackoverflow.com/questions/9100357/iphone-camera-autofocus-observer – Patricia Jun 27 '13 at 21:14

0 Answers0