Barcode Recognition Example

HUSKYLENS 2 barcode blocks detect, count and output ID, content and position data, like a smart camera reading labels on packages. It recognizes the barcode nearest the crosshair, distinguishes learned IDs from ID 0 unlearned codes, counts all barcodes in view and lets users query specific IDs via Mind+ serial output.

1.Barcode Recognition Blocks

Before You Start:

1.1 Recognize Barcodes and Output Data

Under the Barcode Recognition function, HUSKYLENS 2 can recognize barcodes in the image. The program can retrieve data of the barcode closest to the crosshair and output via serial. The readable data includes: barcode ID, barcode content, barcode width, barcode height, and X/Y coordinates of the barcode center.

The sample program is as follows.

Interface Diagram

Click Upload in Mind+ and wait for completion. Then enter Barcode Recognition via the touchscreen.

Interface Diagram

When a barcode is detected, HUSKYLENS 2 highlights it with a bounding box and displays the decoded content. Open the serial in Mind+ to observe related data of the barcode closest to the crosshair.

Result:Unlearned barcodes default to ID = 0, and the content matches the screen display.

Interface Diagram

Result: For learned barcodes, the ID and content match the screen display.

Interface Diagram

1.2 Count Total Barcodes and Output Data of a Specified Barcode

When multiple barcodes appear, the program can count the total number and retrieve data of a barcode with a specified ID (ID=0 for unlearned; learned IDs assigned in learning order).

Interface Diagram

Result:All detected barcodes appear in the serial output (both learned and unlearned), including total count and data for barcode ID = 1.

Interface Diagram

1.3 Barcode Recognition Block Description

block description
Retrieve barcode recognition data once.
Determine whether any barcode is detected.
Get data of the barcode closest to the crosshair: ID, name, center X/Y coordinates, width, height, decoded content.
Get the total number of detected barcodes, including learned and unlearned.
Get data of a specified barcode when multiple are detected.
Determine whether a barcode with a specified ID exists. (ID=0 for unlearned)
Get the number of barcodes with the specified ID.
Get related data of barcodes with the specified ID.
When multiple barcodes share the same ID, get related data for one of them.

Was this article helpful?

TOP