Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 572
Chaz Avatar asked Dec 18 '25 20:12

Chaz


1 Answers

When setting up your capture session:

 AVCaptureDevice *device = [self cameraWithPosition:AVCaptureDevicePositionBack];
 if ([device isWhiteBalanceModeSupported: AVCaptureWhiteBalanceModeLocked]) {
        if ([device lockForConfiguration:nil]) {
             [device setWhiteBalanceMode:AVCaptureWhiteBalanceModeLocked];
             [device unlockForConfiguration];
        }
 }
like image 139
Wildaker Avatar answered Dec 21 '25 12:12

Wildaker