This interface represents a sample database for training and testing sample organization and management. More...
Public Member Functions | |
LString | AddSample (LPVSampleType sampleType, ILSample *sample) |
void | AddSampleFolder (LPVSampleType sampleType, LString folderPath) |
LString | AddSampleImage (LPVSampleType sampleType, ILImage *img, ILRegion *sampleRegion) |
int | CountSample (LPVSampleType sampleType) |
LPVErrorCode | Delete () |
ILSample * | GetSample (LString sampleName) |
void | Init (LString labelName, LString workingDirectory) |
BOOL | IsInMemory () |
Whether this is an in-memory database, whose sample files and all informations are never saved. | |
ILSample * | ItemSample (LPVSampleType sampleType, int idx) |
LPVErrorCode | Refresh () |
void | RemoveSample (LString sampleName) |
void | RemoveSampleFolder (LString folderPath) |
Public Member Functions inherited from ILObject | |
ILObject * | Copy () |
LPVErrorCode | Load (LString filename) |
void | Reset () |
LPVErrorCode | Save (LString filename) |
BOOL | Valid () |
Properties | |
LString | Label [get] |
The label of the sample database, which is usually unique and as an identification for the database globally. Note: The database label may differ from the class label. | |
BOOL | UseCache [get, set] |
Whether the sample image and region data will be cached in memory. | |
LString | WorkingDir [get] |
The working directory of the sample 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 sample database for training and testing sample organization and management.
There are two supported database type:
To use this interface, you should create a LSampleDatabase object.
LString AddSample | ( | LPVSampleType | sampleType, |
ILSample * | sample | ||
) |
Add an sample to the database. The sample will be copied to the database then assigned a new name.
[in] | sampleType | The dataset that the sample belongs to, either train or test. |
[in] | sample | The sample instance. |
sampleName | Return the unique name of the new added sample. |
void AddSampleFolder | ( | LPVSampleType | sampleType, |
LString | folderPath | ||
) |
Add the given folder to the database. All samples in the folder will be added to database, and be refreshed manually via Refresh() or when the database is re-loaded.
[in] | sampleType | The dataset that the sample belongs to, either train or test. |
[in] | folderPath | The sample folder. |
LString AddSampleImage | ( | LPVSampleType | sampleType, |
ILImage * | img, | ||
ILRegion * | sampleRegion | ||
) |
Add an sample to the database, with the given image and region.
[in] | sampleType | The dataset that the sample belongs to, either train or test. |
[in] | img | The input image |
[in] | sampleRegion | The input region, could be null. |
sampleName | Return the unique name of the new added sample. |
int CountSample | ( | LPVSampleType | sampleType | ) |
Get the total count of the sample in the required dataset.
[in] | sampleType | The dataset that the sample belongs to, either train or test. |
val | The total count. |
LPVErrorCode Delete | ( | ) |
Delete the entire database. For the persisted database, the whole working directory will be removed permanently, including all the sample files. The external sample folders are kept.
error | Return error code if anything is wrong. |
Get the sample instance by the given name, no matter which dataset it is in.
[in] | sampleName | The name of the sample |
sample | Return the sample instance |
Create and initialized the database.
[in] | labelName | The label of the sample 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. |
ILSample* ItemSample | ( | LPVSampleType | sampleType, |
int | idx | ||
) |
Get the sample instance by the given index.
[in] | sampleType | The dataset that the sample belongs to, either train or test. |
[in] | idx | The input index, it should be a 0-based number smaller than total count. |
sample | Return the sample instance |
LPVErrorCode Refresh | ( | ) |
Refresh the dataset manually. For the in-memory dataset, it makes no sense. For the persisted, all sample folders are re-scanned and all samples are re-loaded. Inaccessible folders and files are ignored and skipped.
It is time-consuming, you may not do this frequently.
error | Return error code if anything is wrong. |
void RemoveSample | ( | LString | sampleName | ) |
Remove the sample from the database. For persisted database, the sample file wouldn't actually be deleted, but is moved to the sibling .deprecated folder.
[in] | sampleName | The sample name to remove. |
void RemoveSampleFolder | ( | LString | folderPath | ) |
Removed the sample folder from the database. We wouldn't delete the folder on the disk.
[in] | folderPath | The sample folder. |