CVB++ 14.1
Classifier Class Reference

Minos classifier object. More...

#include <cvb/minos/classifier.hpp>

Public Member Functions

 Classifier (const String &fileName)
 Loads a classifier with the given file name. More...
 
void * Handle () const noexcept
 Classic API CLF handle. More...
 
void Save (const String &fileName) const
 Write the classifier to a file. More...
 
std::vector< std::uint8_tToBuffer () const
 Builds a byte buffer with the classifier. More...
 
String FileName () const
 Name of the file from which this classifier was loaded (empty string, if this image list was neither loaded nor saved since its construction). More...
 
ClassifierModelInfoCollection Models () const
 Collection of the models contained in this classifier. More...
 
Rect< int > Extent () const noexcept
 Extent of the classes in the classifier relative to the anchor point. More...
 
std::chrono::system_clock::time_point CreationDate () const noexcept
 Creation date of the classifier. More...
 
bool IsMinos16BitClassifier () const
 Returns true if the classifier was generated by Minos16Bit. More...
 
int ContrastTrigger () const
 Get the trigger value for the contrast of features to be taken into account. More...
 
void SetContrastTrigger (int trigger)
 Set the trigger value for the contrast of features to be taken into account. More...
 
double Threshold () const
 Get the threshold for search operations with normalized quality feedback. More...
 
void SetThreshold (double threshold)
 Set the threshold for search operations with normalized quality feedback. More...
 
QualityFeedback QualityMeasure () const
 Get the type of quality feedback from the classifier. More...
 
void SetQualityMeasure (QualityFeedback quality)
 Set the type of quality feedback from the classifier. More...
 
String TrainingSetName () const
 Get name of the training set from which this classifier was generated. More...
 
class LearnParameters LearnParameters () const
 Get the set of parameters that has been used during classifier generation. More...
 
String Comment () const
 Get the comment assigned to the classifier at generation time. More...
 
void SetComment (String comment)
 Set the comment assigned to the classifier at generation time. More...
 
std::unique_ptr< ClassifierTransform (Matrix2D transformation)
 Generate a new classifier by transforming this classifier with a 2x2 transformation matrix. More...
 
std::unique_ptr< ClassifierSetGlobalAdvanceVector (Point2D< int > advance)
 Create a new classifier, that is a copy of this classifier, but with a global advance vector applied to all classes in the classifier. More...
 
String Read (const ImagePlane &plane, ReadMode mode, Area2D startAOI, Area2D ocrAOI, SearchResult &startOrStop, double density=1.0)
 Reads a string of characters. More...
 
std::vector< SearchResultRead (const ImagePlane &plane, Area2D startAOI, Area2D ocrAOI, double density=1.0)
 Reads a list of characters. More...
 
SearchResult Search (const ImagePlane &plane, SearchMode mode, Area2D aoi, double density=1.0)
 Search one object using this Minos classifier. More...
 
SearchResult Search (const ImagePlane &plane, SearchMode mode, double density=1.0)
 Search one object using this Minos classifier. More...
 
std::vector< SearchResultSearchAll (const ImagePlane &plane, int locality, Area2D aoi, double density=1.0)
 Search all objects using this Minos classifier. More...
 
std::vector< SearchResultSearchAll (const ImagePlane &plane, int locality, double density=1.0)
 Search all objects using this Minos classifier. More...
 

Static Public Member Functions

static std::unique_ptr< ClassifierLoad (const String &fileName)
 Load a saved classifier from a file. More...
 
static std::unique_ptr< ClassifierFromBuffer (const void *buffer, size_t size)
 Recreate a serialized Minos classifier from a byte array. More...
 
template<class RANGE >
static TypedRange< std::unique_ptr< Classifier >, std::uint8_t, RANGE >::type FromBuffer (const RANGE &buffer)
 Recreate a serialized Minos classifier from a byte array. More...
 
static std::unique_ptr< ClassifierFromHandle (HandleGuard< Classifier > &&guard)
 Creates classifier from a classic API handle. More...
 

Detailed Description

Minos classifier object.

Examples
Minos/QmlMinos.

Constructor & Destructor Documentation

◆ Classifier()

Classifier ( const String fileName)
inlineexplicit

Loads a classifier with the given file name.

Parameters
[in]fileNameThe file name.
Exceptions
Anyexception derived from std::exception including CvbException.

Member Function Documentation

◆ Comment()

String Comment ( ) const
inline

Get the comment assigned to the classifier at generation time.

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

◆ ContrastTrigger()

int ContrastTrigger ( ) const
inline

Get the trigger value for the contrast of features to be taken into account.

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

◆ CreationDate()

std::chrono::system_clock::time_point CreationDate ( ) const
inlinenoexcept

Creation date of the classifier.

Returns
The creation date.
Exceptions
Doesnot throw any exception.

◆ Extent()

Rect< int > Extent ( ) const
inlinenoexcept

Extent of the classes in the classifier relative to the anchor point.

Returns
The classifier extent.
Exceptions
Doesnot throw any exception.

◆ FileName()

String FileName ( ) const
inline

Name of the file from which this classifier 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< Classifier >, std::uint8_t, RANGE >::type FromBuffer ( const RANGE &  buffer)
inlinestatic

Recreate a serialized Minos classifier from a byte array.

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

◆ FromBuffer() [2/2]

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

Recreate a serialized Minos classifier from a byte array.

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

◆ FromHandle()

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

Creates classifier from a classic API handle.

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

The classifier 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.

◆ IsMinos16BitClassifier()

bool IsMinos16BitClassifier ( ) const
inline

Returns true if the classifier was generated by Minos16Bit.

Returns
True if generated by Minos16Bit, false otherwise.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ LearnParameters()

class LearnParameters LearnParameters ( ) const
inline

Get the set of parameters that has been used during classifier generation.

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

◆ Load()

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

Load a saved classifier from a file.

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

◆ Models()

ClassifierModelInfoCollection Models ( ) const
inline

Collection of the models contained in this classifier.

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.

◆ QualityMeasure()

QualityFeedback QualityMeasure ( ) const
inline

Get the type of quality feedback from the classifier.

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

◆ Read() [1/2]

std::vector< SearchResult > Read ( const ImagePlane plane,
Area2D  startAOI,
Area2D  ocrAOI,
double  density = 1.0 
)
inline

Reads a list of characters.

Parameters
[in]planeImage plane to read on.
[in]startAOIArea in which to start the read operation.
[in]ocrAOIArea to be used for the intermediate read steps; this area will be applied relative to the expected position of the next character and is typically only a few pixels wide and high.
[in]densityDensity to be used for the read operation.
Returns
The list of characters that has been read by this function.
Exceptions
Anyexception derived from std::exception including CvbException.

Uses the following approach:

  1. To begin with, the first object in the startAOI will be searched.
  2. This result's advance vector will be added to this result's position; around the result position, the ocrAOI will be centered.
  3. The result area will be used as the AOI for a new FindFirst search operation. The whole process will be repeated until no more results are encountered. String of up to 32k characters are read.

◆ Read() [2/2]

String Read ( const ImagePlane plane,
ReadMode  mode,
Area2D  startAOI,
Area2D  ocrAOI,
SearchResult startOrStop,
double  density = 1.0 
)
inline

Reads a string of characters.

Parameters
[in]planeImage plane to read on.
[in]modeRead mode.
[in]startAOIArea in which to start the read operation.
[in]ocrAOIArea to be used for the intermediate read steps; this area will be applied relative to the expected position of the next character and is typically only a few pixels wide and high.
[out]startOrStopFirst or last character that has been read (depending on the value of the mode parameter), output.
[in]densityDensity to be used for the read operation.
Returns
The string that has been read by this function.
Exceptions
Anyexception derived from std::exception including CvbException.

Uses the following approach:

  1. To begin with, the first object in the startAOI will be searched.
  2. This result's advance vector will be added to this result's position; around the result position, the ocrAOI will be centered.
  3. The result area will be used as the AOI for a new FindFirst search operation. The whole process will be repeated until no more results are encountered. String of up to 32k characters are read.

◆ Save()

void Save ( const String fileName) const
inline

Write the classifier to a file.

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

◆ Search() [1/2]

SearchResult Search ( const ImagePlane plane,
SearchMode  mode,
Area2D  aoi,
double  density = 1.0 
)
inline

Search one object using this Minos classifier.

Parameters
[in]planeImage plane to search on.
[in]modeSearch mode to be used.
[in]aoiArea to search in.
[in]densityDensity at which to search ([0...1]).
Returns
The found result (SearchResult::Nothing() if none was found).
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Search() [2/2]

SearchResult Search ( const ImagePlane plane,
SearchMode  mode,
double  density = 1.0 
)
inline

Search one object using this Minos classifier.

Parameters
[in]planeImage plane to search on.
[in]modeSearch mode to be used.
[in]densityDensity at which to search ([0...1]).
Returns
The found result (SearchResult::Nothing() if none was found)..
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SearchAll() [1/2]

std::vector< SearchResult > SearchAll ( const ImagePlane plane,
int  locality,
Area2D  aoi,
double  density = 1.0 
)
inline

Search all objects using this Minos classifier.

Parameters
[in]planeImage plane to search on.
[in]localityRadius within which no better solution may exist.
[in]aoiArea to search in.
[in]densityDensity at which to search ([0...1]).
Returns
List of found results.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SearchAll() [2/2]

std::vector< SearchResult > SearchAll ( const ImagePlane plane,
int  locality,
double  density = 1.0 
)
inline

Search all objects using this Minos classifier.

Parameters
[in]planeImage plane to search on.
[in]localityRadius within which no better solution may exist.
[in]densityDensity at which to search ([0...1]).
Returns
List of found results.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetComment()

void SetComment ( String  comment)
inline

Set the comment assigned to the classifier at generation time.

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

◆ SetContrastTrigger()

void SetContrastTrigger ( int  trigger)
inline

Set the trigger value for the contrast of features to be taken into account.

Parameters
[in]triggerThe trigger value.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetGlobalAdvanceVector()

std::unique_ptr< Classifier > SetGlobalAdvanceVector ( Point2D< int >  advance)
inline

Create a new classifier, that is a copy of this classifier, but with a global advance vector applied to all classes in the classifier.

Parameters
[in]advanceAdvance vector to apply globally.
Returns
The new classifier.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetQualityMeasure()

void SetQualityMeasure ( QualityFeedback  quality)
inline

Set the type of quality feedback from the classifier.

Parameters
[in]qualityThe quality value.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetThreshold()

void SetThreshold ( double  threshold)
inline

Set the threshold for search operations with normalized quality feedback.

Parameters
[in]thresholdThe threshold value.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Threshold()

double Threshold ( ) const
inline

Get the threshold for search operations with normalized quality feedback.

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

◆ ToBuffer()

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

Builds a byte buffer with the classifier.

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

◆ TrainingSetName()

String TrainingSetName ( ) const
inline

Get name of the training set from which this classifier was generated.

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

◆ Transform()

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

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

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