How to generate an UIImage from AVCapturePhoto with correct orientation?
I am calling AVFoundation 's delegate method to handle a photo capture, but I am having difficulty converting the AVCapturePhoto it generates into an UIImage with the correct orientation. Although the routine below is successful, I always get a right-oriented UIImage ( UIImage.imageOrientation = 3). I have no way of providing an orientation when using the UIImage(data: image) and attempting to first use photo.cgImageRepresentation()?.takeRetainedValue() also doesn't help. Please assist. Image orientation is critical here as the resulting image is being fed to a Vision Framework workflow. func