Chaz
Chaz

Reputation: 233

Can White Balance Mode be controlled on starting camera app? (ios)

Just a question I have been trying to experiment with. I know that the iphone camera starts with White Balance on continuous (2) in most if not all of the camera apps i have, as found in AVCaptureDevice.h in the AVFoundation framework:

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

};

But is there anyway that I can force it to start with White Balance Mode Locked?
I cannot seem to find where its dictating this condition.

I've tried including it in my capture Session here:

// 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];

...but to no avail. It's still auto white balancing upon opening the app.

Upvotes: 3

Views: 3086

Answers (1)

Wildaker
Wildaker

Reputation: 2533

When setting up your capture session:

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

Upvotes: 2

Related Questions