This interface provide functionalities of the machine learning based image classification. More...
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) |
ILSampleDatabase * | GetClassSampleDb (LString classLabel) |
ILFeature * | GetFeature (int idx) |
ILModel * | GetModel (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 | |
ILObject * | Copy () |
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. | |
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.
void AddClass | ( | LString | classLabel, |
ILSampleDatabase * | sampleDB | ||
) |
Add a new class and the input associated sample database.
[in] | classLabel | The label of the class. It may be a readable word and must be not duplicated. |
[in] | sampleDB | The associated sample database. |
int AddFeature | ( | ILFeature * | feature | ) |
Add the feature to the classifier.
[in] | feature | The input feature object. |
idx | Return the index of the new added feature. |
int AddModel | ( | ILModel * | model | ) |
Add the model to the classifier.
[in] | model | The input model object. |
idx | Return the index of the new added model. |
int CountFeature | ( | ) |
Get the total count of all the features.
val | The total count. |
int CountModel | ( | ) |
Get the total count of all the models.
val | The total count. |
Create a new class and its sample database.
[in] | classLabel | The label of the class. It may be a readable word and must be not duplicated. |
[in] | sampleDBDir | The 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. |
ILSampleDatabase* GetClassSampleDb | ( | LString | classLabel | ) |
Get the sample database of the required class.
[in] | classLabel | The label of the class. |
sampleDB | Return the sample database. It may be null if there's no matching label. |
ILFeature* GetFeature | ( | int | idx | ) |
Get the feature object with the given index.
[in] | idx | The input index, it should be a 0-based number smaller than total count. |
feature | Return the feature object. |
ILModel* GetModel | ( | int | idx | ) |
Get the model object with the given index.
[in] | idx | The input index, it should be a 0-based number smaller than total count. |
model | Return the model object. |
BOOL IsTrained | ( | ) |
Check whether the classifier is well-trained
val | Return True if it's trained, otherwise, return False. |
LPVErrorCode Predict | ( | ILImage * | img, |
ILRegion * | predictRegion, | ||
LString * | classLabel, | ||
double * | confidence | ||
) |
Predict the input image with the region, report its class label.
[in] | img | The input image |
[in] | predictRegion | The input prediction region, could be null. |
[out] | classLabel | Output the result class label. |
[out] | confidence | Output 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. |
error | Return error code if anything is wrong. |
void RemoveAllClass | ( | BOOL | deleteSampleDb | ) |
Remove all the classes.
[in] | deleteSampleDb | Whether to permanently delete all the sample databases together. By default, we don't. |
void RemoveAllFeatures | ( | ) |
Remove all the features in the classifier
void RemoveAllModels | ( | ) |
Remove all the models in the classifier
void RemoveClass | ( | LString | classLabel, |
BOOL | deleteSampleDb | ||
) |
Remove the class from the classifier.
[in] | classLabel | The label of the class. |
[in] | deleteSampleDb | Whether to permanently delete the sample database together. By default, we don't. |
void RemoveFeature | ( | int | idx | ) |
Remove the feature with the given index.
[in] | idx | The input index, it should be a 0-based number smaller than total count. |
void RemoveModel | ( | int | idx | ) |
Remove the model with the given index.
[in] | idx | The input index, it should be a 0-based number smaller than total count. |
LPVErrorCode Train | ( | ) |
Train the classifier. All the features in it will engage in, and all the models will be trained.
error | Return error code if anything is wrong. |