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

TrainOcr_SVM_Deprecated
Header: | FIL.h |
---|---|
Namespace: | fil |
Trains an OCR support vector machines classifier.
Syntax
void fil::TrainOcr_SVM_Deprecated ( const fil::OcrSvmModel& inOcrModel, const ftl::Array<fil::CharacterSample>& inCharacterSamples, ftl::Optional<const fil::Size&> inCharacterSize, fil::OcrSvmModel& outOcrModel, float& diagTrainingAccuracy, ftl::Array<fil::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
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Invalid character sample in TrainOcr_SVM. |
DomainError | Invalid OcrSvmModel in TrainOcr_SVM. |
See Also
- InitOcr_SVM_Deprecated – Creates an OCR model based on support vector machines classifier.
- MakeCharacterSamples – Creates training font samples from the provided regions.
- RecognizeCharacters_SVM_Deprecated – Classifies input regions into characters. Based on the Support Vector Machines model.