Back to Adaptive Vision Library website

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

TrainOcr_SVM_Deprecated


Trains an OCR support vector machines classifier.

Syntax

C++
C#
 
void avl::TrainOcr_SVM_Deprecated
(
	const avl::OcrSvmModel& inOcrModel,
	const atl::Array<avl::CharacterSample>& inCharacterSamples,
	atl::Optional<const avl::Size&> inCharacterSize,
	avl::OcrSvmModel& outOcrModel,
	float& diagTrainingAccuracy,
	atl::Array<avl::Image>& diagNormalizedCharacters
)

Parameters

Name Type Default Description
inOcrModel const OcrSvmModel& Initialized OcrSvmModel to train
inCharacterSamples const Array<CharacterSample>& Training font created from sample regions
inCharacterSize Optional<const Size&> NIL Size of fixed width font
outOcrModel OcrSvmModel& Trained OcrSvmModel used to recognize characters
diagTrainingAccuracy float& The overall training score
diagNormalizedCharacters Array<Image>& Images of normalized characters used to train classifier

Description

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

Character training requires initialized OcrSvmModel provided in the inOcrModel. Model should be initialized by the InitOcr_SVM_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'.

The trained SVM 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.

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

Errors

Error type Description
DomainError Invalid OcrSvmModel in TrainOcr_SVM.
DomainError Invalid character sample in TrainOcr_SVM.

See Also