Face Detection is a native extension to use iOS Core Image framework. It can be used to easily detect faces in images or live video in real-time from the camera. Using the extension, you can change the perspective of a game when the user moves left and right, for instance.
The high-level API is extremely easy to use, but if you need more advanced functionalities, you can use the low-level API, which comes with 30+ classes and 240+ methods. The extension does not include the image filters in the Core Image framework, but it has an extensive list of features:
- High accuracy face detection in images
- Fast face detection in live video in real-time from a camera
- Convenience utilities to easily read images from CameraUI and CameraRoll and auto-rotates according to orientation in image EXIF data
- Camera preview video sprite that auto-rotates according to the orientation of the device; fixes the problem that AIR captures only in landscape mode on mobile devices
Sample
var supported:Boolean = CoreImage.isSupported; var coreimage:CoreImage = new CoreImage(); // use high accuracy and don't track faces faceDetector = new FaceDetector(true, false); // Detect faces in a BitmapData object // Each Face object in the Vector contains the face location and size, mouth and eyes locations. var faces:Vector. = faceDetector.detectInImage(bitmapData); // Face Detection in Live Video // use front camera, full screen size, and 24 fps previewVideo = new CameraPreviewVideo(true, -1, -1, 24); addChild(previewVideo); faceDetector = new FaceDetector(false, false); faceDetector.addEventListener(FaceDetector.FACES_DETECTED_EVENT, function(e:FacesDetectedEvent):void { trace(e.faces); // a vector of faces }); faceDetector.addEventListener(FaceDetector.FACES_NOT_DETECTED_EVENT, function(e:Event):void { trace("no detection"); }); // start detection doing 12 detections per sec faceDetector.startDetection(previewVideo, 12);