QR Code Recognition Example

HuskyLens 2 QR blocks detect, count and read QR tags; it’s like giving your camera a spreadsheet that logs each code’s ID, content, position and size in real time

1. QR Code Recognition Blocks

Before You Start:

1.1 Recognizing QR Codes and Outputting Related Data

HUSKYLENS 2 can recognize QR codes appearing in the frame. Through programming, you can obtain related data of the detected QR codes in the frame. The readable QR code data include: the total number of detected QR codes, and data of a specified QR code, including its ID, content, width, height, and the X/Y coordinates of the QR code center point.

The example program is shown below.

Interface Diagram

Upload the program and wait for the upload to complete.

Point the Camera of HUSKYLENS 2 at the QR code in the frame to perform learning. For detailed instructions on how to learn QR codes, please refer to the QR Code Recognition

Point the Camera of HUSKYLENS 2 at the QR code and observe the output results.

Running Result: As shown in the figure, the total number of detected QR codes can be output (regardless of whether the QR code has been learned). The specified QR code ID can also be output; for an unlearned QR code, the ID is 0.

Interface Diagram

1.2 Obtaining Related Data of a Specified QR Code in the Frame

After HUSKYLENS 2 recognizes QR codes, it can obtain related data of a specified QR code in the frame. For example, you can determine whether a QR code with a specified ID is present in the frame, obtain the number of QR codes with the same ID in the frame, and when multiple QR codes with the same ID appear, specify and retrieve the related parameters of a particular QR code, including its name, content, X/Y coordinates, width, and height.

The example program is shown below.

Interface Diagram

As shown in the figure, the QR code previously learned by Liang Ge has the content "2025", and the center point coordinates of the first detected QR code are (171, 218).

Interface Diagram

1.3 QR Reconition Blocks Description

block Description
Acquire QR code recognition data once.
Determine if any tag is detected.
Get data of the closest QR code: ID, name, center X/Y coordinates, width, height, decoded content.
Get total number of detected QR codes, including unlearned and learned QR codes.
Get the number of QR codes that have been learned by HuskyLens 2, regardless of whether they appear in the current frame.
Get data of a specified QR code.
Determine whether a specified ID exists.
Get number of QR codes with a specified ID.
Get data of QR codes with a specified ID.
Get data of one specified QR code when multiple shares the same ID.

Was this article helpful?

TOP