CVB++ 14.1
Classifier Class Referencefinal

ShapeFinder2 classifier object. More...

#include <cvb/shapefinder2/classifier.hpp>

Public Member Functions

 Classifier (const String &fileName)
 Loads a classifier with the given file name. More...
 
void * Handle () const noexcept
 Classic API classifier handle. More...
 
void Save (const String &fileName) const
 Writes the classifier to a file. More...
 
std::unique_ptr< ImageVisualization (int layer=-1) const
 Creates and returns a color coded image representation of this ShapeFinder classifier. More...
 
int NumLayers () const noexcept
 Number of layers in the classifier. More...
 
String FileName () const
 Gets the name of the file, from which this classifier was loaded. More...
 
void SetComment (const String &comment) noexcept
 Set the comment assigned to the classifier. More...
 
String Comment () const noexcept
 Get the comment assigned to the classifier. More...
 
Cvb::ShapeFinder2::GradientType GradientType () const noexcept
 Get the gradient type this classifier uses for feature extraction. More...
 
Rect< int > FeatureWindow () const noexcept
 Get the feature window of this classifier. More...
 
int ContrastThreshold () const noexcept
 Get the threshold for the gradient slope. More...
 
void SetContrastThreshold (int threshold)
 Set the threshold for the gradient slope. More...
 
Angle AngularTolerance () const noexcept
 Get the acceptance parameter for feature gradient angles. More...
 
void SetAngularTolerance (Angle angularTolerance)
 Set the acceptance parameter for feature gradient angles. More...
 
int FeatureCount () const noexcept
 Get the number of features this classifier contains. More...
 
bool UseCuda (CudaStatus status) const noexcept
 Set the flag to use CUDA if possible or to force not using CUDA. More...
 
std::vector< SearchResultSearchAll (const ImagePlane &plane, Rect< int > aoi, PrecisionMode precision, double relativeThreshold, int minimumThreshold, int coarseLocality, ValueRange< Angle > rotationRange, ValueRange< double > scaleRange)
 Use this classifier to perform a ShapeFinder search on an image plane. More...
 
std::vector< SearchResultSearchAll (const ImagePlane &plane, Rect< int > aoi, PrecisionMode precision, double relativeThreshold, int minimumThreshold, int coarseLocality)
 Use this classifier to perform a ShapeFinder search on an image plane. More...
 
Rect< int > TrainingWindow () const noexcept
 Training window of the classes in the classifier relative to the anchor point. More...
 
std::vector< Point2D< double > > FineFeatures () const noexcept
 The features the classifier uses on the finely granular level. More...
 
std::vector< Point2D< double > > CoarseFeatures () const noexcept
 Features the classifier uses on the coarsely granular level. More...
 
int CoarseScale () const noexcept
 Scale factor between the fine and the coarse feature level. More...
 
ValueRange< AngleRotation ()
 Range of rotations for which this classifier has been generated. More...
 
ValueRange< double > Scale ()
 Range of scales for which this classifier has been generated. More...
 
Cvb::ShapeFinder2::ContrastMode ContrastMode ()
 Contrast mode for which this classifier has been created. More...
 
double RotationStep ()
 Step size at which the rotations in the classifier have been generated. More...
 
double ScaleStep ()
 Step size at which the scales in the classifier have been generated. More...
 

Static Public Member Functions

static std::unique_ptr< ClassifierFromHandle (HandleGuard< Classifier > &&guard)
 Creates a classifier from a classic API handle. More...
 
static std::unique_ptr< ClassifierCreate (const String &fileName)
 Creates a classifier object loading a classifier file. More...
 

Detailed Description

ShapeFinder2 classifier object.

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

◆ AngularTolerance()

Angle AngularTolerance ( ) const
inlinenoexcept

Get the acceptance parameter for feature gradient angles.

Returns
Angular tolerance
Exceptions
Doesnot throw any exception.

◆ CoarseFeatures()

std::vector< Point2D< double > > CoarseFeatures ( ) const
inlinenoexcept

Features the classifier uses on the coarsely granular level.

Returns
The coarse features
Exceptions
Doesnot throw any exception.

◆ CoarseScale()

int CoarseScale ( ) const
inlinenoexcept

Scale factor between the fine and the coarse feature level.

Returns
The coarse scale
Exceptions
Doesnot throw any exception.

◆ Comment()

String Comment ( ) const
inlinenoexcept

Get the comment assigned to the classifier.

Returns
Comment of the classifier
Exceptions
Doesnot throw any exception.

◆ ContrastMode()

Contrast mode for which this classifier has been created.

Returns
The contrast mode
Exceptions
Doesnot throw any exception.

◆ ContrastThreshold()

int ContrastThreshold ( ) const
inlinenoexcept

Get the threshold for the gradient slope.

Returns
Contrast threshold
Exceptions
Doesnot throw any exception.

◆ Create()

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

Creates a classifier object loading a classifier file.

Parameters
[in]fileNameThe file name.
Returns
Pointer to classifier object.
Exceptions
Anyexception derived from std::exception including CvbException.
Examples
ShapeFinder2/QtShapeFinder2, and ShapeFinder2/QtShapeFinder2Cuda.

◆ FeatureCount()

int FeatureCount ( ) const
inlinenoexcept

Get the number of features this classifier contains.

Returns
Number of features
Exceptions
Doesnot throw any exception.

◆ FeatureWindow()

Rect< int > FeatureWindow ( ) const
inlinenoexcept

Get the feature window of this classifier.

Returns
Feature window
Exceptions
Doesnot throw any exception.

◆ FileName()

String FileName ( ) const
inline

Gets the name of the file, from which this classifier was loaded.

Returns
File name
Exceptions
Doesnot throw any exception.

◆ FineFeatures()

std::vector< Point2D< double > > FineFeatures ( ) const
inlinenoexcept

The features the classifier uses on the finely granular level.

Returns
The fine features
Exceptions
Doesnot throw any exception.

◆ FromHandle()

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

Creates a 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.

◆ GradientType()

Get the gradient type this classifier uses for feature extraction.

Returns
Gradient type
Exceptions
Doesnot throw any exception.

◆ Handle()

void * Handle ( ) const
inlinenoexcept

Classic API classifier handle.

Returns
Classic API handle.
Exceptions
Doesnot throw any exception.

It is normally not necessary to work with this handle.

◆ NumLayers()

int NumLayers ( ) const
inlinenoexcept

Number of layers in the classifier.

Returns
Number of layers
Exceptions
Doesnot throw any exception.

◆ Rotation()

ValueRange< Angle > Rotation ( )
inline

Range of rotations for which this classifier has been generated.

Returns
The rotation in degrees
Exceptions
Doesnot throw any exception.

◆ RotationStep()

double RotationStep ( )
inline

Step size at which the rotations in the classifier have been generated.

Returns
The rotation step in degrees
Exceptions
Doesnot throw any exception.

◆ Save()

void Save ( const String fileName) const
inline

Writes the classifier to a file.

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

◆ Scale()

ValueRange< double > Scale ( )
inline

Range of scales for which this classifier has been generated.

Returns
The scale
Exceptions
Doesnot throw any exception.

◆ ScaleStep()

double ScaleStep ( )
inline

Step size at which the scales in the classifier have been generated.

Returns
The scale step
Exceptions
Doesnot throw any exception.

◆ SearchAll() [1/2]

std::vector< SearchResult > SearchAll ( const ImagePlane plane,
Rect< int >  aoi,
PrecisionMode  precision,
double  relativeThreshold,
int  minimumThreshold,
int  coarseLocality 
)
inline

Use this classifier to perform a ShapeFinder search on an image plane.

Parameters
[in]planeThe image plane in which to use the classifier.
[in]aoiThe area of interest in the plane to search in.
[in]precisionThe search mode to use.
[in]relativeThresholdThe threshold used for eliminating less promising candidates in the edge model search step.
[in]minimumThresholdThe minimum gray value different that must be visible in the image before an edge location may be considered a feature.
[in]coarseLocalityThe minimum distance between two results in the coarse layer during the edge model search.
Returns
The list of all results that were found
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SearchAll() [2/2]

std::vector< SearchResult > SearchAll ( const ImagePlane plane,
Rect< int >  aoi,
PrecisionMode  precision,
double  relativeThreshold,
int  minimumThreshold,
int  coarseLocality,
ValueRange< Angle rotationRange,
ValueRange< double >  scaleRange 
)
inline

Use this classifier to perform a ShapeFinder search on an image plane.

Parameters
[in]planeThe image plane in which to use the classifier.
[in]aoiThe area of interest in the plane to search in.
[in]precisionThe search mode to use.
[in]relativeThresholdThe threshold used for eliminating less promising candidates in the edge model search step.
[in]minimumThresholdThe minimum gray value different that must be visible in the image before an edge location may be considered a feature.
[in]coarseLocalityThe minimum distance between two results in the coarse layer during the edge model search.
[in]rotationRangeThe range of rotations to be reported.
[in]scaleRangeThe range of scales to be reported.
Returns
The list of all results that were found
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetAngularTolerance()

void SetAngularTolerance ( Angle  angularTolerance)
inline

Set the acceptance parameter for feature gradient angles.

Parameters
[in]angularToleranceThe angular tolerance.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ SetComment()

void SetComment ( const String comment)
inlinenoexcept

Set the comment assigned to the classifier.

Parameters
[in]commentThe comment string of the classifier.
Exceptions
Doesnot throw any exception.

◆ SetContrastThreshold()

void SetContrastThreshold ( int  threshold)
inline

Set the threshold for the gradient slope.

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

◆ TrainingWindow()

Rect< int > TrainingWindow ( ) const
inlinenoexcept

Training window of the classes in the classifier relative to the anchor point.

Returns
The training window
Exceptions
Doesnot throw any exception.

◆ UseCuda()

bool UseCuda ( CudaStatus  status) const
inlinenoexcept

Set the flag to use CUDA if possible or to force not using CUDA.

Parameters
[in]statusThe CUDA status. If CudaStatus::SFCS_ForceDisable CUDA won't be used in SF2Search.
Returns
true if status == SFCS_Default and a CUDA capable device is present, false otherwise.
Exceptions
Doesnot throw any exception.

◆ Visualization()

std::unique_ptr< Image > Visualization ( int  layer = -1) const
inline

Creates and returns a color coded image representation of this ShapeFinder classifier.

Parameters
[in]layerThe layer of the classifier to be visualized. A value of -1 superimposes all layers.
Returns
The image representation
Exceptions
Anyexception derived from std::exception including CvbException.