我正在尝试设置并锁定macOS中的网络摄像头(AVCaptureDevice)的温度和色调。这是我试过的代码:
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeLocked]) {
float tempVal = 5000.0f;
float tintVal = 0.0f;
AVCaptureWhiteBalanceTemperatureAndTintValues temperatureAndTint = {
.temperature = tempVal,
.tint = tintVal,
};
AVCaptureWhiteBalanceGains wbGains = [device deviceWhiteBalanceGainsForTemperatureAndTintValues:temperatureAndTint];
[device setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:wbGains completionHandler:^(CMTime syncTime) {}];
}
似乎它仅在iOS上受支持。在macOS上我得到如下错误:
'AVCaptureWhiteBalanceTemperatureAndTintValues' is unavailable: not available on macOS
'AVCaptureWhiteBalanceGains' is unavailable: not available on macOS
'setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler:' is unavailable: not available on macOS
但是,if
的第一个isWhiteBalanceModeSupported
语句适用于macOS并返回true
值。这可能表明有一种方法可以将白平衡锁定为固定值。有没有人有想法?