CVB++ 15.0
TrainingSet Class Reference

A Minos Training Set from which a classifier can be generated. More...

#include <cvb/minos/training_set.hpp>

Public Member Functions

 TrainingSet ()
 Create an empty training set. More...
 
 TrainingSet (const String &fileName)
 Load a saved training set from a file. More...
 
void * Handle () const noexcept
 Classic API CLF handle. More...
 
void Save (const String &fileName) const
 Write the training set to a file. More...
 
std::vector< std::uint8_tToBuffer () const
 Serializes the training set into a buffer. More...
 
std::unique_ptr< TrainingSetTransform (Matrix2D transformation)
 Generate a new training set by transforming this training set with a 2x2 transformation matrix. More...
 
std::vector< SearchResultCheckConsistency (double threshold, double density=1.0)
 Test all images in the parent training set for instances of this model that might have been forgotten during the training process. More...
 
int ClassCount () const
 The number of identifiable classes inside this training set. More...
 
InstanceInfoCollectionInstances ()
 The instances contained in this training set. More...
 
int InstancesTotal () const
 Total number of instances currently trained in this training set. More...
 
ImageInfoCollectionImages ()
 The images contained in this training set. More...
 
ModelInfoCollectionModels ()
 The models contained in this training set. More...
 
String FileName () const
 Name of the file, from which this training set was loaded (empty string if this image list was neither loaded nor saved since its construction). More...
 
bool IsModified () const
 Get a flag that informs about unsaved modifications to the training set. More...
 
void SetIsModified (bool isModified)
 Set a flag that informs about unsaved modifications to the training set. More...
 
Rect< int > Extent () const
 Extent of the classes in the training set relative to the anchor point. More...
 
Rect< int > LastFeatureWindow () const
 Feature window of the last model that has been created for the training set. More...
 
String Comment () const
 Get the comment assigned to the training set at generation time. More...
 
void SetComment (String comment)
 Set the comment assigned to the training set at generation time. More...
 
double ExpectationRadius () const
 Get the expectation radius - the radius that is searched for the best occurrence of a sample, when adding a new sample to the training set. More...
 
void SetExpectationRadius (double expectationRadius)
 Set the expectation radius - the radius that is searched for the best occurrence of a sample, when adding a new sample to the training set. More...
 
double CorrelationThreshold () const
 Gets the correlation threshold. The correlation value under which Minos proposes generating a new model, not generating a new instance of an existing model with which the new instance correlates poorly. More...
 
void SetCorrelationThreshold (double correlationThreshold)
 Set the correlation threshold - the correlation value below which Minos will suggest the generation of a new model rather over the generation of a new instance of an existing model, with which the new instance correlates poorly. More...
 

Static Public Member Functions

static std::unique_ptr< TrainingSetLoad (const String &fileName)
 Load a saved training set from a file. More...
 
static std::unique_ptr< TrainingSetFromBuffer (const void *buffer, size_t size)
 Recreate a serialized Minos training set from a byte array. More...
 
template<class RANGE >
static TypedRange< std::unique_ptr< TrainingSet >, std::uint8_t, RANGE >::type FromBuffer (const RANGE &buffer)
 Recreate a serialized Minos training set from a byte array. More...
 
static std::unique_ptr< TrainingSetFromHandle (HandleGuard< TrainingSet > &&guard)
 Creates training set from a classic API handle. More...
 

Detailed Description

A Minos Training Set from which a classifier can be generated.

Constructor & Destructor Documentation

◆ TrainingSet() [1/2]

TrainingSet ( )
inline

Create an empty training set.

Exceptions
Anyexception derived from std::exception including CvbException.

◆ TrainingSet() [2/2]

TrainingSet ( const String fileName)
inlineexplicit

Load a saved training set from a file.

Parameters
[in]fileNameName of the file to be loaded.
Exceptions
Anyexception derived from std::exception including CvbException.

Member Function Documentation

◆ CheckConsistency()

std::vector< SearchResult > CheckConsistency ( double  threshold,
double  density = 1.0 
)
inline

Test all images in the parent training set for instances of this model that might have been forgotten during the training process.

Parameters
[in]thresholdCorrelation threshold to be used for the consistency check.
[in]densityDensity to be used for the consistency check.
Returns
Potentially forgotten positive samples that may be added to the training set.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ ClassCount()

int ClassCount ( ) const
inline

The number of identifiable classes inside this training set.

Returns
The number of classes.
Exceptions
Anyexception derived from std::exception including CvbException.

The number of classes cannot be higher than the number of trained models (see property Models). If two models have the same name, the classifier can no longer distinguish between these two models, reducing the ClassCount property.

◆ Comment()

String Comment ( ) const
inline

Get the comment assigned to the training set at generation time.

Returns
The comment.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ CorrelationThreshold()

double CorrelationThreshold ( ) const
inline

Gets the correlation threshold. The correlation value under which Minos proposes generating a new model, not generating a new instance of an existing model with which the new instance correlates poorly.

Returns
The correlation threshold.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ ExpectationRadius()

double ExpectationRadius ( ) const
inline

Get the expectation radius - the radius that is searched for the best occurrence of a sample, when adding a new sample to the training set.

Returns
The expectation radius.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Extent()

Rect< int > Extent ( ) const
inline

Extent of the classes in the training set relative to the anchor point.

Returns
The training set classes extent.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FileName()

String FileName ( ) const
inline

Name of the file, from which this training set was loaded (empty string if this image list was neither loaded nor saved since its construction).

Returns
The file name.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromBuffer() [1/2]

static TypedRange< std::unique_ptr< TrainingSet >, std::uint8_t, RANGE >::type FromBuffer ( const RANGE &  buffer)
inlinestatic

Recreate a serialized Minos training set from a byte array.

Parameters
[in]bufferByte array from which to create the training set.
Returns
Pointer to the loaded training set.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromBuffer() [2/2]

static std::unique_ptr< TrainingSet > FromBuffer ( const void *  buffer,
size_t  size 
)
inlinestatic

Recreate a serialized Minos training set from a byte array.

Parameters
[in]bufferByte array from which to create the training set.
[in]sizeNumber of bytes to use.
Returns
Pointer to the loaded training set.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromHandle()

static std::unique_ptr< TrainingSet > FromHandle ( HandleGuard< TrainingSet > &&  guard)
inlinestatic

Creates training set from a classic API handle.

Parameters
[in]guardLife time guard for C-API handle.
Returns
The training set created from the classic API handle.
Exceptions
Anyexception derived from std::exception including CvbException.

The training set takes ownership of the handle, so you must share it before using this function.

◆ Handle()

void * Handle ( ) const
inlinenoexcept

Classic API CLF handle.

Returns
Classic API handle.
Exceptions
Doesnot throw any exception.

It is normally not necessary to work with this handle.

◆ Images()

ImageInfoCollection & Images ( )
inline

The images contained in this training set.

Returns
The image info collection.
Exceptions
Anyexception derived from std::exception including CvbException.

The collection keeps internal link to the classifier, shares resources with it and stays valid even if the classifier object itself gets destroyed.

◆ Instances()

InstanceInfoCollection & Instances ( )
inline

The instances contained in this training set.

Returns
The instance info collection.
Exceptions
Anyexception derived from std::exception including CvbException.

The collection keeps internal link to the classifier, shares resources with it and stays valid even if the classifier object itself gets destroyed.

◆ InstancesTotal()

int InstancesTotal ( ) const
inline

Total number of instances currently trained in this training set.

Returns
The instance count.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ IsModified()

bool IsModified ( ) const
inline

Get a flag that informs about unsaved modifications to the training set.

Returns
The is-modified flag.
Exceptions
Anyexception derived from std::exception including CvbException.

Saving the training set will set this flag to false.

◆ LastFeatureWindow()

Rect< int > LastFeatureWindow ( ) const
inline

Feature window of the last model that has been created for the training set.

Returns
The last model feature window.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Load()

static std::unique_ptr< TrainingSet > Load ( const String fileName)
inlinestatic

Load a saved training set from a file.

Parameters
[in]fileNameName of the file to be loaded.
Returns
Pointer to the loaded training set.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Models()

ModelInfoCollection & Models ( )
inline

The models contained in this training set.

Returns
The model info collection.
Exceptions
Anyexception derived from std::exception including CvbException.

The collection keeps internal link to the classifier, shares resources with it and stays valid even if the classifier object itself gets destroyed.

◆ Save()

void Save ( const String fileName) const
inline

Write the training set to a file.

Parameters
[in]fileNamePath to save to.
Exceptions
Anyexception derived from std::exception including CvbException.

As a side effect this function sets the IsModified flag to false, if the training set was saved successfully.

◆ SetComment()

void SetComment ( String  comment)
inline

Set the comment assigned to the training set at generation time.

Parameters
[in]commentThe comment.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetCorrelationThreshold()

void SetCorrelationThreshold ( double  correlationThreshold)
inline

Set the correlation threshold - the correlation value below which Minos will suggest the generation of a new model rather over the generation of a new instance of an existing model, with which the new instance correlates poorly.

Parameters
[in]correlationThresholdThe correlation threshold.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetExpectationRadius()

void SetExpectationRadius ( double  expectationRadius)
inline

Set the expectation radius - the radius that is searched for the best occurrence of a sample, when adding a new sample to the training set.

Parameters
[in]expectationRadiusThe expectation radius.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetIsModified()

void SetIsModified ( bool  isModified)
inline

Set a flag that informs about unsaved modifications to the training set.

Parameters
[in]isModifiedThe is-modified flag.
Exceptions
Anyexception derived from std::exception including CvbException.

Saving the training set will set this flag to false.

◆ ToBuffer()

std::vector< std::uint8_t > ToBuffer ( ) const
inline

Serializes the training set into a buffer.

Returns
Byte array with serialzed Minos training set.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Transform()

std::unique_ptr< TrainingSet > Transform ( Matrix2D  transformation)
inline

Generate a new training set by transforming this training set with a 2x2 transformation matrix.

Parameters
[in]transformationMatrix with which to transform the geometry of this training set.
Returns
Transformed training set.
Exceptions
Anyexception derived from std::exception including CvbException.