7

我正在为 IOS (13) 开发相机应用程序。为此,我将 AVCaptureSession 与 AVCaptureVideoPreviewLayer 结合使用。到目前为止一切正常。

现在我想让用户从给定的典型快门速度值数组(以 1/3 曝光停止)中选择并设置自定义快门速度(曝光持续时间)作为 [Int32]:

let shutterSpeedValues: [Int32] = [1, 2, 3, 4, 5, 6, 8, 10, 13, 15, 20, 25, 30, 40, 50, 60, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, 10000, 12800, 16000, 20000, 2400]

我将所需的曝光设置为 - 据我所知 - 只有以下功能的可能方式:

captureDevice?.setExposureModeCustom(duration: CMTimeMake(value: 1, timescale: shutterSpeedValues[index]), iso: AVCaptureDevice.currentISO, completionHandler: nil)

检查 AVCaptureDevice 的 exposureDuration 值表明,这可以为较慢的快门速度(高达 1/200 秒)提供完全准确的结果。选择的曝光持续时间越快,差异越大。例如:

1/250th -> 1/251th
1/400th -> 1/403th
1/640th -> 1/648th
1/1000th -> 1/1021th
1/4000th -> 1/4366th
1/8000th -> 1/9615th
1/1200th -> 1/16129th
1/16000th -> 1/24390th
1/20000th -> 1/24390th
1/24000th -> 1/49999th (which is the activeFormat's minExposureDuration in this case)

我了解标称快门速度(对用户更方便的四舍五入的近似数字)与相机使用的精确实际快门速度之间存在差异(请参阅https://www.scantips.com/lights/fstop2. html ). 后者彼此之间的差异恰好是相邻光圈的 2 倍或 1/2 曝光(这将是 1/2、1/4、1/8、1/16、1/32、1/64 等值, 1/128, 1/256, 1/512, 1/1024, ..., 1/4096, ..., 1/8192...)。然而,这仍然不能解释我在更快的快门速度下得到的这些极端差异。

我还尝试像这样明确设置(随机)快速快门速度:

captureDevice?.setExposureModeCustom(duration: CMTimeMake(value: 1, timescale: 10000, iso: AVCaptureDevice.currentISO, completionHandler: nil)

或这个

captureDevice?.setExposureModeCustom(duration: CMTimeMakeWithSeconds(0.0001, preferredTimescale: 1000000000), iso: AVCaptureDevice.currentISO, completionHandler: nil) 

但两者仍然导致曝光持续时间为 1/12048(而不是 1/10000)...

我是否遗漏了与 CMTime 相关的内容,这与视频的帧速率有关(尽管更改 captureDevice 的 activeVideoMinFrameDuration 和 activeVideoMaxFrameDuration 没有任何效果)还是根本不可能设置完全自定义的曝光持续时间?

顺便提一句。我在尝试实现一个功能时遇到了同样的问题,该功能应该允许用户在(连续)自动曝光模式下定义最小快门速度(为此我使用了 captureDevice 的 activeMaxExposureDuration 函数)......

任何想法或提示将不胜感激。

4

0 回答 0