Face Attention
Analyzes the face attention in a video stream. The event listener continuously gets the data in a JSON object as FaceAI analyzes the face attention.
Methods
EnxFaceAI.startFaceAttention(config, callback)
: To start analyzing face attention in a video stream.EnxFaceAI.stopFaceAttention(callback)
: To stop analyzing face attention in a video stream.
Parameters
For Method: EnxFaceAI.startFaceAttention(config, callback)
config
: JSON Object. This is to configure or customize parameter using which the Face Attention would be analyzed.smoothness
: Number. Default 0.83. Range 0-1. Value closer to 1 provides greater smoothing and slower response time. Lower values provide lesser smoothing but faster response time. Set it to 0 (zero) if you need the raw signal.
callback
: Callback to know that processing request has been accepted.
For Method: EnxFaceAI.stopFaceAttention(callback)
callback
: Callback to know that request has been accepted.
Event Listener
face-attention
: This event notification is received repeatedly with the Face Attention Analysis report as a JSON object.
JSON Object: Received with Face Attention Analysis data.
{ output: {attention: Number}}
Analysis Data Explanation
output
: Face Attention Reportattention
: Filtered value (smoothened) in range [0.0, 1.0]. A value close to 1.0 represents attention, a value close to 0.0 represents distraction.
Sample Code
config = {smoothness: 0.85};// Start Face AttentionfaceAI.startFaceAttention(config, (res) => {if (res.result === 0) {window.addEventListener("face-attention", (evt) => {console.log(evt.detail, "face-attention");});}});// Stop Face AttentionfaceAI.stopFaceAttention((res) => {if (res.result === 0) { }});