You are here: Start » Tutorial Exercises » Reading Numbers from Images
Reading Numbers from Images
Aim:
Create an algorithm that reads values from an LCD display.
Input:
The set of images with an LCD display.
Images are stored in the ocr_read directory.
Output:
Values read from the LCD display.
Hints:
This example shows how to extract text from an image and create an OCR model.
To perform most 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 have a specialized GUI editor that is a convenient way to perform the text reading.
While training the OCR model, please gather or create 4 samples per character.
Create missing digits samples from '8'.
Labeling connections is explained in this article.
Solution (FIS):
-
Add the EnumerateImages filter to obtain input images.
-
Add the ExtractText filter and connect to it images from the source to it.
2.1. Set inRoi to cover 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.
-
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. The correct value is: -05.5.
3.3. Open the Details tab and, using the CTRL key, select a single sample for each character.
3.4. Open the Variation Toolbox and create variants for selected samples.
3.5. If a character has more than 4 samples remove all superfluous samples.
3.6. Iterate the application again and open the OCR Model Training editor again.
3.7. Right-click on the character that 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.
-
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 the marked region part in the image below.
4.6. Create variations for the modified sample.
4.7. In the same way, create a sample for digit 7.
Macrofilter Main uses high-level filters to perform text reading.
Further Readings
- Optical Character Recognition - Detailed article explaining Optical Character Recognition technique.