Optical Character Recognition Example

Optical character recognition on HuskyLens 2 detects on‑screen text blocks and streams their ID, content and position data via micro:bit, like giving each word a GPS tag. It lets users count blocks, check if specific IDs or license plates appear, and read size and coordinates of the closest or selected target for kid‑friendly AI vision projects.

1. Optical Char Recognition Project Example

Before You Start:

1.1 Optical Char Recognition and Output Relevant Data

When optical character recognition is enabled, text blocks appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected text blocks, recognized text content, center-closest text block, and specified ID text block. This data includes the text block's ID, name, text content, center coordinates (XY), width, and height.

Example program:

Interface Diagram

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 text content to observe the output.

As shown, when HuskyLens 2 detects text blocks such as "happy", the following data will display:

How to use optical character recognition, please refer to the Optical Character Recognition.

Result: The serial port will output: ID,content, coordinates and size of the center-closest text block.

Interface Diagram

1.2 Optical Char Recognition Blocks Description

block Description
Used to obtain one set of Optical Char Recognition data under the Optical Char Recognition function of HUSKYLENS 2.
DDetermine if a text block is present in the current frame.
Retrieves data of the text block closest to the screen cross cursor, including text ID, name, recognized text content, center X/Y coordinates, width, and height.
Get the total number of text blocks detected on the screen.
Determine if a text block with the specified ID exists in the frame.
Get the total number of learned license plates, regardless of whether they appear in the current frame.
Determine if a license plate 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 license plates with a specified ID on the screen.
When multiple license plates are detected, retrieve the relevant data of a specified license plate.
When multiple license plates with the same ID are detected, retrieve the relevant data of a specified license plate.

Was this article helpful?

TOP