0

I'm setting custom exposure/iso with the camera using:

AVCaptureDevice* cd = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[cd setExposureModeCustomWithDuration:cmtime ISO:iso completionHandler:nil];

This works fine. However, for the duration of the app's session these custom settings persist. Is there a way to reset the capture device's exposure/iso settings? I've tried something like:

if([captureDevice lockForConfiguration:&error]){
    [captureDevice setExposureModeCustomWithDuration:captureDevice.activeFormat.minExposureDuration ISO:captureDevice.activeFormat.minISO completionHandler:nil];
    [captureDevice unlockForConfiguration];
}

But this doesn't reset the camera to the default settings.

user3335999
  • 392
  • 1
  • 2
  • 17

1 Answers1

0

You can store exposure mode before customising it

AVCaptureDevice* cd = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

self.defaultExposureMode = cd.exposureMode; // store in some property

if([cd lockForConfiguration:&error]){
    [cd setExposureModeCustomWithDuration:cmtime ISO:iso completionHandler:nil];
    [cd unlockForConfiguration];
}

and then restore it when needed

AVCaptureDevice* cd = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([cd lockForConfiguration:&error]){
    cd.exposureMode = self.defaultExposureMode;
    [cd unlockForConfiguration];
}
Asperi
  • 228,894
  • 20
  • 464
  • 690
  • That's a possibility. I was hoping there was a way to tell the camera to "resume as you were". – user3335999 May 27 '20 at 05:02
  • No, this doesn't seem to work. I record the current ISO and exposure before ever calling setExposureModeCustomWithDuration. Since these values are auto adjusting, it can be caught at the "wrong" time. Either too much exposure or too little. – user3335999 May 29 '20 at 03:26
  • @user3335999, then reset to some constant, eg. `.autoExpose` – Asperi May 29 '20 at 03:28