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

This interface represents a sample database for training and testing sample organization and management. More...

Inheritance diagram for ILSampleDatabase:
ILObject LSampleDatabase

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 ()
 
ILSampleGetSample (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.
 
ILSampleItemSample (LPVSampleType sampleType, int idx)
 
LPVErrorCode Refresh ()
 
void RemoveSample (LString sampleName)
 
void RemoveSampleFolder (LString folderPath)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
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.
 

Detailed Description

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.

Example Code

Member Function Documentation

◆ AddSample()

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.

Parameters
[in]sampleTypeThe dataset that the sample belongs to, either train or test.
[in]sampleThe sample instance.
Return values
sampleNameReturn the unique name of the new added sample.
See also
AddSampleImage(), AddSampleFolder()

◆ AddSampleFolder()

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.

Parameters
[in]sampleTypeThe dataset that the sample belongs to, either train or test.
[in]folderPathThe sample folder.
See also
AddSample(), AddSampleImage(), RemoveSampleFolder()

◆ AddSampleImage()

LString AddSampleImage ( LPVSampleType  sampleType,
ILImage img,
ILRegion sampleRegion 
)

Add an sample to the database, with the given image and region.

Parameters
[in]sampleTypeThe dataset that the sample belongs to, either train or test.
[in]imgThe input image
[in]sampleRegionThe input region, could be null.
Return values
sampleNameReturn the unique name of the new added sample.
See also
AddSample(), AddSampleFolder()

◆ CountSample()

int CountSample ( LPVSampleType  sampleType)

Get the total count of the sample in the required dataset.

Parameters
[in]sampleTypeThe dataset that the sample belongs to, either train or test.
Return values
valThe total count.

◆ Delete()

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.

Return values
errorReturn error code if anything is wrong.

◆ GetSample()

ILSample* GetSample ( LString  sampleName)

Get the sample instance by the given name, no matter which dataset it is in.

Parameters
[in]sampleNameThe name of the sample
Return values
sampleReturn the sample instance
See also
ItemSample(), AddSample()

◆ Init()

void Init ( LString  labelName,
LString  workingDirectory 
)

Create and initialized the database.

Parameters
[in]labelNameThe label of the sample 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.

◆ ItemSample()

ILSample* ItemSample ( LPVSampleType  sampleType,
int  idx 
)

Get the sample instance by the given index.

Parameters
[in]sampleTypeThe dataset that the sample belongs to, either train or test.
[in]idxThe input index, it should be a 0-based number smaller than total count.
Return values
sampleReturn the sample instance
See also
CountSample(), GetSample()

◆ Refresh()

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.

Return values
errorReturn error code if anything is wrong.

◆ RemoveSample()

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.

Parameters
[in]sampleNameThe sample name to remove.
See also
AddSample(), RemoveSampleFolder()

◆ RemoveSampleFolder()

void RemoveSampleFolder ( LString  folderPath)

Removed the sample folder from the database. We wouldn't delete the folder on the disk.

Parameters
[in]folderPathThe sample folder.
See also
AddSampleFolder(), RemoveSample()