Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
picker.dismiss(animated: true)
classificationLabel.text = "Analyzing Image…"
correctedImageView.image = nil
guard let uiImage = info[UIImagePickerControllerOriginalImage] as? UIImage
else { fatalError("no image from image picker") }
guard let ciImage = CIImage(image: uiImage)
else { fatalError("can't create CIImage from UIImage") }
let orientation = CGImagePropertyOrientation(uiImage.imageOrientation)
inputImage = ciImage.applyingOrientation(Int32(orientation.rawValue))
// Show the image in the UI.
imageView.image = uiImage
// Run the rectangle detector, which upon completion runs the ML classifier.
let handler = VNImageRequestHandler(ciImage: ciImage, orientation: Int32(orientation.rawValue)) .userInteractive).async {
do {
try handler.perform([self.rectanglesRequest])
} catch {

This comment has been minimized.

Copy link

@biranchi2018 biranchi2018 commented Mar 21, 2018

 applyingOrientation is deprecated now.
    inputImage = ciImage.applyingOrientation(Int32(orientation.rawValue))

Use the below code:
inputImage = ciImage.oriented(forExifOrientation: Int32(orientation.rawValue))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment