Appery Face Detection

Face detection

FaceRecognizer.recognizeFace

Parameters
  • {string} filePath - path to image
  • {function} success - callback function which takes a parameter data which will be invoked on success
  • {function} error - callback function which takes a parameter err which will be invoked on failure
  • {object} options - options for face detector
Supported Options
propertyvaluedescription
performanceModeFAST (default) / ACCURATEFavor speed or accuracy when detecting faces.
landmarksDetectionNO_LANDMARKS (default) / ALL_LANDMARKSWhether to attempt to identify facial "landmarks": eyes, ears, nose, cheeks, mouth, and so on.
contoursDetectionNO_CONTOURS (default) / ALL_CONTOURSWhether to detect the contours of facial features. Contours are detected for only the most prominent face in an image.
facesClassificationNO_CLASSIFICATIONS (default) / ALL_CLASSIFICATIONSWhether or not to classify faces into categories such as "smiling", and "eyes open".
minimumFaceSizedouble (default: 0.1)The minimum size, relative to the image, of faces to detect.
enableFaceTrackingfalse (default) / trueWhether or not to assign faces an ID, which can be used to track faces across images.
useBase64false (default) / trueWhether or not filePath is a base64 encoded string.
detectedFaceImageDatatrue (default) / falsereturn or not cropped face image data in base64 format depends on detectedFaceImageResultType option value for every detected face; if true, each item of response "faces" array contains "faceImage" field with the data
encodingTypeEncodingType.JPEG (default) / EncodingType.PNGformat of output cropped face image
detectedFaceImageResultTypeCameraResultType.BASE64_STRING (default) / CameraResultType.DATA_URLinclude captured photo as only base64 string or as full data url

Example:

window.ApperyioMLCordovaPlugin.FaceRecognizer.recognizeFace('filePath', successCallback, errorCallback, {
    landmarksDetection: ApperyioMLCordovaPlugin.FaceDetectorOptions.LandmarksDetection.ALL_LANDMARKS,
    facesClassification: ApperyioMLCordovaPlugin.FaceDetectorOptions.FacesClassification.ALL_CLASSIFICATIONS,
    useBase64: true,
    detectedFaceImageData: true,
    encodingType: ApperyioMLCordovaPlugin.FaceDetectorOptions.EncodingType.PNG,
    detectedFaceImageResultType: ApperyioMLCordovaPlugin.FaceDetectorOptions.CameraResultType.DATA_URL
})

Sample JSON callback: face_recognition.json

FaceRecognizer.startRealTimeFaceDetection

Parameters
  • {function} success - callback function which takes a parameter data which will be invoked on success
  • {function} error - callback function which takes a parameter err which will be invoked on failure
  • {object} options - options for face detector
Supported Options
propertyvaluedescription
performanceModeFAST (default) / ACCURATEFavor speed or accuracy when detecting faces.
landmarksDetectionNO_LANDMARKS (default) / ALL_LANDMARKSWhether to attempt to identify facial "landmarks": eyes, ears, nose, cheeks, mouth, and so on.
contoursDetectionNO_CONTOURS (default) / ALL_CONTOURSWhether to detect the contours of facial features. Contours are detected for only the most prominent face in an image.
facesClassificationNO_CLASSIFICATIONS (default) / ALL_CLASSIFICATIONSWhether or not to classify faces into categories such as "smiling", and "eyes open".
minimumFaceSizedouble (default: 0.1)The minimum size, relative to the image, of faces to detect.
enableFaceTrackingfalse (default) / trueWhether or not to assign faces an ID, which can be used to track faces across images.
showFaceBoundingBoxtrue (default) / falseWhether or not show green rectangle around a detected face
showFaceContoursfalse (default) / trueWhether or not show dots contour on a detected face (face border, eyes, nose and mouth)
frameImageDatatrue (default) / falseWhether include base64 of captured photo or not
frameImageResultTypeCameraResultType.BASE64_STRING (default) / CameraResultType.DATA_URLinclude captured photo as only base64 string or as full data url
encodingTypeEncodingType.JPEG (default) / EncodingType.PNGformat of output photo base64
cameraDirectionCameraDirection.BACK (default) / CameraDirection.FRONTUse back or front camera of device during face detection
delay500 (default)Time interval in msec, for performing detection each interval value
detectedFaceImageDatatrue (default) / falsereturn or not cropped face image data in base64 format depends on frameImageResultType option value for every detected face; if true, each item of response "faces" array contains "faceImage" field with the data

Example:

window.ApperyioMLCordovaPlugin.FaceRecognizer.startRealTimeFaceDetection(successCallback, errorCallback, {
    landmarksDetection: ApperyioMLCordovaPlugin.FaceDetectorOptions.LandmarksDetection.ALL_LANDMARKS,
    contoursDetection:  ApperyioMLCordovaPlugin.FaceDetectorOptions.ContoursDetections.ALL_CONTOURS,
    facesClassification: ApperyioMLCordovaPlugin.FaceDetectorOptions.FacesClassification.ALL_CLASSIFICATIONS,
    enableFaceTracking: false,
    showFaceBoundingBox: true,
    showFaceContours: false,
    frameImageData: true,
    frameImageResultType: CameraResultType.DATA_URL,
    delay: 100,
    encodingType: this.window.ApperyioMLCordovaPlugin.FaceDetectorOptions.EncodingType.PNG,
    cameraDirection: this.window.ApperyioMLCordovaPlugin.FaceDetectorOptions.CameraDirection.BACK
});

FaceRecognizer.stopRealTimeFaceDetection

Parameters
  • {function} success - callback function which takes a parameter data which will be invoked on success
  • {function} error - callback function which takes a parameter err which will be invoked on failure

Example:

window.ApperyioMLCordovaPlugin.FaceRecognizer.stopRealTimeFaceDetection(successCallback, errorCallback)