Need to show my camera view GrayScale (not camrea output) in ios app

75 Views Asked by At

I have a requirement in my app where I need to display the camera in a grayscale. I don't need to capture any images or videos from the camera, I just want to display the camera in grayscale view, as shown in the attached image.

Origional Image

GrayScale Image

I have tried WhiteBalanceGains by setting setWhiteBalanceModeLocked in 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)
        }
}

I have already tried it by applying filter on video output but I dont want any output from the camera so applying filter on output wasn't helped to solve this requirment.

0

There are 0 best solutions below