Tag Recognition Example
HUSKYLENS 2 reads AprilTag IDs, position and size to drive robots; it’s like giving your camera barcodes that encode commands and coordinates.
1. Tag Recognition Code Example
Before You Start:
1.1 Recognizing Tags and Outputting Related Data
HUSKYLENS 2 can recognize AprilTag labels appearing in the frame. Through programming, you can obtain related data of the detected tags in the frame. The readable tag data include: data of a specified tag, such as the tag ID, tag content, tag width, tag height, and the X/Y coordinates of the tag center point, as well as the total number of detected tags.
The example program is shown below.
Upload the program and wait for the upload to complete.
Point the Camera of HUSKYLENS 2 at the tag in the frame to perform learning. For detailed instructions on how to learn tags, please refer to the Tag Recognition.
Point the Camera of HUSKYLENS 2 at the tag and observe the output results.
Running Result: As shown in the figure, the total number of detected tags can be output (regardless of whether the tag has been learned). The specified tag ID can also be output; for an unlearned tag, the ID is 0.
1.2 Obtaining Related Data of a Specified Tag in the Frame
After HUSKYLENS 2 recognizes tags, it can obtain related data of a specified tag in the frame. For example, you can determine whether a tag with a specified ID is present in the frame, obtain the number of tags with the same ID in the frame, and when multiple tags with the same ID appear, specify and retrieve the related parameters of a particular tag, including its name, content, X/Y coordinates, width, and height.
The example program is shown below:
Running Result: As shown in the figure, when there are two learned tags with ID 7 in the frame, the related data of one specified tag can be output.
1.3 Tag Reconition Blocks 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. |
|
Get total number of learned tags that have been learned by HuskyLens 2, regardless of whether they appear in the current frame. |
|
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?
