Tag Recognition Example
HUSKYLENS 2 tag mode reads AprilTag IDs, content and position, then streams data via serial. It’s like a smart barcode scanner that also counts how many tags are in view, distinguishes learned (ID>0) and unlearned (ID 0) tags, and lets Mind+ blocks check, count and query tags by ID or by the one nearest the crosshair.
1.Tag Recognition Blocks
Before You Start:
1.1 Recognize Tags and Output Related Data
Under the Tag Recognition function, HUSKYLENS 2 can recognize AprilTag labels in the image. The program can acquire data of the tag closest to the crosshair and output it through the serial. The readable data includes: tag ID, tag content, tag width, tag height, and X/Y coordinates of the tag center.
The sample program is as follows.
Click Upload in Mind+ and wait for completion. Use touchscreen to enter Tag Recognition.
When a tag is detected, HUSKYLENS 2 will highlight it with a bounding box and show the decoded content. Open the serial in Mind+ and observe the related data.
Result:For unlearned tags, the ID defaults to 0 and matches the screen display.
Result:For learned tags, the ID and content match the screen display.
Note: If a complete tag appears but is not recognized, check whether the tag size matches the Dict parameter.
For detailed usage instructions, see:Tag Recognition.
1.2 Count Total Tags and Output Data of a Specified Tag
When multiple tags appear, the following program counts them and retrieves data for a specified ID.
The sample program is as follows.
Result:When multiple tags appear on the screen, HUSKYLENS 2 can recognize all tags (both unlearned and learned). The total number of tags on the screen can be observed and counted through the serial port. At the same time, the serial port prints the relevant data of the tag with the specified ID 1.
1.3 Count Specific Tags ID and Output Data
When multiple tags have the same ID, count them and get data from one of them.
The sample program is as follows.
Result:When multiple identical tags appear on the screen, HUSKYLENS 2 can identify all tags with ID 1 (assuming a tag has been learned and assigned ID 1, and unlearned tags are assigned ID 0). The total number of ID1 tags on the screen can be observed through the serial port. At the same time, the serial port outputs the relevant data of the first tag with ID 1.
1.4 Tag Recognition Block Description
| block | description |
|---|---|
|
Acquire tag recognition data once. |
|
Determine if any tag is detected. |
|
Get data of tag closest to crosshair: ID, center X/Y coordinates, width, height, decoded content. |
|
Get total number of detected tags,including both unlearned and learned labels. |
|
Get data of a specified tag. |
|
Determine whether a tag with the specified ID exists.The IDs of unlearned tags are all set to 0, and the IDs of learned tags are sorted in the order in which they were learned. |
|
Get the number of tags with a specified ID. |
|
Get data of a specified ID tag. |
|
Get data of a specified one when multiple tags share the same ID. |
Was this article helpful?
