You are here: Start » AVL.NET » Function Reference » Computer Vision » Optical Character Recognition » AVL.TrainOcr_MLP

AVL.TrainOcr_MLP

Trains an OCR multilayer perceptron classifier.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void TrainOcr_MLP
(
	IList<AvlNet.CharacterSample> inCharacterSamples,
	AvlNet.Size inNormalizationSize,
	NullableRef<IList<int>> inHiddenLayerSizes,
	int? inRandomSeed,
	AvlNet.CharacterFeatures inCharacterFeatures,
	float inLearningRate,
	float inMomentum,
	int inIterationCount,
	AvlNet.Size? inCharacterSize,
	AvlNet.OcrModel outOcrModel,
	out float outTrainingAccuracy,
	AvlNet.Profile diagError,
	IList<AvlNet.Image> diagNormalizedCharacters
)

Parameters

Name Type Range Default Description
inCharacterSamplesSystem.Collections.Generic.IList<AvlNet.CharacterSample>Training font created from sample regions.
inNormalizationSizeAvlNet.Size(Width: 16, Height: 16)The character size after normalization. Default value: (Width: 16, Height: 16).
inHiddenLayerSizesAvlNet.NullableRef<System.Collections.Generic.IList<int>>Internal structure of neuron layers used in classifier. Default value: atl::NIL.
inRandomSeedint?<0, +INF>Random seed used by MLP classifier. Default value: atl::NIL.
inCharacterFeaturesAvlNet.CharacterFeatures(Pixels: True)Character features used to distinguish characters from each other. Default value: (Pixels: True).
inLearningRatefloat<0.01f, 1.0f>0.6fSuppression level of changes during learning process. Default value: 0.6f.
inMomentumfloat<0.0f, 1.0f>0.75fValue of classifier learning momentum. Default value: 0.75f.
inIterationCountint<1, +INF>100Learning iteration count. Default value: 100.
inCharacterSizeAvlNet.Size?Size of fixed width font. Default value: atl::NIL.
outOcrModelAvlNet.OcrModelTrained OcrMlpModel used to recognize characters.
outTrainingAccuracyfloatThe overall training score.
diagErrorAvlNet.ProfileChanges of mean error level progress during learning process.
diagNormalizedCharactersSystem.Collections.Generic.IList<AvlNet.Image>Images of normalized characters used to train classifier.

Description

This filter prepares a MLP classifier for the further OCR operations.

Filter requires a set of prepared CharacterSample which can be created using MakeCharacterSamples.

Parameter inCharacterSize defines the size of character cropping box. It is especially useful when characters are much bigger than normalization size. When it has Nil value the character is cropped to its bounding box.

Parameters inHiddenLayerSizes, inRandomSeed are used in the process of learning of a newly created MLP classifier. For further parameter description please refer to the documentation of the MLP_Init filter.

All the input regions in filters RecognizeCharacters and TrainOcr_MLP are resized to the size specified in the inNormalizationSize input parameter. The further classification is performed on the normalized regions. Therefore, it is important to select the appropriate normalization size.

The selection of too small normalization size may result in loss of character details. However, too large value of normalization size increases the classifier learning time. The best recognition results are obtained when the size of character is nearly the same as the normalization size.

The character classification depends on character features that are selected in the inCharacterFeatures parameter. At least one feature must be selected. By the default the feature Pixels is selected.

The table below contains the description of each available character feature:

Feature name Description Filter origin Normalized
Pixels Values of the image pixels after normalization. False
NormalizedPixels Values of the image pixels after normalization normalized to range <0, 1.0>. True
Convexity Ratio of the input region area to area of its convex hull. RegionConvexity True
Circularity Ratio of the region area to area of its bounding circle. RegionCircularity True
NumberOfHoles Number of holes found in the input region. RegionHoles True
AspectRatio Ratio of input region width to its height. RegionBoundingBox False
Width Region bounding box width. RegionBoundingBox False
Height Region bounding box height. RegionBoundingBox False
AreaRatio Ratio of the input region area to area of its bounding box. True
DiameterRatio Ratio of the input region diameter to diameter of its bounding box. RegionDiameter True
Elongation Ratio of longer axis of the approximating ellipse to the shorter one. RegionElongation False
Orientation Further details in the filter RegionOrientation documentation. RegionOrientation True
Zoning4x4 Normalized pixel values of region reduced to size 4x4 pixel. True
HorizontalProjection Values of normalized image projection normalized by region height. ImageProjection True
VerticalProjection Values of normalized image projection normalized by region height. ImageProjection True
HoughCircles Count of circles found in the normalized image. True
Moment_11 Character geometric moment type M11. RegionMoment False
Moment_20 Character geometric moment type M20. RegionMoment False
Moment_02 Character geometric moment type M02. RegionMoment False

Remarks

It is recommended not to set normalization size greater than 50 pixels in each dimension. That could make learning time too long.

For more remarks about using MLP classifier please refer to the documentation of the MLP_Init filter.

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

Errors

List of possible exceptions:

Error type Description
DomainError At least a single feature must be selected in inCharacterFeatures in TrainOcr_MLP.
DomainError Hidden layer should have at least a single hidden layer in TrainOcr_MLP.
DomainError Invalid character sample in TrainOcr_MLP.
DomainError Invalid normalization size in InitOcr_MLP.

Function Overrides

See also