【问题标题】:iOS AVFoundation set exposure value, in EV unitsiOS AVFoundation 设置曝光值,以 EV 为单位
【发布时间】:2016-11-28 07:12:20
【问题描述】:

您好,我正在构建一个扫描 IOS 应用程序(条形码和二维码)。我有一个 silder 来调整曝光值(根据光线条件使图像更亮或更暗。我正在使用它来手动设置曝光值

captureDevice.setExposureTargetBias(slider.value, completionHandler: nil)

但我的问题是ExposureTargetBias 的最小值和最大值是多少,以便我们可以相应地为slider 设置minmax 值?

这是调整图像亮度的合适方法还是有其他方法? (iOS)。

【问题讨论】:

  • 如何手动设置曝光?
  • 内置IOS摄像头如何实现亮度?
  • 您对使用自动曝光或点击曝光不感兴趣?
  • 嗨,我正在尝试寻找手动更改图像亮度的方法(使用原生 ios 应用摄像头)
  • 您是否查看了 Apple 的 AVCam Manual 同一个项目。它有你需要的一切

标签: ios avfoundation


【解决方案1】:

您可以使用captureDevice.minExposureTargetBiascaptureDevice.maxExposureTargetBias 作为滑块的最小值和最大值。

【讨论】:

    【解决方案2】:

    使用AVCaptureDeviceFormat 中的以下属性获取曝光持续时间的最小值和最大值。

    斯威夫特

    var minExposureDuration: CMTime { get }
    var maxExposureDuration: CMTime { get }
    

    目标 C

    @property(nonatomic, readonly) CMTime minExposureDuration;
    @property(nonatomic, readonly) CMTime maxExposureDuration;
    

    请注意,您不能简单地将这些值直接设置到滑块中。您可能需要将其设置为 0-1 作为滑块范围,并从滑块值到实际设备曝光持续时间进行非线性映射。

    这是来自 Apple AVCam Manual 的示例代码

        self.exposureDurationSlider.minimumValue = 0;
        self.exposureDurationSlider.maximumValue = 1;
        double exposureDurationSeconds = CMTimeGetSeconds( self.videoDevice.exposureDuration );
        double minExposureDurationSeconds = MAX( CMTimeGetSeconds( self.videoDevice.activeFormat.minExposureDuration ), kExposureMinimumDuration );
        double maxExposureDurationSeconds = CMTimeGetSeconds( self.videoDevice.activeFormat.maxExposureDuration );
        // Map from duration to non-linear UI range 0-1
        double p = ( exposureDurationSeconds - minExposureDurationSeconds ) / ( maxExposureDurationSeconds - minExposureDurationSeconds ); // Scale to 0-1
        self.exposureDurationSlider.value = pow( p, 1 / kExposureDurationPower ); // Apply inverse power
        self.exposureDurationSlider.enabled = ( self.videoDevice && self.videoDevice.exposureMode == AVCaptureExposureModeCustom );
    

    如果您想获得清晰的二维码图片,您可能需要检查其他属性,例如焦点、白平衡。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多