在macOS上设置并锁定AVCaptureDevice的温度和色调

时间:2018-06-10 22:03:03

标签: objective-c macos avfoundation avcapturedevice

我正在尝试设置并锁定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值。这可能表明有一种方法可以将白平衡锁定为固定值。有没有人有想法?

0 个答案:

没有答案