Yam Peroche
Yam Peroche

Reputation: 11

Camera capture device exposure mode lock

I'm trying to lock the exposure with the exposure point but it seems it doesn't work when I tried in my device. Although the Camera app works when you long press tap the screen to lock the exposure and the focus as well, but when trying it with my own app with the following lines of code, it doesn't work. Did I miss something on the configuration?

if ([_captureInput.device isExposureModeSupported:AVCaptureExposureModeLocked] && [_captureInput.device lockForConfiguration:NULL] && [_captureInput.device isExposurePointOfInterestSupported]) 
{
[_captureInput.device setExposurePointOfInterest:pointOfInterest];
[_captureInput.device setExposureMode:AVCaptureExposureModeLocked];
[_captureInput.device unlockForConfiguration];
}

Upvotes: 1

Views: 1483

Answers (1)

Pochi
Pochi

Reputation: 13459

an example of how to lock the configuration if you were to change the flash mode for example is like this:

AVCaptureDevice *temp = [[[[self captureSession] inputs] lastObject] device];

if ([temp isFlashModeSupported:AVCaptureFlashModeOn]) {
        NSError *error;
        bool locked = [temp lockForConfiguration:&error];
        if (locked) {
            switch (self.flashMode.intValue) {
                case 0: // Off
                    [temp setFlashMode:AVCaptureFlashModeOff];
                    break;
                case 1: // On
                    [temp setFlashMode:AVCaptureFlashModeOn];
                    break;
                case 2: // Auto
                    [temp setFlashMode:AVCaptureFlashModeAuto];
                    break;

                default:
                    break;
            }
        } else {
            NSLog(@"Could not lock for configuration");
        }

    }

Edit: THis is JUST an example (but it should work), as you can see i get the capture device in a very weird way because i dont save it anywhere if you had it saved or if u were handling it differently it would also work.

Upvotes: 1

Related Questions