iPhone相机应用程序的AVFoundation AVCaptureDevice设置是什么?

4
我想了解iPhone相机应用程序中的AVCaptureDevice设置。具体来说,是AVCaptureExposureMode、AVCaptureFocusMode和AVCaptureWhiteBalanceMode。我正在尝试制作自定义相机,但由于某些原因,当聚焦时无法正确更改照片的照明。我为我的相机设置了ExposurePointOfInterest和FocusPointOfInterest,但由于某种原因,似乎相机对焦正确,但照明并没有像在相机应用中一样跟随我点击的区域移动。我是否忘记了一些设置?以下是我聚焦相机的代码。
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);
    }
}
1个回答

0

这份文档包含了许多内容,可以部分回答你的问题。

希望这能有所帮助,因为我们无法告诉你相机应用程序的每个属性值。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接