CoreImage.CIDetector Class
Image analysis class for face detection.

See Also: CIDetector Members

Syntax

[Foundation.Register("CIDetector", true)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_5_0)]
public class CIDetector : Foundation.NSObject

Remarks

CIDetector is a general API to perform image analysis on an image, but as of iOS5 only face detection is supported. You initiate the face detection by calling the static method CIDetector.CreateFaceDetector(CIContext, bool) and then get the results by calling one of the FeaturesInImage overloads.

C# Example

var imageFile = "photoFace2.jpg";
var image = new UIImage(imageFile);

var context = new CIContext ();
var detector = CIDetector.CreateFaceDetector (context, true);
var ciImage = CIImage.FromCGImage (image.CGImage);
var features = detector.GetFeatures (ciImage);

Console.WriteLine ("Found " + features.Length + " faces (origin bottom-left)");
foreach (var feature in features){
    var facefeature = (CIFaceFeature) feature;

    Console.WriteLine ("Left eye  {0} {1}\n", facefeature.HasLeftEyePosition,  facefeature.LeftEyePosition);
    Console.WriteLine ("Right eye {0} {1}\n", facefeature.HasRightEyePosition, facefeature.RightEyePosition);
    Console.WriteLine ("Mouth     {0} {1}\n", facefeature.HasMouthPosition,    facefeature.MouthPosition);
}
	

Instances of CoreImage.CIDetector are expensive to initialize, so application developers should prefer to re-use existing instances rather than frequently creating new ones.

Related content

Requirements

Namespace: CoreImage
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0