You are here: Start » AVL.NET » AVL.TrainOcr_SVM(AvlNet.CharacterSample[], AvlNet.Size, float?, float?, float, float, bool, AvlNet.Size?, int?, AvlNet.CharacterFeatures, AvlNet.OcrModel, float, AvlNet.Image[])

AVL.TrainOcr_SVM(AvlNet.CharacterSample[], AvlNet.Size, float?, float?, float, float, bool, AvlNet.Size?, int?, AvlNet.CharacterFeatures, AvlNet.OcrModel, float, AvlNet.Image[])

Trains an OCR support vector machines classifier.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax


public static void TrainOcr_SVM(
	AvlNet.CharacterSample[] inCharacterSamples,
	AvlNet.Size inNormalizationSize,
	float? inNu,
	float? inKernelGamma,
	float inRegularizationConstant,
	float inStopEpsilon,
	bool inUseShrinkingHeuristics,
	AvlNet.Size? inCharacterSize,
	int? inRandomSeed,
	AvlNet.CharacterFeatures inCharacterFeatures,
	out AvlNet.OcrModel outOcrModel,
	out float outTrainingAccuracy,
	out AvlNet.Image[] diagNormalizedCharacters
)

Parameters

inCharacterSamples
Type: AvlNet.CharacterSample
Training font created from sample regions
inNormalizationSize
Type: AvlNet.Size
The character size after normalization
inNu
Type: System.Nullable<System.Single>
Trade-off between training accuracy and number of supported vectors, or null.
inKernelGamma
Type: System.Nullable<System.Single>
Gamma parameter for RBF kernel, or null.
inRegularizationConstant
Type: System.Single
Preventing overfitting
inStopEpsilon
Type: System.Single
Epsilon for stopping criterion
inUseShrinkingHeuristics
Type: System.Boolean
Heuristics may speed up computations
inCharacterSize
Type: System.Nullable<AvlNet.Size>
Size of fixed width font, or null.
inRandomSeed
Type: System.Nullable<System.Int32>
Random seed used to train classifier, or null.
inCharacterFeatures
Type: AvlNet.CharacterFeatures
Character features used to identify characters
outOcrModel
Type: AvlNet.OcrModel
Trained OcrSvmModel used to recognize characters
outTrainingAccuracy
Type: System.Single
The overall training score
diagNormalizedCharacters
Type: AvlNet.Image
Images of normalized characters used to train classifier

Description

This filter prepares a SVM 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.

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

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

Errors

Error type Description
DomainError At least a single feature must be selected in inCharacterFeatures in TrainOcr_SVM.
DomainError Invalid OcrSvmModel in TrainOcr_SVM.
DomainError Invalid character sample in TrainOcr_SVM.

See also