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

This interface provide functionalities of the machine learning based image classification. More...

Inheritance diagram for ILClassifier:
ILObject LClassifier

Public Member Functions

void AddClass (LString classLabel, ILSampleDatabase *sampleDB)
 
int AddFeature (ILFeature *feature)
 
int AddModel (ILModel *model)
 
int CountFeature ()
 
int CountModel ()
 
void CreateClass (LString classLabel, LString sampleDBDir)
 
ILSampleDatabaseGetClassSampleDb (LString classLabel)
 
ILFeatureGetFeature (int idx)
 
ILModelGetModel (int idx)
 
BOOL IsTrained ()
 
LPVErrorCode Predict (ILImage *img, ILRegion *predictRegion, LString *classLabel, double *confidence)
 
void RemoveAllClass (BOOL deleteSampleDb)
 
void RemoveAllFeatures ()
 
void RemoveAllModels ()
 
void RemoveClass (LString classLabel, BOOL deleteSampleDb)
 
void RemoveFeature (int idx)
 
void RemoveModel (int idx)
 
LPVErrorCode Train ()
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Properties

int PrimaryModelIndex [get, set]
 The index of the primary model which is used for prediction. By default, we use the first model.
 
LString WorkingDir [get, set]
 The working directory, used as the default root path for the database of the created class labels.
 

Detailed Description

This interface provide functionalities of the machine learning based image classification.

This is an integrated image classifier which may involve multiple machine learning models with various feature extraction approaches. You may train those models with one Train() call, then choose the primary one for the prediction, according to their testing performance.

We also provide the advanced functionalities for auto-tuning, auto-feature-selection and powerful testing.

To use this interface, you should create a LClassifier object.

Example Code

Member Function Documentation

◆ AddClass()

void AddClass ( LString  classLabel,
ILSampleDatabase sampleDB 
)

Add a new class and the input associated sample database.

Parameters
[in]classLabelThe label of the class. It may be a readable word and must be not duplicated.
[in]sampleDBThe associated sample database.
See also
CreateClass(), RemoveClass()

◆ AddFeature()

int AddFeature ( ILFeature feature)

Add the feature to the classifier.

Parameters
[in]featureThe input feature object.
Return values
idxReturn the index of the new added feature.
See also
GetFeature(), RemoveFeature()

◆ AddModel()

int AddModel ( ILModel model)

Add the model to the classifier.

Parameters
[in]modelThe input model object.
Return values
idxReturn the index of the new added model.
See also
GetModel(), RemoveModel()

◆ CountFeature()

int CountFeature ( )

Get the total count of all the features.

Return values
valThe total count.

◆ CountModel()

int CountModel ( )

Get the total count of all the models.

Return values
valThe total count.

◆ CreateClass()

void CreateClass ( LString  classLabel,
LString  sampleDBDir 
)

Create a new class and its sample database.

Parameters
[in]classLabelThe label of the class. It may be a readable word and must be not duplicated.
[in]sampleDBDirThe required directory for the class' sample database. It could be empty then we'll create one under the default path generated out of WorkingDir, or a path to an existing database.
See also
AddClass(), RemoveClass()

◆ GetClassSampleDb()

ILSampleDatabase* GetClassSampleDb ( LString  classLabel)

Get the sample database of the required class.

Parameters
[in]classLabelThe label of the class.
Return values
sampleDBReturn the sample database. It may be null if there's no matching label.

◆ GetFeature()

ILFeature* GetFeature ( int  idx)

Get the feature object with the given index.

Parameters
[in]idxThe input index, it should be a 0-based number smaller than total count.
Return values
featureReturn the feature object.
See also
AddFeature(), CountFeature()

◆ GetModel()

ILModel* GetModel ( int  idx)

Get the model object with the given index.

Parameters
[in]idxThe input index, it should be a 0-based number smaller than total count.
Return values
modelReturn the model object.
See also
AddModel(), CountModel()

◆ IsTrained()

BOOL IsTrained ( )

Check whether the classifier is well-trained

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

◆ Predict()

LPVErrorCode Predict ( ILImage img,
ILRegion predictRegion,
LString classLabel,
double *  confidence 
)

Predict the input image with the region, report its class label.

Parameters
[in]imgThe input image
[in]predictRegionThe input prediction region, could be null.
[out]classLabelOutput the result class label.
[out]confidenceOutput the confidence of this prediction. It's a numeric positive value mostly in 0 ~ 1, the higher indicates the classifier is more confident and the result is more trustworthy.
Return values
errorReturn error code if anything is wrong.

◆ RemoveAllClass()

void RemoveAllClass ( BOOL  deleteSampleDb)

Remove all the classes.

Parameters
[in]deleteSampleDbWhether to permanently delete all the sample databases together. By default, we don't.

◆ RemoveAllFeatures()

void RemoveAllFeatures ( )

Remove all the features in the classifier

See also
RemoveFeature()

◆ RemoveAllModels()

void RemoveAllModels ( )

Remove all the models in the classifier

See also
RemoveModel()

◆ RemoveClass()

void RemoveClass ( LString  classLabel,
BOOL  deleteSampleDb 
)

Remove the class from the classifier.

Parameters
[in]classLabelThe label of the class.
[in]deleteSampleDbWhether to permanently delete the sample database together. By default, we don't.

◆ RemoveFeature()

void RemoveFeature ( int  idx)

Remove the feature with the given index.

Parameters
[in]idxThe input index, it should be a 0-based number smaller than total count.
See also
RemoveAllFeatures(), AddFeature()

◆ RemoveModel()

void RemoveModel ( int  idx)

Remove the model with the given index.

Parameters
[in]idxThe input index, it should be a 0-based number smaller than total count.
See also
RemoveAllModels(), AddModel()

◆ Train()

LPVErrorCode Train ( )

Train the classifier. All the features in it will engage in, and all the models will be trained.

Return values
errorReturn error code if anything is wrong.