You are here: Start » Tutorial Exercises » Reading Numbers from Images (ocr_read)

Reading Numbers from Images (ocr_read)

Aim

Create an algorithm which reads values from an LCD display.

Input

The set of images with an LCD display.

Images are stored in ocr_read directory.

Output

Values read from the LCD display.

Hints

This example shows how to extract a text from an image and create an OCR model.

To perform most of the OCR applications two filters are needed. Extracting the text from the image can be done using the ExtractText filter. To get textual values from regions the ReadText filter can be used. Both of these filters has a specialized GUI editor which is a convenient way to perform the text reading.

While training OCR model please gather or create 4 samples per character.

Create missing digits samples from '8'.

Solution (AVS)

  1. Add the EnumerateImages filter to obtain input images.

  2. Add the ExtractText filter and connect to it images from the source.

    2.1. Set inRoi which covers only the LCD.

    2.2. Open the editor for inSegmentationModel port. In the opened Quick Setup dialog please select:

    * Text color: **Black**,
    * Background color: **Uniform**,
    * Font type: **Noncontinuous**.
    

    2.3. In the text extraction section correct the value of Max. Value to 30.0.

    2.4. In the text segmentation section set the Distance parameter to 10.0.

  3. Add the ReadText filter and connect it with ExtractText.

    3.1. Iterate the project and open the OCR Model Training editor.

    3.2. Enter visible text to the input box on the bottom. Correct value is: -05.5.

    3.3. Open the Details tab and using CTRL key select a single sample for each character.

    3.4. Open the Variation Toolbox and create variants for selected samples.

    3.5. If character has more than 4 samples remove all superfluous samples.

    3.6. Iterate the application once again and open the OCR Model Training editor once again.

    3.7. Using the right mouse button click on the character which is not recognized properly. Enter a valid character: 2.

    3.8. Create variations for the added character 2.

    3.9. Repeat this process until all available characters are added.

  4. Create samples for the missing digits.

    4.1. Open the "OCR Training Editor" and select the best sample of the 8 character.

    4.2. Right-click on it and select Duplicate item.

    4.3. Right-click on the newly added sample and select Rename item. Rename this item to 9.

    4.4. Double-click on the sample of character 9.

    4.5. Remove marked region part in the image below.

    4.6. Create variations for the modified sample.

    4.7. In this same way create sample for digit 7.

Macrofilter Main uses high-level filters to perform a reading from a text.

Further Readings