Tag Recognition Example

Tag recognition on HuskyLens 2 detects AprilTag IDs, content and position and streams them via micro:bit, it’s like giving the camera labeled markers it can count, sort and track in real time

1. Tag Recognition Project Example

Before You Start:

1.1 Tag Recognition and Output Relevant Data

When tag recognition is enabled, AprilTag tags appearing on the HuskyLens 2 screen will be detected and decoded, allowing you to access key data: total detected tags, total trained tags, center-closest tag, nth detected tag, and specified ID tag. This data includes the tag's ID,name, content, 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 AprilTag to observe the output.

As shown, when HuskyLens 2 detects two tags such as "6" and "2", the following data will display:

How to learn tags, please refer to the Tag Recognition.

Result: The serial port will output: total detected tags, ID of the center-closest tag, ID of the first detected tag.

Interface Diagram

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

Interface Diagram

1.2 Obtaining Tag Recognition Feature Data

The system can capture detailed tag recognition data for any detected AprilTag. Key readable information includes: tag ID, name,content, width, height, center coordinates (X/Y).

For instance, the sample program below retrieves tag feature data positioned near the camera's center; this functionality works even for tags not previously learned.

Interface Diagram

Operation 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 AprilTag, and the serial port will display the tag ID along with its decoded content, positional and dimension.

Interface Diagram

1.3 Obtaining Data of a Specific Tag

When multiple tags with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth tag in the detected sequence.

Example program:

Interface Diagram

Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two tags labeled ID0. After activation, the serial port will output data statistics for these two tags, including their individual positions, dimensions, and decoded content.

Interface Diagram

1.4 Tag Recognition Blocks Description

block Description
Used to obtain one set of Tag Recognition data under the Tag Recognition function of HUSKYLENS 2.
Determine if a tag is present in the current frame.
Retrieves data of the tag closest to the screen cross cursor, including tag ID, decoded content, center X/Y coordinates, width, and height.
Get the total number of tags detected on the screen, including both unregistered and registered tags.
When multiple tags are detected, retrieves data for a specified tag.
Get the total number of learned tags, regardless of whether they appear in the current frame.
Determine if a tag with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected tags with a specified ID on the screen.
When multiple tags are detected, retrieve the relevant data of a specified tag.
When multiple tags are detected with the same ID, retrieve the relevant data of a specified tag.

Was this article helpful?

TOP