QR Code Recognition Example

HUSKYLENS 2 QR blocks let Mind+ read QR IDs, text and position, like giving Arduino a visual barcode scanner. It’s like a smart camera that locks onto the nearest code, counts all visible codes, filters by specific ID, and streams each tag’s decoded content and coordinates via serial.

1.QR Code Recognition Blocks

Before You Start:

1.1 Recognize QR Codes and Output Related Data

Under QR Code Recognition, HUSKYLENS 2 can recognize QR codes. The program retrieves data of the QR code closest to the crosshair and prints via serial ID, name, decoded content, width, height, center X/Y coordinates.

The sample program is as follows.

Interface Diagram

Click Upload in Mind+ and enter QR Code Recognition by touchscreen.

Interface Diagram

After the QR code is recognized, the HukyLens 2 screen will frame the QR code and display the parsed QR code content in the upper left corner of the frame. Open the Mind+ serial port and observe the serial port output the relevant data of the QR code closest to the crosshairs.

Result:ID=0 for unlearned; decoded content matches display.

Interface Diagram

Result:Learned QR code ID matches display.

Interface Diagram

1.2 Output Data of a Specified QR Code

When multiple QR codes appear, count them and output data for a specified ID.

Interface Diagram

Result:When multiple QR codes appear on the screen, HUSKYLENS 2 can recognize all QR codes (both unlearned and learned), and the total number of QR codes on the current screen can be observed and counted through the serial port. At the same time, the serial port prints the relevant data of the QR code with the specified ID 1.

Interface Diagram

1.3 Count of a Specific ID and Output Related Data

When multiple QR codes with the same ID appear on the screen (the IDs of learned QR Codes are assigned in the order of learning, and the IDs of unlearned tags are all 0), you can use the following sample program to count the number of QR codes with the same ID on the screen and obtain the relevant data of a specified ID QR code.

Interface Diagram

Result:When multiple identical QR codes appear on the screen, HUSKYLENS 2 can recognize all QR codes with ID 1 (assuming a QR code has been learned and assigned ID 1, and unlearned QR codes are assigned ID 0). The total number of QR codes with ID 1 on the current screen can be observed and counted through the serial port. The serial port also outputs the data related to the first QR code with ID 1.

Interface Diagram

1.4 QR Code Recognition Block Description

block description
Acquire QR code recognition data once.
Determine whether a QR code 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 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