Face Detection
Detects human faces in real time from the camera video and tracks their positions. Includes emotion recognition and age and gender estimation.
Commands
| Command | Description |
| Face Detected? | Checks whether a face is detected. |
| Count Faces | Writes the number of detected faces. |
| Get Face | Writes the confidence, center point, and width and height of one face chosen by Select By. |
| Get All Faces | Writes every detected face as JSON. |
| Recognize Emotion | When a face is detected, analyzes the expression and classifies it into one of 8 emotions. |
| Estimate Age/Gender | Estimates the age and gender of the detected face. |
When a Detection Zone is set, only faces inside it are considered.
Settings
| Setting | Description |
| Confidence (%) | Default 70. |
| Detection Zone | See Common Items. |
| Select By | Highest Confidence (default), By Confidence Index (0-based), Largest Size, Closest From Ref. Point. |
| Index (0-based) | 0 to 15, default 0. |
| Reference Point | See Common Items. |
Output Variables
| Field | Type | Value |
| Detected | Digital | True when a face is detected. |
| Count | Number | Number of detected faces. |
| Confidence (%) | Number | Confidence of the selected face, 0 to 100. |
| Center Point X / Center Point Y | Number | Pixel coordinates of the selected face's center. |
| Width (Pixels) / Height (Pixels) | Number | Size of the selected face's box. |
| Output (JSON Text) | Text | Array of every detected face. |
| Emotion | Text | English name of the recognized emotion; none when not detected. |
| Emotion ID | Number | Emotion number 0 to 7; -1 when not detected. |
| Emotion Confidence (%) | Number | 0 to 100; -1 when not detected. |
| Age | Number | Estimated age 0 to 100; -1 when not detected. |
| Gender | Text | male or female; none when not detected. |
| Gender Confidence (%) | Number | 0 to 100; -1 when not detected. |
JSON Output
Each face carries score (confidence, 0 to 100), bbox, center, width, and height. The emotion keys (emotion, emotion_id, emotion_confidence) are present only while Recognize Emotion runs, and the age and gender keys (age, gender, gender_confidence) only while Estimate Age/Gender runs. Note that the confidence key is score, unlike confidence in Object Detection.
[
{
"score": 95,
"bbox": { "x1": 120, "y1": 80, "x2": 250, "y2": 300 },
"center": { "x": 185, "y": 190 },
"width": 130,
"height": 220,
"emotion": "happy",
"emotion_id": 4,
"emotion_confidence": 87,
"age": 28,
"gender": "male",
"gender_confidence": 92
}
]
The 8 emotions and their IDs
| ID | Emotion | Meaning |
| 0 | angry | Anger |
| 1 | contempt | Contempt |
| 2 | disgust | Disgust |
| 3 | fear | Fear |
| 4 | happy | Happiness |
| 5 | neutral | Neutral |
| 6 | sad | Sadness |
| 7 | surprise | Surprise |