ezAR adds Face Detection For Cordova

Face detection is a popular image processing capability that can be used as part of an augmented reality solutions. Today ezAR makes it easy to add face detection into your hybrid mobile apps with the new ezAR Startup Kit ver. 0.2.8. The Startup Kit includes our new facedetector plugin for Apache Cordova and Ionic. This plugin provides native OS-level face detection capabilities for the Android and iOS platforms. In addition to the facedetector plugin you will find the ezar-facedetector example project (see screenshot below) in the kit as well as on GitHub here

Download ezAR Startup Kit

Image from ezar-facedetector app

Image from ezar-facedetector app

Quick Start With Face Detection

In a future article I will walk through the details for implementing a cool face detection feature but for now here's a quick outline of the process with a matching code snippet. Additionally see the FaceDetector plugin docs to learn more.

Step-1: Add the ezAR FaceDetector and VideoOverlay plugins to your Cordova project
Step-2: Initialize the VideoOverlay plugin
Step-3: Select either front or back camera on the device and start the video preview
Step-4: Start face detection and process the face rectangles returned by the plugin

 ezar.initializeVideoOverlay(
  function() {
    ezar.getFrontCamera().start(             
      function() {
        ezar.watchFaces(onFaces,handleError);
      },
      handleError) //end camera start
    handleError);
    
//face detection callback, receives array of face rectangles 
function onFaces(facesArray) {
  console.log('faces cnt: ', facesArray.length);
  for (i=0; i < facesArray.length; i++) {
    var face = facesArray[i];
    console.log('face: ', face.left, face.top, face.right, face.bottom);
  }
}
    
//general error handler
function handleError(errMsg) {
  alert('Error: " + errMsg);
}

Update required for building on latest iOS 10 Platform

In addition to the new face detection capabilities the VideoOverlay and Snapshot plugins have been updated to create iOS 10 compatible apps. As small change to the plists was required to meet new iOS 10 requirements for access the device's camera and photo gallery.

Stay In Touch

In closing please let us know how you are using ezAR and what we can do to make it better.  @ezARTech (twitter), info@ezartech.com (email) or online forum.