Skip to content

Instantly share code, notes, and snippets.

@iherrera
Created July 21, 2017 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iherrera/5e5de3204b25cc0565e6e59d1f78a460 to your computer and use it in GitHub Desktop.
Save iherrera/5e5de3204b25cc0565e6e59d1f78a460 to your computer and use it in GitHub Desktop.
[Foundation.Export("imagePickerController:didFinishPickingMediaWithInfo:")]
public virtual void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info){
picker.DismissViewController(true, ()=>{});
classificationLabel.Text = "Analyzing Image...";
correctedImageView.Image = null;
var originalImg = new NSString("UIImagePickerControllerOriginalImage");
var uiImage = (UIImage)info[originalImg];
var ciImage = new CIImage(uiImage);
var orientation = UIImageOrientationToCGImagePropertyOrientation(uiImage.Orientation);
inputImage = ciImage.CreateWithOrientation(orientation)
imageView.Image = uiImage;
//var handler = VNImageRequestHandler
}
public CGImagePropertyOrientation UIImageOrientationToCGImagePropertyOrientation(UIImageOrientation orientation){
switch (orientation){
case UIImageOrientation.Down:
return CGImagePropertyOrientation.Down;
case UIImageOrientation.DownMirrored:
return CGImagePropertyOrientation.DownMirrored;
case UIImageOrientation.Up:
return CGImagePropertyOrientation.Up;
case UIImageOrientation.UpMirrored:
return CGImagePropertyOrientation.UpMirrored;
case UIImageOrientation.Left:
return CGImagePropertyOrientation.Left;
case UIImageOrientation.LeftMirrored:
return CGImagePropertyOrientation.LeftMirrored;
case UIImageOrientation.Right:
return CGImagePropertyOrientation.Right;
case UIImageOrientation.RightMirrored:
return CGImagePropertyOrientation.RightMirrored;
default:
return CGImagePropertyOrientation.Up;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment