需要在 ios 应用程序中显示我的相机视图 GrayScale(不是 camrea 输出)

问题描述 投票:0回答:0

我在我的应用程序中有一个要求,我需要以灰度显示相机。我不需要从相机捕捉任何图像或视频,我只想以灰度视图显示相机,如附图所示。

我已经通过在

WhiteBalanceGains
中设置
setWhiteBalanceModeLocked
来尝试
AVCaptureDevice

let redGain: Float = 3
let greenGain: Float = 1
let blueGain: Float = 2

if backVideoDevice!.isLockingWhiteBalanceWithCustomDeviceGainsSupported {
do {
    try backVideoDevice?.lockForConfiguration()
    backVideoDevice?.setWhiteBalanceModeLocked(with:   AVCaptureDevice.WhiteBalanceGains.init(redGain: redGain, greenGain: greenGain, blueGain: blueGain))
    backVideoDevice?.unlockForConfiguration()
} catch {
    print(error.localizedDescription)
        }
}

我已经尝试通过在视频输出上应用过滤器来尝试它,但我不希望相机输出任何内容,因此在输出上应用过滤器无助于解决此要求。

ios swift filter camera avcapturesession
© www.soinside.com 2019 - 2024. All rights reserved.