可以在启动相机应用程序时控制白平衡模式吗? (IOS)

时间:2013-03-28 18:41:13

标签: ios avfoundation

这是我一直试图尝试的一个问题。我知道iphone相机在连续(2)连续(2)以大多数(如果不是全部)相机应用程序启动,如AVFoundation框架中的AVCaptureDevice.h中所示:

enum {
AVCaptureWhiteBalanceModeLocked                     = 0,
AVCaptureWhiteBalanceModeAutoWhiteBalance           = 1,
AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance = 2,

};

但无论如何,我可以强制它以白平衡模式锁定开始吗?
我似乎无法找到它决定这种情况的地方。

我已尝试将其包含在我的捕获会话中:

// Create session (use default AVCaptureSessionPresetHigh)
AVCaptureSession *newCaptureSession = [[AVCaptureSession alloc] init];
[newCaptureSession beginConfiguration];

AVCaptureDevice *device = [self cameraWithPosition:AVCaptureDevicePositionBack];
if ([device isWhiteBalanceModeSupported: AVCaptureWhiteBalanceModeLocked]) {
    if ([device lockForConfiguration:nil]) {
        [device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked];
        [device unlockForConfiguration];
    }
}
[newCaptureSession commitConfiguration];

......但无济于事。打开应用程序时,它仍然是自动白平衡。

1 个答案:

答案 0 :(得分:0)

设置捕获会话时:

 AVCaptureDevice *device = [self cameraWithPosition:AVCaptureDevicePositionBack];
 if ([device isWhiteBalanceModeSupported: AVCaptureWhiteBalanceModeLocked]) {
        if ([device lockForConfiguration:nil]) {
             [device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked];
             [device unlockForConfiguration];
        }
 }