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.


  • EnxFaceAI.startFaceEmotion(config, callback) : To start analyzing face emotions in a video stream.|
  • EnxFaceAI.stopFaceEmotion(callback) : To stop analyzing face emotions in a video stream.


For Method: EnxFaceAI.startFaceEmotion(config, callback)

  • config : JSON Object. This is to configure or customize parameter using which the Face Gender would be analyzed.
    • smoothness : Number. Default 0.95. Range 0-1. A value closer to 1 provides greater smoothing and slower response time. Lower values provide less smoothing but faster response time. Set it to 0 (zero) if you need the raw signal.
    • threshold : Number. Default 0.70. Range 0.5-1. It controls the minimum value of confidence for which mostConfident output returns the predicted gender name instead of undefined.
  • callback : Callback to know that processing request has been accepted.

For Method: EnxFaceAI.stopFaceEmotion(callback)

  • callback : Callback to know that 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

config = {
smoothness: 0.95,
threshold: 0.70
// Start Face Emotion
faceAI.startFaceEmotion(config, (res) => {
if (res.result === 0) {
window.addEventListener("face-emotion", (evt) => {
console.log(evt.detail, "face-emotion");
// Stop Face Emotion
faceAI.stopFaceEmotion((res) => {
if (res.result === 0) { }