Face Detector

Detects the count of faces in a video stream. The Event Listener collects the data in a JSON object as FaceAI detects the faces.


  • EnxFaceAI.startFaceDetector(config, callback) : To start detecting faces.
  • EnxFaceAI.stopFaceDetector(callback) : To stop detecting faces.


For Method: EnxFaceAI.startFaceDetector(config, callback)

  • config : JSON Object. This is to configure or customize parameter using which the Face Detector would analyze.
    • maxInputFrameSize : Number. Default 160 (pixel). Input Frame Size in pixels for Face Detection.
    • fullFrameDetection : A boolean. It is true when detection was full-frame and multiple faces can be returned, false otherwise.
  • callback : Callback to know that processing request has been accepted.

For Method: EnxFaceAI.stopFaceDetector(callback)

  • callback : Callback to know that request has been accepted.

Event Listener

  • face-detector: This event notification is received repeatedly with Face Detection Analysis data as a JSON object.

JSON Object: Received with Face Detection Analysis data.

faces: Array(n)
rects: Array(n)
status: string

Analysis Data Explanation

  • faces : Array. The detected faces in form of ImageData objects (zero or one; or multiple faces, if fullFrameDetection is true)
  • rects : Array of objects. Describes the bounding boxes (zero or one; or multiple rects, if fullFrameDetection is true)
    • x : Upper left point x coordinate
    • y : Upper left point y coordinate
    • width : Width of the bounding box
    • height : Height of the bounding box
  • status : String. Its status of the face tracker
    • INIT : Detector initializing; zero or many faces could be returned
    • TRACK_OK : Detector is correctly tracking one face; one face is returned
    • RECOVERING : Detector lost a face and attempting to recover and continue tracking; zero faces are returned

Sample Code

config = {
maxInputFrameSize: 200,
fullFrameDetection: true
// Start Face Detector
faceAI.startFaceDetector(config, (res) => {
if (res.result === 0) {
window.addEventListener("face-detector", (evt) => {
console.log(evt.detail, "face-detector");
// Stop Face Detector
faceAI.stopFaceDetector((res) => {
if (res.result === 0) { }