Face Emotion Recognition Example
HUSKYLENS 2 face emotion recognition reads seven preset emotions and outputs IDs, names, counts and box coordinates in each frame, like a smart camera that tags every mood it sees.
1. Face Emotion Recognition Code Example
Before You Start:
1.1 Recognizing Facial Emotions and Outputting Related Data
Under the Face Emotion Recognition function, HUSKYLENS 2 can recognize seven predefined facial emotions: Anger (ID 1), Disgust (ID 2), Fear (ID 3), Happiness (ID 4), Neutral (ID 5), Sadness (ID 6), and Surprise (ID 7). These emotions are pre-trained at the factory on HUSKYLENS 2 and do not require users to perform additional manual learning. For detailed instructions on using the Face Emotion Recognition function, please refer to Face Emotion Recognition.
Using the following example program, you can count the total number of facial emotions recognized in the current HUSKYLENS 2 camera frame and output data such as the ID, quantity, name, center point coordinates, width, and height of a specified facial emotion.
The example program is shown below.
Upload the program and wait for the upload to complete.
When any of the seven facial emotions listed above appear in the camera view, observe that the HUSKYLENS 2 screen frames the face and displays the emotion ID, name, and confidence.
Running Result: As shown below, you can observe and count the total number of facial emotions in the current frame, as well as the related data of a facial emotion with a specified ID.
1.2 Obtaining Related Data of a Specified Facial Emotion in the Frame
When multiple facial emotions with the same ID appear in the frame, the following example program can be used to collect and output the related data of facial emotions with that ID in the frame.
Running Result: As shown below, when multiple facial emotions with a specified ID appear in the frame, you can obtain data such as the total number of facial emotions with that ID in the frame, their name, and the coordinates of a specified facial emotion under that ID.
1.3 Face Emotion Recognition Blocks Description
| block | Description |
|---|---|
|
Used to obtain expression recognition data once under HUSKYLENS 2 Face Emotion Recognition. |
|
Determine whether the current image contains seven specific expressions (anger (ID 1), disgust (ID 2), fear (ID 3), happiness (ID 4), neutral (ID 5), sadness (ID 6), and surprise (ID 7)). |
|
Get data of the expression closest to the crosshair: ID, name, center X/Y coordinates, width, and height. |
|
Get the total number of detected expressions. |
|
Get the related data of a specified expression when multiple expressions are detected. |
|
Get the total number of learned expressions that have been learned by HuskyLens 2, regardless of whether they appear in the current frame. |
|
Determine whether an expression with a specified ID is present (anger (ID 1), disgust (ID 2), fear (ID 3), happiness (ID 4), neutral (ID 5), sadness (ID 6), and surprise (ID 7)). |
|
Get the number of expressions with a specified ID. |
|
Get the related data of an expression by its ID. |
|
Get the related data of one specific expression when multiple identical expressions appear. |
Was this article helpful?
