Face Emotion

Analyzes eight face emotions in a video stream. These emotions are: Angry, Disgust, Fear, Happy, Sad, Surprise, and Neutral. It also returns most dominant emotion on a face. The event listener continuously gets the data in a JSON object as FaceAI analyzes the face emotions.

Method

To analyze face emotions in a video stream.

Method: EnxFaceAI.startFaceEmotion(callback)

Parameter

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

Event Listener

  • face-emotion : This event notification is received repeatedly with the Face Emotion Analysis report as a JSON object.

JSON Object: Received with Face Emotion Analysis data.

{ output: {
dominantEmotion: String,
emotion: {
Angry: Number,
Disgust: Number,
Fear: Number,
Happy: Number,
Neutral: Number,
Sad: Number,
Surprise: Number
}
}
}

Analysis Data Explanation

  • output : Face Emotion Report
    • dominantEmotion : Name of Dominant Emotion if present, otherwise it is undefined.
    • emotion : Filtered (smoothened) values of the probability distribution of emotions. The sum of all the probabilities is always 1, each probability in the distribution has a value between 0 and 1.
      • Angry : Probability for Angry.
      • Disgust : Probability for Disgust.
      • Fear : Probability for Fear.
      • Happy : Probability for Happy.
      • Sad : Probability for Sad.
      • Surprise : Probability for Surprise.
      • Neutral : Probability for Neutral.

Sample Code

// Start Face Emotion
faceAI.startFaceEmotion((res) => {
if (res.result === 0) {
window.addEventListener("face-emotion", (evt) => {
console.log(evt.detail, "face-emotion");
});
}
});