Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Core Image Detectors

View gist:e34ef9237619c09bcb7a
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
using System;
using MonoTouch.CoreImage;
using MonoTouch.UIKit;
 
namespace CIDetectorsDemo
{
public class DetectorController : UIViewController
{
UIImageView imageView;
 
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var imageIn = UIImage.FromBundle("card.jpg");
//var imageIn = UIImage.FromBundle("qrcode.png");
 
var context = CIContext.FromOptions (null);
 
var options = new CIDetectorOptions {
Accuracy = FaceDetectorAccuracy.High
};
 
var detector = CIDetector.CreateRectangleDetector (context, options);
//var detector = CIDetector.CreateQRDetector (context, options);
var ciImage = CIImage.FromCGImage (imageIn.CGImage);
var features = detector.FeaturesInImage (ciImage);
 
var overlay = CIImage.ImageWithColor (CIColor.FromRgba (1.0f, 0.0f, 0.0f, 0.7f));
overlay = overlay.ImageByCroppingToRect (features [0].Bounds);
var ciImageWithOverlay = overlay.CreateByCompositingOverImage (ciImage);
 
var imageOut = UIImage.FromImage (ciImageWithOverlay);
 
imageView = new UIImageView (imageOut);
imageView.Frame = View.Frame;
 
Add (imageView);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.