Face Emotion Recognition Example
HUSKYLENS 2 face emotion recognition reads seven preset emotions, like a smart mirror counting moods in real time, and Mind+ blocks let users detect, locate, count and filter expressions by ID for STEM projects
1.Face Emotion Recognition Blocks
Before You Start:
1.1 Recognize All Facial Emotion
Under the Face Emotion Recognition function, HUSKYLENS 2 can recognize seven predefined expressions: Anger (ID 1), Disgust (ID 2), Fear (ID 3), Happy (ID 4), Neutral (ID 5), Sad (ID 6), and Surprise (ID 7). These expressions are pre-trained before shipment, and no manual learning is required. For detailed usage instructions, please refer to Face Emotion Recognition.
The following sample program can count all recognized expressions in the camera view and output their related data sequentially.
The sample program is as follows.
Click “Upload” in Mind+ and wait for the upload to complete. Then switch to Face Emotion Recognition from the touchscreen.
When any of the seven expressions appear in the screen, HUSKYLENS 2 will highlight them and display the expression name and confidence score.
Result:When a fearful expression appears, the serial port outputs the total number and corresponding expression name.
Result:When multiple facial expressions appear, the serial port outputs the total number and names of all recognized expressions.
1.2 Count Each Type of face emotion
Since output IDs are within 1–7, we can use the following sample program to count each expression type in the camera view.
Result:When multiple different expressions appear, the serial port outputs the type and number of each expression.
1.3 Face Emotion Recognition Block 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. |
|
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?
