Object Recognition Example

Object recognition on HuskyLens 2 lets micro:bit read IDs, names, positions and counts for any detected or learned object, like a smart camera ruler. It’s like giving your robot eyes that also report coordinates and statistics.

1.Object Recognition Project Example

Before You Start:

1.1 Recognize Objects and Output Related Data

When object recognition is enabled, objects appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected objects, total trained objects, center-closest object, nth detected object, and specified ID object. This data includes the object's ID, name, center coordinates (XY), width, and height.

Example program:

Interface Diagram

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 an object to observe the output.
As shown, when HuskyLens 2 detects two objects named "cell phone" and "cup", the following data will display:
How to learn objects, please refer to the Object Recognition.

Result: The serial port will output: total detected objects, ID of the center-closest object, name of the first detected object, and total the learned objects.

Interface Diagram

There are 2 detected objects, so the dot matrix display shows "2".

Interface Diagram

1.2 Obtaining Object Feature Data

The system can capture object feature and positional data for any detected object. Key readable information includes: object ID, name, width, height, and center coordinates (X/Y).
For instance, the sample program below retrieves object feature data of objects positioned near the camera's center; this functionality works even for objects not previously learned.

Interface Diagram

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 an object, and the serial port will display the object ID along with its positional data.

Interface Diagram

1.3 Obtaining Data of a Specific Object

When multiple objects with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth object in the detected sequence.
Example program:

Interface Diagram

Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two objects labeled ID 1. After activation, the serial port will output data statistics for these two objects.

Interface Diagram

1.4 Object Recognition Blocks Description

block Description
Used to obtain one set of Object Recognition data under the Object Recognition function of HUSKYLENS 2.
Determine if an object is present in the current frame.
Retrieves data of the object closest to the screen cross cursor, including object ID, custom object name, center X/Y coordinates, width, and height.
Get the total number of objects detected on the screen, including both unregistered and registered objects.
When multiple objects are detected, retrieves data for a specified object.
Get the total number of learned objects, regardless of whether they appear in the current frame.
Determine if an object 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 objects with a specified ID on the screen.
When multiple faces appear, obtain the relevant data of a specified face.
When multiple faces with the same ID appear, obtain the relevant data of a specified face.

Was this article helpful?

TOP