QR Code Recognition Example
HuskyLens 2 QR recognition streams ID, content and position data to micro:bit; it’s like giving your board eyes to count, track and filter multiple QR codes by index or ID in real time.
1. QR Code Recognition Project Example
Before You Start:
1.1 QR Recognition and Output Relevant Data
When QR code recognition is enabled, QR codes appearing on the HuskyLens 2 screen will be detected and decoded, allowing you to access key data: total detected QR codes, total trained QR codes, center-closest QR code, nth detected QR code, and specified ID QR code. This data includes the QR code's ID, name,content, center coordinates (XY), width, and height.
Example program:
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 a QR code to observe the output.
As shown, when HuskyLens 2 detects two QR codes such as "abc" and "hello", the following data will display:
How to learn QR codes, please refer to the QR Code Recognition.
Operation Result: The serial port will output: total detected QR codes, ID of the center-closest QR code, and IDt of the first detected QR code.
There are 2 detected QR codes, so the dot matrix display shows "2".
1.2 Obtaining QR Recognition Feature Data
The system can capture detailed QR code recognition data for any detected QR code. Key readable information includes: QR code ID, name,content, width, height, center coordinates (X/Y), and decoding confidence levels.
For instance, the sample program below retrieves QR code feature data positioned near the camera's center; this functionality works even for QR codes not previously learned.
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 a QR code, and the serial port will display the QR code ID along with its decoded content, positional and dimensions.
1.3 Obtaining Data of a Specific QR Code
When multiple QR codes with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth QR code in the detected sequence.
Example program:
Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two QR codes labeled ID 0. After activation, the serial port will output data statistics for these two QR codes, including their individual positions, dimensions, and decoded content.
1.4 QR Code Blocks Description
| block | Description |
|---|---|
|
Used to obtain one set of QR Code Recognition data under the QR Code Recognition function of HUSKYLENS 2. |
|
Determine if a QR code is present in the current frame. |
|
Retrieves data of the QR code closest to the screen cross cursor, including QR ID, decoded content, center X/Y coordinates, width, and height. |
|
Get the total number of QR codes detected on the screen, including both unregistered and registered QR codes. |
|
When multiple QR codes are detected, retrieves data for a specified QR code. |
|
Get the total number of learned QR codes, regardless of whether they appear in the current frame. |
|
Determine if a QR code 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 QR codes with a specified ID on the screen. |
|
When multiple QR codes are detected, retrieve the relevant data of a specified QR code. |
|
When multiple QR codes with the same ID are detected, retrieve the relevant data of a specified QR code. |
Was this article helpful?
