首页 > 解决方案 > 固定的avfoundation变量,不同的显示亮度

问题描述

我已经使用 avfoundation 将 iPad 值的 ISO/白平衡/曝光值修复为 AR 应用程序中的固定值。我把 iPad 放在三脚架上。如果我将空间中的照明从 A 切换到 B 再切换回 A,iPad 显示亮度和颜色不稳定。

有什么解决办法吗?

我尝试使用以下代码修复所有 avfoundation 变量,但显示仍然会改变。

    case .wbset2:
        device2?.unlockForConfiguration()
        do {
            if ((try device2?.lockForConfiguration()) != nil) {

                var g = (device2?.deviceWhiteBalanceGains)!
                g.redGain = 1.685
                g.greenGain = 1
                g.blueGain = 2.367

                device2?.setWhiteBalanceModeLocked(with: g, completionHandler: nil)
                var dur: CMTime = device2!.exposureDuration
                dur = CMTimeMake(value: 1964000, timescale: 1000000000)

                device2?.automaticallyAdjustsVideoHDREnabled = false

                device2?.setExposureModeCustom(duration: dur, iso: 121.9, completionHandler: nil)

                try device2?.lockForConfiguration()

                var wbg2 = device2?.deviceWhiteBalanceGains
                lab_ij.text = "wb: \(wbg2)"
                lab_exp.text = "duration: \(device2?.exposureDuration),iso:\(device2?.iso)"
            }
        } catch{
        }

标签: iosswiftavfoundation

解决方案


推荐阅读