目标c如何将AVCaptureDevice的显示方式重置为默认值

问题描述 投票:0回答:1

我正在使用以下相机设置自定义曝光/ iso:

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

这很好。但是,在应用会话期间,这些自定义设置将保持不变。有没有一种方法可以重置捕获设备的曝光/ iso设置?我已经尝试过类似的东西:

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

但是不会将相机重置为默认设置。

objective-c avcapturesession iso avcapturedevice exposure
1个回答
0
投票

您可以在自定义曝光模式之前存储它

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

然后在需要时将其还原

AVCaptureDevice* cd = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([cd lockForConfiguration:&error]){
    cd.exposureMode = self.defaultExposureMode;
    [cd unlockForConfiguration];
}
© www.soinside.com 2019 - 2024. All rights reserved.