我收到错误消息:
- whiteBalanceGains contain an out-of-range value. Red, green, and blue gains must be in the [1, maxWhiteBalanceGain] range
如何确定maxWhiteBalanceGain范围?
AVCaptureDevice *device =
[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureWhiteBalanceTemperatureAndTintValues temperatureAndTint = {
.temperature = 8000,
.tint = 146,
};
[device deviceWhiteBalanceGainsForTemperatureAndTintValues:temperatureAndTint];
[device setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:[device deviceWhiteBalanceGainsForTemperatureAndTintValues:temperatureAndTint] completionHandler:^(CMTime syncTime) {
}];
最佳答案
rom苹果开发人员文档
“请注意,尽管某些温度和色调组合会产生超出范围的设备RGB值,如果将其直接传递给setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler:
,将导致引发异常。请确保检查红色,绿色和蓝色增益值是否在该范围内为[1.0-maxWhiteBalanceGain]。
所以,首先,您必须获得白平衡增益
AVCaptureWhiteBalanceGains wbGains = [device deviceWhiteBalanceGainsForTemperatureAndTintValues:temperatureAndTint]
然后,检查
wbGains.redGain, wbGains.blueGain, wbGains.greenGain
是否在[1 ... maxWhiteBalanceGain]范围内。maxWhiteBalanceGain
是AVCaptureDevice
对象的属性。