Leaper WaferScan Toolkit
中文 / English 2.x
Public Member Functions | Properties
ILFontDatabase Interface Reference

This interface represents a font database for character recognition. More...

Inheritance diagram for ILFontDatabase:
ILObject LFontDatabase

Public Member Functions

void AddOCRChar (ILOCRChar *charData, LString charString)
 
void AddOCRLine (ILOCRLine *lineData, LString lineString)
 
void AddOCRResult (ILOCRResult *resultData, LString resultString)
 
int CountChar ()
 
ILSampleDatabaseCreateChar (LString charString)
 
ILSampleDatabaseGetCharDatabase (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
ILObjectCopy ()
 
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 \( 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.
 

Detailed Description

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.

Example Code

Member Function Documentation

◆ AddOCRChar()

void AddOCRChar ( ILOCRChar charData,
LString  charString 
)

Add the single character object to the font database as training sample.

Parameters
[in]charDataThe single character object.
[in]charStringThe recognition string. Pass in empty to use the recognition result inside charString as training characters.
See also
AddOCRResult(), AddOCRLine()

◆ AddOCRLine()

void AddOCRLine ( ILOCRLine lineData,
LString  lineString 
)

Add all the characters in the line of text object to the font database as training samples.

Parameters
[in]lineDataThe line of text object. It should contain at least one character.
[in]lineStringThe 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.
See also
AddOCRResult(), AddOCRChar()

◆ AddOCRResult()

void AddOCRResult ( ILOCRResult resultData,
LString  resultString 
)

Add all the characters in the OCR result object to the font database as training samples.

Parameters
[in]resultDataThe OCR result object. It should contain at least one line or one character.
[in]resultStringThe 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.
See also
AddOCRLine(), AddOCRChar()

◆ CountChar()

int CountChar ( )

Get the total count of all the characters.

Return values
valThe total count.
See also
CreateChar(), RemoveChar(), ItemChar(), GetCharDatabase()

◆ CreateChar()

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.

Parameters
[in]charStringThe character code.
Return values
charDBReturn the sample database for the new character
See also
RemoveChar(), CountChar(), ItemChar(), GetCharDatabase()

◆ GetCharDatabase()

ILSampleDatabase* GetCharDatabase ( LString  charString)

Get the corresponding database by the given character code.

Parameters
[in]charStringThe character code
Return values
charDBReturn the sample database for the character
See also
CreateChar()

◆ Init()

void Init ( LString  fontName,
LString  workingDirectory 
)

Create and initialized the font database.

Parameters
[in]fontNameThe name of the font database.
[in]workingDirectoryThe 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.

◆ IsTrained()

BOOL IsTrained ( )

Check whether the font database is well-trained

Return values
valReturn True if it's trained, otherwise, return False.

◆ ItemChar()

LString ItemChar ( int  index)

Fetch one character with given index.

Parameters
[in]indexThe input index, it should be a 0-based number smaller than total count.
Return values
resultReturn the character code of given index.
See also
CreateChar(), RemoveChar(), CountChar(), GetCharDatabase()

◆ RemoveChar()

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.

Parameters
[in]charStringThe character code to remove.
See also
CreateChar(), CountChar(), ItemChar(), GetCharDatabase()

◆ Train()

LPVErrorCode Train ( )

Train the font database. If automatic feature or model selection is turned on, it's performed during the training.

Return values
errorReturn error code if anything is wrong.

Property Documentation

◆ Features

LPVOCRFeatures Features
getset

The features used for recognition. By default, it's LPVOCRFeatureDefault.

/*!