Face Emotion Recognition Example
HuskyLens 2 reads seven preset emotions and streams IDs and positions to micro:bit, like a mood sensor for faces, enabling counts, closest emotion selection, and detailed data per target.
1. Face Emotion Recognition Project Example
Before You Start:
1.1 Face Emotion Recognition and Output Relevant Data
When face emotion recognition is enabled, facial expressions appearing on the HuskyLens 2 screen will be detected and analyzed, allowing you to access key data: total detected emotions, emotion types, center-closest emotion, and specified ID emotion. This data includes the emotion's ID, name, center coordinates (XY), width, and height.Under the Face Emotion Recognition function, HUSKYLENS 2 can recognize 7 specific emotions: angry (ID 1), disgust (ID 2), fear (ID 3), happy (ID 4), neutral (ID 5), sad (ID 6), and surprise (ID 7). These emotions have already been learned by HUSKYLENS 2 at the factory, so users do not need to learn them manually again.
Example program:
Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a face showing emotion to observe the output.
As shown, when HuskyLens 4 detects facial emotions such as "Happiness" "Neural"and“Fear”, the following data will display:
How to use face emotion recognition, please refer to the Face Emotion Recognition.
Result: The serial port will output: total detected emotions, ID of the center-closest emotion, and emotion recognition results.
There are 4 detected emotions, so the dot matrix display shows "4".
1.2 Obtaining Face Emotion Recognition Feature Data
The system can capture detailed emotion analysis data for any detected facial expression. Key readable information includes: emotion ID, name, width, height, center coordinates (X/Y), and confidence levels for different emotion categories.
For instance, the sample program below retrieves emotion feature data of facial expressions positioned near the camera's center; this functionality works with the 7 pre-trained emotion categories.
Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a face showing emotion, and the serial port will display the emotion ID along with detailed recognition data.
1.3 Obtaining Data of a Specific Face Emotion
When multiple facial emotions with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth emotion in the detected sequence.
Example program:
Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two emotions labeled ID 4 (HAPPY). After activation, the serial port will output data statistics for these emotions, including their individual positions.
1.4 Face Emotion Recognition Blocks Description
| block | Description |
|---|---|
|
Used to obtain one set of Face Emotion Recognition data under the Face Emotion Recognition function of HUSKYLENS 2. |
|
Determine if a facial emotion is present in the current frame. |
|
Retrieves data of the emotion closest to the screen cross cursor, including emotion ID, emotion name, center X/Y coordinates, width, and height. |
|
Get the total number of emotions detected on the screen. |
|
When multiple emotions are detected, retrieves data for a specified emotion. |
|
Gets the total number of learned emotions on the screen. |
|
Obtain the number of emotions with the specified ID in the current frame. |
|
When multiple face emotions are detected, retrieve the relevant data of a specified emotion. |
|
When multiple face enotions with the same ID are detected, retrieve the relevant data of a face emotion. |
Was this article helpful?
