How to Fix capturing images with front facing camera mirrors image? SnapChat seems to fix it as well as WhatsApp and Instagram , how can i? i would really love to find a sol
I did that a long ago. I don't have my system with me but i can say that transform your preview layer horizontally and it will show exact result as you want. For saving and exporting you will find lot of examples out here.
i figured this out myself, Here is the solution:
if captureDevice.position == AVCaptureDevicePosition.back {
if let image = context.createCGImage(ciImage, from: imageRect) {
return UIImage(cgImage: image, scale: UIScreen.main.scale, orientation: .right)
}
}
if captureDevice.position == AVCaptureDevicePosition.front {
if let image = context.createCGImage(ciImage, from: imageRect) {
return UIImage(cgImage: image, scale: UIScreen.main.scale, orientation: .leftMirrored)
}
}
}
return nil
}