Back to Adaptive Vision Library website

You are here: Start » Function Reference » Optical Character Recognition Deprecated » TrainOcr_MLP_Deprecated

TrainOcr_MLP_Deprecated


Trains an OCR multilayer perceptron classifier.

Syntax

C++
C#
 
void avl::TrainOcr_MLP_Deprecated
(
	const avl::OcrMlpModel& inOcrModel,
	const atl::Array<avl::CharacterSample>& inCharacterSamples,
	float inLearningRate,
	float inMomentum,
	int inIterationCount,
	atl::Optional<const avl::Size&> inCharacterSize,
	avl::OcrMlpModel& outOcrModel,
	avl::Profile& diagError,
	float& diagTrainingAccuracy,
	atl::Array<avl::Image>& diagNormalizedCharacters
)

Parameters

Name Type Range Default Description
inOcrModel const OcrMlpModel& Initialized OcrMlpModel to train
inCharacterSamples const Array<CharacterSample>& Training font created from sample regions
inLearningRate float 0.01 - 1.0 0.6f Suppression level of changes during learning process
inMomentum float 0.0 - 1.0 0.75f Value of classifier learning momentum
inIterationCount int 1 - + 100 Learning iteration count
inCharacterSize Optional<const Size&> NIL Size of fixed width font
outOcrModel OcrMlpModel& Trained OcrMlpModel used to recognize characters
diagError Profile& Changes of mean error level progress during learning process
diagTrainingAccuracy float& The overall training score
diagNormalizedCharacters Array<Image>& Images of normalized characters used to train classifier

Description

The operation trains a MLP classifier using character samples provided in the inCharacterSamples parameter.

Character training requires initialized OcrMlpModel provided in the inOcrModel. Model should be initialized by the InitOcr_MLP_Deprecated filter.

Classifier training requires at least single character to learn provided in the inCharacterSamples input. To obtain more information about creating character samples please refer to the documentation of the MakeCharacterSamples.

At the beginning it should be determined which kind of font typeface will be recognized.

There are two types of font typefaces:

  • Monospaced - the font has defined constant width and height which is the same for all characters. Space between two characters is always the same.
  • Proportional - size of each character may be different. Character height is limited only to line height. The distance between characters may depend on which characters are in the neighborhood.

The example below shows basic differences between monospaced and proportional fonts:

ABCabc123
Monospaced typeface - all characters have the same width.
ABCabc123
Proportional typeface - for example the character 'A' is much wider the character '1'.

Character training parameters:

  1. Learning factor (inLearningRate) - this parameter indicates how fast classifier should learn a new character. Setting value of this factor to too high will speed up learning of network but the results of learning can be far from an acceptable value. On the other hand setting this parameter too low can make learning process very slow. Default value is set to 0,6.
  2. Momentum (inMomentum) - this parameter indicates how learning of next iteration should depend on previous iteration. Too high value of the momentum parameter can make learning process slow, because network will not learn anything new and value will be similar to first iteration. On the other hand assigning to small value for this parameter can make learning process unstable and prone to find not optimal results. Default value is set to 0,75.
  3. Iteration count (inIterationCount) - this parameter indicates how many iterations should be done during the classifier learning process.

The trained MLP classifier is stored in outOcrModel output.

Remarks

  • Using monospaced typeface option for fonts that are proportional can make a thin character too small to recognize.
  • It is good practice to make single pixel border around all characters.
  • Training the MLP classifier can take some time. So as not to waste time save OcrMlpModel to file after every training.

To read more about how to use OCR technique, refer to Machine Vision Guide: Optical Character Recognition

Errors

Error type Description
DomainError Invalid OcrMlpModel in TrainOcr_MLP.
DomainError Invalid character sample in TrainOcr_MLP.

See Also