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.
Methods
EnxFaceAI.startFaceDetector(config, callback)
: To start detecting faces.EnxFaceAI.stopFaceDetector(callback)
: To stop detecting faces.
Parameters
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 coordinatey
: Upper left point y coordinatewidth
: Width of the bounding boxheight
: Height of the bounding box
status
: String. Its status of the face trackerINIT
: Detector initializing; zero or many faces could be returnedTRACK_OK
: Detector is correctly tracking one face; one face is returnedRECOVERING
: Detector lost a face and attempting to recover and continue tracking; zero faces are returned
Sample Code
config = {maxInputFrameSize: 200,fullFrameDetection: true};// Start Face DetectorfaceAI.startFaceDetector(config, (res) => {if (res.result === 0) {window.addEventListener("face-detector", (evt) => {console.log(evt.detail, "face-detector");});}});// Stop Face DetectorfaceAI.stopFaceDetector((res) => {if (res.result === 0) { }});