This interface represents a font database for character recognition. More...
Public Member Functions | |
void | AddOCRChar (ILOCRChar *charData, LString charString) |
void | AddOCRLine (ILOCRLine *lineData, LString lineString) |
void | AddOCRResult (ILOCRResult *resultData, LString resultString) |
int | CountChar () |
ILSampleDatabase * | CreateChar (LString charString) |
ILSampleDatabase * | GetCharDatabase (LString charString) |
void | Init (LString fontName, LString workingDirectory) |
BOOL | IsInMemory () |
Whether this is an in-memory database, whose sample files and all informations are never saved. | |
BOOL | IsTrained () |
LString | ItemChar (int index) |
void | RemoveChar (LString charString) |
LPVErrorCode | Train () |
Public Member Functions inherited from ILObject | |
ILObject * | Copy () |
LPVErrorCode | Load (LString filename) |
void | Reset () |
LPVErrorCode | Save (LString filename) |
BOOL | Valid () |
Properties | |
BOOL | AutoFeature [get, set] |
Whether to enable automatic feature selection and tuning. By default, it's off. | |
BOOL | AutoModel [get, set] |
Whether to enable automatic model selection and tuning. By default, it's off. | |
LPVOCRFeatures | Features [get, set] |
The features used for recognition. By default, it's LPVOCRFeatureDefault. More... | |
LPVModelType | ModelType [get, set] |
The machine learning model type used for recognition. | |
LString | Name [get] |
The name of the sample database, which is usually unique and as an identification for the database globally. | |
LSize | PixelGrid [get, set] |
The grid size for LPVOCRFeaturePixel feature. By default, it's a @math_eq{6 \times 8} grid. | |
LPVOCRPixelProjection | PixelProjection [get, set] |
The grid projection used for LPVOCRFeaturePixel feature. By default, it's LPVOCRPixelProjNone indicating no projection. | |
LPVOCRPixelValue | PixelValue [get, set] |
The pixel value's calculation method used for LPVOCRFeaturePixel feature. By default, it's LPVOCRPixelGrayscaleNormalized indicating normalized grayscale value. | |
LString | WorkingDir [get] |
The working directory of the font database. For the persisted database, it is used to store the sample files and management information file. For the in-memory database, it is the fix "in-memory" text. | |
This interface represents a font database for character recognition.
The font database is used to manage the character samples, and train the machine-learning based classification model for recognition. It provides various image-based or geometric features designed for OCR task. It also support advanced automatic feature selection and model tuning, if there are sufficient character samples. It could be serialized to disk and shared by multiple OCR tools.
To use this interface, you should create a LFontDatabase object.
Add the single character object to the font database as training sample.
[in] | charData | The single character object. |
[in] | charString | The recognition string. Pass in empty to use the recognition result inside charString as training characters. |
Add all the characters in the line of text object to the font database as training samples.
[in] | lineData | The line of text object. It should contain at least one character. |
[in] | lineString | The recognition string. It should match the count of the characters in lineData. Pass in empty to use the recognition result inside lineData as training characters. |
void AddOCRResult | ( | ILOCRResult * | resultData, |
LString | resultString | ||
) |
Add all the characters in the OCR result object to the font database as training samples.
[in] | resultData | The OCR result object. It should contain at least one line or one character. |
[in] | resultString | The recognition string. It should match the count of the characters in resultData. Pass in empty to use the recognition result inside resultData as training characters. |
int CountChar | ( | ) |
Get the total count of all the characters.
val | The total count. |
ILSampleDatabase* CreateChar | ( | LString | charString | ) |
Create a new character in the font database. It will also create a sample database under the font database for the new character at the same time.
[in] | charString | The character code. |
charDB | Return the sample database for the new character |
ILSampleDatabase* GetCharDatabase | ( | LString | charString | ) |
Get the corresponding database by the given character code.
[in] | charString | The character code |
charDB | Return the sample database for the character |
Create and initialized the font database.
[in] | fontName | The name of the font database. |
[in] | workingDirectory | The working directory. To create an in-memory database, pass in an empty path. For other cases, we'll create a persisted database and initialize the working directory with an empty database. So you should provide a readable and writable path. If there's an existing database in the given directory, we'll try to load it in the first place, and the label name may be refreshed with the loaded one. |
BOOL IsTrained | ( | ) |
Check whether the font database is well-trained
val | Return True if it's trained, otherwise, return False. |
LString ItemChar | ( | int | index | ) |
Fetch one character with given index.
[in] | index | The input index, it should be a 0-based number smaller than total count. |
result | Return the character code of given index. |
void RemoveChar | ( | LString | charString | ) |
Remove the character from the font database. Please noted the corresponding database is not permanently removed, you may delete it manually.
[in] | charString | The character code to remove. |
LPVErrorCode Train | ( | ) |
Train the font database. If automatic feature or model selection is turned on, it's performed during the training.
error | Return error code if anything is wrong. |
|
getset |
The features used for recognition. By default, it's LPVOCRFeatureDefault.
/*!