Skip to content

Instantly share code, notes, and snippets.

@Rich86man
Created April 26, 2014 19:25
Show Gist options
  • Save Rich86man/11328703 to your computer and use it in GitHub Desktop.
Save Rich86man/11328703 to your computer and use it in GitHub Desktop.
- (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