Created
April 26, 2014 19:25
-
-
Save Rich86man/11328703 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)focusWithMode:(AVCaptureFocusMode)focusMode exposeWithMode:(AVCaptureExposureMode)exposureMode atDevicePoint:(CGPoint)point monitorSubjectAreaChange:(BOOL)monitorSubjectAreaChange | |
{ | |
dispatch_async([self sessionQueue], ^{ | |
AVCaptureDevice *device = [[self videoDeviceInput] device]; | |
NSError *error = nil; | |
if ([device lockForConfiguration:&error]) { | |
if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:focusMode]) { | |
[device setFocusMode:focusMode]; | |
[device setFocusPointOfInterest:point]; | |
} | |
if ([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:exposureMode]) { | |
[device setExposureMode:exposureMode]; | |
[device setExposurePointOfInterest:point]; | |
} | |
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance]) { | |
[device setWhiteBalanceMode:AVCaptureWhiteBalanceModeAutoWhiteBalance]; | |
} | |
if ([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:AVCaptureExposureModeAutoExpose]){ | |
[device setExposurePointOfInterest:point]; | |
} | |
if ([device isLowLightBoostSupported]) { | |
device.automaticallyEnablesLowLightBoostWhenAvailable = YES; | |
} | |
[device setSubjectAreaChangeMonitoringEnabled:monitorSubjectAreaChange]; | |
[device unlockForConfiguration]; | |
} | |
else { | |
NSLog(@"%@", error); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment