4
我想知道什麼AVCaptureDevice設置是iPhone上的相機應用程序。特別是AVCaptureExposureMode,AVCaptureFocusMode和AVCaptureWhiteBalanceMode。我正在嘗試製作自定義相機,出於某種原因,我無法使照片的光線在對焦時正確更改。我爲我的相機設置了ExposurePointOfInterest和FocusPointOfInterest,但出於某種原因,它好像照相機正確對焦,但照明不會在我點擊時聚焦。當我點擊一個黑暗區域時,它不會像照相機應用程序中那樣變亮。有沒有我忘記設置的設置?這是我用於對焦相機的代碼。什麼是iPhone上的攝像頭應用程序的AVFoundation AVCaptureDevice設置?
CGPoint touchPoint = [gesture locationInView:collectView];
float focus_x = touchPoint.x/collectView.frame.size.width;
float focus_y = touchPoint.y/collectView.frame.size.height;
NSError *tError = nil;
NSLog(@"previous: %.2f, %.2f", backCamera.focusPointOfInterest.x, backCamera.focusPointOfInterest.y);
if (isFrontCamera) {
focus_x = collectView.frame.size.width - focus_x; //the view is mirrored for the front camera
if ([frontCamera lockForConfiguration:&tError]) {
if ([frontCamera isExposurePointOfInterestSupported]) {
[frontCamera setExposurePointOfInterest:CGPointMake(focus_x, focus_y)];
if ([frontCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
[frontCamera setExposureMode:AVCaptureExposureModeAutoExpose];
}
}
if ([frontCamera isFocusPointOfInterestSupported]) {
[frontCamera setFocusPointOfInterest:CGPointMake(focus_x, focus_y)];
if ([frontCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
[frontCamera setExposureMode:AVCaptureExposureModeAutoExpose];
}
}
if ([frontCamera isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance]) {
[frontCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeAutoWhiteBalance];
}
[frontCamera unlockForConfiguration];
}
else {
NSLog(@"Couldn't change focus point:%@",tError);
}
}
else {
if ([backCamera lockForConfiguration:&tError]) {
if ([backCamera isExposurePointOfInterestSupported]) {
[backCamera setExposurePointOfInterest:CGPointMake(focus_x, focus_y)];
if ([backCamera isExposureModeSupported:AVCaptureExposureModeAutoExpose]) {
[backCamera setExposureMode:AVCaptureExposureModeAutoExpose];
}
}
if ([backCamera isFocusPointOfInterestSupported]) {
[backCamera setFocusPointOfInterest:CGPointMake(focus_x, focus_y)];
if ([backCamera isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {
[backCamera setFocusMode:AVCaptureFocusModeAutoFocus];
}
}
if ([backCamera isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance]) {
[backCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeAutoWhiteBalance];
}
[backCamera unlockForConfiguration];
}
else {
NSLog(@"Couldn't change focus point:%@",tError);
}
}