Barcode Recognition Example

HuskyLens 2 barcode blocks let Mind+ read, count and filter barcodes by ID, content and position; it’s like giving your robot eyes to sort printed codes and trigger different actions in UNIHIKER projects.

1.Barcode Recognition Blocks

Before You Start:

1.1 Barcode Recognition And Output Relevant Data

HUSKYLENS 2 can recognize barcodes appearing in the frame. You can get data about detected barcodes through programming. Readable barcode data includes: the total number of detected barcodes, and data for a specific barcode, including its ID, Content, Width, Height, and X/Y coordinates of the center point.

Example Program:

Interface Diagram

Click to upload the program to the device in Mind+, and wait for the upload to complete.
Point the HuskyLens 2 camera at the barcode in the frame to learn it. For detailed instructions on how to learn barcodes, refer to: Barcode Recognition.
Point the HUSKYLENS 2 camera at the barcode and observe the results displayed on the UNIHIKER K10 screen.

Output Result: As shown, it can output the number of detected barcodes (whether learned or not) and the specified barcode ID. Unlearned barcodes have an ID of 0.

Interface Diagram

1.2 Get Data for a Specific Barcode

After HuskyLens 2 recognizes barcodes, it can acquire data for a specific barcode in the frame. For example, it can determine if a barcode with a specific ID is in the frame, get the count of barcodes with the same ID, and when multiple barcodes with the same ID appear, it can be set to acquire parameters for a specific one, including Name, Content, X/Y coordinates, Width, and Height.

Example Program:

Interface Diagram

Output Result: As shown, there are two unlearned barcodes (ID 0) in the frame. The first ID 0 barcode is the bottom one, and its content is 'dfrobot'. The second ID 0 barcode is the top one, and its coordinates are (151, 224).

Interface Diagram

1.3 Barcode Blocks 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.
Get the total number of barcodes that have been learned by HuskyLens 2, regardless of whether they appear in the current frame.
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