You are here: Start » Program Examples » OCR Read Number (MLP)

OCR Read Number (MLP)

Aim

The aim of the program is to recognize characters in an image.

Input

Several images of numbers.

Output

Detected numbers in the image and recognized characters.

Hints

To identify the characters in the image it is recommended to use Optical Character Recognition technique to recognize different characters with Blob Analysis to create various character's models.

Solution (AVS)

  1. In a separate program or in a macrofilter you will have to create an OCR model first. Create new global parameter and name it FileNames of StringArray type. The values will be names of consecutive images of characters.
  2. Add LoadImage filter and connect FileNames with inFile.
  3. Add ThresholdToRegion_Dynamic filter and connect outImage with inImage.
  4. Click on ThresholdToRegion_Dynamic filter and make these changes:
  5. Add MakeCharacterSamples filter.
  6. Add TrainOcr_MLP filter. Connect outCharacterSamples with inCharacterSamples. Click on the filter and make these changes in Properties window:
  7. Add SaveObject filter. Connect outOcrModel with inObject.
  8. Save the model as Font_MLP in inFile. Now you can close your program or macrofilter.
  9. Create the right application and add EnumerateImages filter.
  10. Add ThresholdToRegion_Dynamic filter. Connect outImage with inImage.
  11. Click on ThresholdToRegion_Dynamic filter and make these changes in Properties window (in the lower left corner):
  12. Add SplitRegionIntoMultipleCharacters filter. Connect outRegion with inRegion.
  13. Click on SplitRegionIntoMultipleCharacters filter. Set inCharacterWidth to 24.
  14. Add RecognizeCharacters filter.

Macrofilter Main

Macrofilter TrainCharacters

Used Filters

Icon Name Description
TrainOcr_MLP Trains an OCR multilayer perceptron classifier.
EnumerateImages Emulates image acquisition with images stored on disk.
ThresholdToRegion_Dynamic Useful in case of uneven illumination.
SplitRegionIntoMultipleCharacters Text segmentation when the number of characters is unknown, usually followed by a RecognizeCharacters filter.
MakeCharacterSamples Creates training font samples from the provided regions.
RecognizeCharacters Usually the last, yet the most important step of optical character recognition or verification.
LoadImage Loads a single image from a file.
SaveObject Saves an object to a file.

Further Readings