How to Fix capturing images with front facing camera mirrors image, AVFoundation,Swift

前端 未结 2 957
情歌与酒
情歌与酒 2021-01-06 05:21

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

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-06 06:05

    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
            }
    

提交回复
热议问题