【问题标题】:Objective c how to reset AVCaptureDevice exposure to defaultsObjective c 如何将 AVCaptureDevice 曝光重置为默认值
【发布时间】:2020-09-12 16:04:49
【问题描述】:

我正在使用相机设置自定义曝光/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】:

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

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

【讨论】:

  • 这是可能的。我希望有一种方法可以告诉相机“恢复原状”。
  • 不,这似乎不起作用。在调用 setExposureModeCustomWithDuration 之前,我会记录当前的 ISO 和曝光。由于这些值是自动调整的,因此可能会在“错误”的时间被捕获。曝光过多或过少。
  • @user3335999,然后重置为某个常数,例如。 .autoExpose
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-12
  • 2012-04-07
相关资源
最近更新 更多