Face Recognition Example

Face recognition blocks let HuskyLens 2 detect, count, and label faces in real time, then stream rich coordinate data to Mind+. It’s like giving your camera a smart attendance sheet that tracks who is in frame and where every key facial feature is positioned.

1.Face Recognition Blocks

Before You Start:

1.1 Face Recognition - Output Relevant Data

Under the Face Recognition function, when a face appears on the HuskyLens 2 screen, it can be detected and framed, allowing the acquisition of the total number of faces detected and related data for a specified face.

I2C Example Program:

Interface Diagram

UART Example Program:

The sample code provided below is for I2C mode only. If you need to use UART mode, simply modify the code by following the initialization method shown in the program below.

Interface Diagram

Click 'Run' in Mind+ and wait for the program to upload.

Point the HuskyLens 2 camera at the face in the frame to learn it. For detailed instructions on how to learn faces, refer to: Face Recognition.

Once learning is complete, aim at the learned face and observe the output results on the M10 screen.

Output Result: As shown below, you can obtain the total number of faces detected in the frame, whether or not the face has been learned; you can specify the face ID near the center of the camera frame, and the ID of the first detected face (faces not learned will have an ID of 0).

Interface Diagram

1.2 Get Detailed Data of a Specific Face in the Frame

It can acquire facial feature and position data of a specified face. The readable face data includes: Face ID, Face Name, Width, Height, X and Y coordinates of the face's center point, X/Y coordinates of the left/right eye, X/Y coordinates of the left/right corner of the mouth, and X/Y coordinates of the nose.

The example program below shows how to get the facial feature data of the face closest to the center of the camera frame. This data can also be obtained for unlearned faces.

Interface Diagram

Output Result: As shown below, after running the program, the M10 screen displays the Face ID and the facial feature coordinate data for that face. Since this face has not been learned, the Face ID is 0.

Interface Diagram

In addition to the data mentioned above, more face data can be acquired, such as the total count of a specific face in the frame, the name of that face, and data related to the first instance of that face. (This data can also be obtained for unlearned faces).

Taking a learned face as an example, the example program is as follows:

Interface Diagram

Output Result: As shown below, after running the program, the M10 screen displays the total count of Face ID 1 in the frame, the name of that face, and the center XY coordinates of the first detected Face ID 1. (The default face name is "Face". For instructions on setting a name, see the Face Recognition function description - Set Name.)

Interface Diagram

1.3 Face Recognition Blocks Description

block Description
Used to obtain one set of Face Recognition data under the Face Recognition function of HUSKYLENS 2.
Determine if a human face is present in the current frame.
Retrieves data of the face closest to the screen cross cursor, including face ID, custom face name, center X/Y coordinates, width, height, left/right eye X/Y coordinates, left/right mouth corner X/Y coordinates, and nose X/Y coordinates.
Get the total number of faces detected on the screen, including both unregistered and registered faces.
When multiple faces are detected, retrieves data for a specified face.
Get the total number of learned faces detected on the screen.
Determine if a face with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in the order they were learned.
Gets the total number of detected faces with a specified ID on the screen.
Obtain the number of faces with the specified ID in the current frame.
When multiple faces are detected, retrieve the relevant data of a specified face.
Detect the number of faces that have been learned by HuskyLens 2, regardless of whether they appear in the current frame.

Was this article helpful?

TOP