Face Recognition Example
HUSKYLENS 2 face recognition lets you count, track and identify faces with IDs, names and precise coordinates, like a smart people counter for STEM projects. It's like a digital seating chart that knows who sits where, logging total faces, learned faces and per‑ID details in real time.
1. Face Recognition Project Example
Before You Start:
1.1 Detecting Faces and Outputting Related Data
Under the Face Recognition function, when a face appears on the HUSKYLENS 2 screen, it can be detected and framed. This allows you to obtain data such as the total number of detected faces, the number of learned faces, data of the face closest to the center, data of the n-th face, and data of a face with a specified ID. These data include the face ID, name, center point X/Y coordinates, as well as the width and height of the face.
The example program is shown below.
Align the HUSKYLENS 2 Camera with the face in the scene to perform face learning. For detailed instructions on how to learn faces, please refer to: Face Recognition.
Upload the program. When one learned face and one unlearned face appear in the scene, the result is shown as follows.
Running Result: As shown below, the serial port outputs the total number of detected faces, the ID of the face closest to the center of the frame, the name of the first detected face, and the total number of learned faces.
There are two faces in the current scene, so the LED matrix displays 2.
1.2 Obtaining Facial Data of a Specified Face
When multiple instances of the same face appear in the frame at the same time, the program can be used to count the number of faces with a specified ID and to obtain the related data of the n-th face with that specified ID.
The example program is shown below.
Running Result: As shown in the figure below, when the program is running and two faces with ID 1 appear in the frame at the same time, the serial port outputs the specified information.
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?
