See Also: CIDetector Members
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.