Skip to content

Instantly share code, notes, and snippets.

@Clancey
Created June 23, 2011 19:05
Show Gist options
  • Save Clancey/1043336 to your computer and use it in GitHub Desktop.
Save Clancey/1043336 to your computer and use it in GitHub Desktop.
/* ios version
NSDictionary *contextDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:@"kCIContextUseSoftwareRenderer"];
CIContext *ciContext = [CIContext contextWithOptions:contextDict];
NSDictionary *detectorDict = [NSDictionary dictionaryWithObject:@"CIDetectorAccuracyHigh" forKey:@"CIDetectorAccuracy"];
CIDetector *detector = [CIDetector detectorOfType:@"CIDetectorTypeFace" context:ciContext options:detectorDict];
CIImage *image = [[CIImage alloc] initWithImage:self.faceImage.image];
NSArray *features = [detector featuresInImage:image];
*/
string imageFile = "IMG_0540.jpg";
NSDictionary contextDict = NSDictionary.FromObjectAndKey(NSNumber.FromBoolean(false),new NSString("kCIContextUseSoftwareRenderer"));
NSDictionary detectorOptions = NSDictionary.FromObjectAndKey(new NSString("CIDetectorAccuracyHigh"),new NSString("CIDetectorAccuracy"));
CIContext context = CIContext.FromOptions(contextDict);
CIDetector detector = CIDetector.FromType("CIDetectorTypeFace",context,detectorOptions);
var image = new UIImage(imageFile);
var ciImage = CIImage.FromCGImage(image.CGImage);
var features = detector.FeaturesInImage(ciImage);
//detector.
Console.WriteLine(features.Count());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment