CVB++ 14.1
ClassificationPredictor Class Reference

Predictor to classify patterns with. More...

#include <cvb/polimago/classification_predictor.hpp>

Inherits PredictorBaseEx.

Public Member Functions

 ClassificationPredictor (const String &fileName)
 Load a saved Polimago classification predictor from a file. More...
 
std::vector< StringClasses () const
 Class labels available in this predictor. More...
 
ClassificationType Classification () const
 The classification type for which this classifier has been generated. More...
 
int OutputDimension () const
 Dimension of results generated by this predictor. More...
 
int NumClasses () const
 Number of classes a classification predictor has been trained for. More...
 
ClassificationResult Classify (const Image &img, Point2D< int > pos, std::vector< double > &confidences)
 Classify a location inside an image. More...
 
ClassificationResult Classify (const Image &img, Point2D< int > pos)
 Classify a location inside an image. More...
 
- Public Member Functions inherited from PredictorBaseEx
int FeatureResolution () const noexcept
 Feature resolution value with which the classifier was trained. More...
 
- Public Member Functions inherited from PredictorBase
bool IsCompatible (const Image &img, Point2D< int > pos) const
 Verify the compatibility of a CVB image with this classifier. More...
 
bool IsCompatible (const Image &img) const
 Verify the compatibility of a CVB image with this classifier. More...
 
- Public Member Functions inherited from PolimagoFactoryCreatedObject
void * Handle () const noexcept
 Classic API Polimago handle. More...
 
String FileName () const
 Name of the file the object has been loaded from (or empty string if the object was not loaded). More...
 
void Save (const String &fileName) const
 Save this object into a file. More...
 
double Lambda () const noexcept
 Regularization value that has been used for generating this object. More...
 
double Offset () const noexcept
 Intercept weight that has been used for generating this object. More...
 
InterpolationType Interpolation () const noexcept
 Interpolation setting used for generating this object. More...
 
int ImagePlanes () const noexcept
 The plane count of the images that have been used for generating this classifier. Image on which this classifier is to be used will need to have the same plane count. More...
 
Rect< int > FeatureWindowExtent () const noexcept
 The feature window extent that has been used during classifier training. More...
 
Size2D< int > RetinaSize () const noexcept
 Size of the 'Retina' in pixels. The retina is the set of paxels onto which the input image is projected using the preprocessing code prior to application/training of the classifier. More...
 
Point2D< double > Correction () const noexcept
 Correction factors in X and Y direction required to rescale the input images for projection onto the retina. More...
 
String Preprocessing () const
 Preprocessing code with which this object was generated. More...
 

Static Public Member Functions

static std::unique_ptr< ClassificationPredictorFromHandle (ReleaseObjectGuard &&guard)
 Creates predictor from a classic API handle. More...
 
static std::unique_ptr< ClassificationPredictorLoad (const String &fileName)
 Load a saved predictor from a file. More...
 

Detailed Description

Predictor to classify patterns with.

Constructor & Destructor Documentation

◆ ClassificationPredictor()

ClassificationPredictor ( const String fileName)
inlineexplicit

Load a saved Polimago classification predictor from a file.

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

Member Function Documentation

◆ Classes()

std::vector< String > Classes ( ) const
inline

Class labels available in this predictor.

Returns
Class labels.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Classification()

ClassificationType Classification ( ) const
inline

The classification type for which this classifier has been generated.

Returns
Classification type.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Classify() [1/2]

ClassificationResult Classify ( const Image img,
Point2D< int >  pos 
)
inline

Classify a location inside an image.

Parameters
[in]imgImage to classify in.
[in]posPosition to classify.
Returns
Classification result.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Classify() [2/2]

ClassificationResult Classify ( const Image img,
Point2D< int >  pos,
std::vector< double > &  confidences 
)
inline

Classify a location inside an image.

Parameters
[in]imgImage to classify in.
[in]posPosition to classify.
[out]confidencesConfidence distribution (output).
Returns
Classification result.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ FromHandle()

static std::unique_ptr< ClassificationPredictor > FromHandle ( ReleaseObjectGuard &&  guard)
inlinestatic

Creates predictor from a classic API handle.

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

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

◆ Load()

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

Load a saved predictor from a file.

Parameters
[in]fileNameName of the file to be loaded.
Returns
Pointer to the loaded predictor.
Exceptions
Anyexception derived from std::exception including CvbException.
Examples
Polimago/QmlCookieClassification.

◆ NumClasses()

int NumClasses ( ) const
inline

Number of classes a classification predictor has been trained for.

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

◆ OutputDimension()

int OutputDimension ( ) const
inline

Dimension of results generated by this predictor.

Returns
Output dimension.
Exceptions
Anyexception derived from std::exception including CvbException.