CVB.Net 14.0
Classifier Class Reference

ShapeFinder2 classifier object. More...

Inherits ClassifierObject.

Public Member Functions

 Classifier (string fileName)
 Load a saved classifier from a file. More...
 
SearchResult[] SearchAll (ImagePlane plane, Rect aoi, PrecisionMode precision, double relativeThreshold, int minimumThreshold, int coarseLocality)
 Use this classifier to perform a ShapeFinder search on an image plane . More...
 
bool UseCuda (CudaStatus status)
 Allows disabling the use of CUDA and returns whether CUDA will in fact be used. More...
 
- Public Member Functions inherited from ClassifierObject
 ClassifierObject (string fileName, string typeName)
 Load a saved classifier from a file. More...
 
void Dispose ()
 IDisposable implementation. More...
 
void Transform (Matrix2D m)
 Transform this ShapeFinder classifier using a 2x2 matrix. More...
 
void Translate (Point2D offset)
 Translate this classifier by a selectable offset . More...
 
void Save (string fileName)
 Write the classifier to a file. More...
 
Image GetVisualization (int layer)
 Create and return a color coded image representation of this ShapeFinder classifier. The colors in the output image correspond to the gradient directions, the positions to the displacement vectors. This visual representation might be useful during interactive supervision and debugging. More...
 
Image GetVisualization ()
 Create and return a color coded image representation of this ShapeFinder classifier. The colors in the output image correspond to the gradient directions, the positions to the displacement vectors. This visual representation might be useful during interactive supervision and debugging. More...
 

Properties

Rect Extent [get]
 Training window of the classes in the classifier relative to the anchor point. More...
 
ReadOnlyCollection< Point2DFineFeatures [get]
 Features the classifier uses on the finely granular level. More...
 
ReadOnlyCollection< Point2DCoarseFeatures [get]
 Features the classifier uses on the coarsely granular level. More...
 
int CoarseScale [get]
 Scale factor between the fine and the coarse feature level. More...
 
ValueRange< AngleRotation [get]
 Range of rotations for which this classifier has been generated. Rotations are given in degrees. More...
 
ValueRange< double > Scale [get]
 Range of scales for which this classifier has been generated. More...
 
ContrastMode ContrastMode [get]
 Contrast mode for which this classifier has been created. More...
 
double RotationStep [get]
 Step size at which the rotations in the classifier have been generated. Rotations steps are given in degrees. More...
 
double ScaleStep [get]
 Step size at which the scales in the classifier have been generated. More...
 
- Properties inherited from ClassifierObject
IntPtr Handle [get]
 Native ShapeFinder2 classifier handle. More...
 
string FileName [get]
 Name of the file from which this classifier was loaded (string.Empty if this image list was neither loaded nor saved since its construction). More...
 
bool IsDisposed [get]
 Tests if the native handle has already been disposed.
 
unsafe string Comment [get, set]
 Comment assigned to the classifier. More...
 
GradientType GradientType [get]
 Gradient type this classifier uses for feature extraction. More...
 
Rect FeatureWindow [get]
 Feature window of this classifier (i.e. the bounding rectangle into which all the classifier's features fit) relative to the classifier's origin. More...
 
int NumLayers [get]
 Number of layers in the classifier (and in the accumulator generated by the search function). In ShapeFinder classifiers layers may be associated with specific classes or rotation information. In ShapeFinder2 the layer count is a purely informational value. More...
 
- Properties inherited from INativeHandle
IntPtr Handle [get]
 The native handle of the object.
 
bool IsDisposed [get]
 Possibility to check whether the object has already been disposed of.
 

Additional Inherited Members

- Protected Member Functions inherited from ClassifierObject
virtual void Dispose (bool disposing)
 IDispose helper function. More...
 
- Events inherited from ClassifierObject
NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
More...
 
- Events inherited from INativeHandle
NativeHandleEventDelegate ObjectDisposing
 Raised when this object is about to be disposed via the IDisposable.Dispose method.
More...
 

Detailed Description

ShapeFinder2 classifier object.

Constructor & Destructor Documentation

◆ Classifier()

Classifier ( string  fileName)

Load a saved classifier from a file.

Parameters
fileNamename of the file to be loaded
Exceptions
FileNotFoundExceptionIf the classifier file does not exist
FileLoadExceptionIf loading an existing classifier file failed either because the file is unreadable or because it does not contain a ShapeFinder2 classifier
ArgumentNullExceptionIf fileName is null

Member Function Documentation

◆ SearchAll()

SearchResult[] SearchAll ( ImagePlane  plane,
Rect  aoi,
PrecisionMode  precision,
double  relativeThreshold,
int  minimumThreshold,
int  coarseLocality 
)

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

Parameters
planethe image plane to search in; must have 8 bits per pixel in the plane in which the ShapeFinder2 classifier should search
aoiThe area of interest in the plane to search in; reducing the area of interest will decrease search time but not necessarily linearly (i.e. a reduction to half the image will not necessarily reduce the processing time by a factor of 2). Note that strictly speaking the area parameter applies only to the ShapeFinder2 edge model search; if you use one of the correlation modes (precision set to either PrecisionMode.CorrelationCoarse or PrecisionMode.CorrelationFine) it is possible for reported results to actually lie outside the area if hill climbing did lead them out of the area.
precisionsearch mode to use (see description of PrecisionMode for a description of the different search modes
relativeThresholdThreshold used for eliminating less promising candidates in the edge model search step of ShapeFinder2. During the edge model search phase, ShapeFinder2 gathers a list of candidates for possible object sites, and each candidate is assigned a quality derived from the number of features present at its site. The relative threshold is applied when deciding whether or not a new candidate may enter the list: If its quality is less than relativeThreshold percent of the so far best candidate, it may not enter the candidate list. Eliminating less promising candidates in this way has the advantage that the time needed for calculating their correlation in the (optional) correlation search step of ShapeFinder2 may be drastically reduced. Relative threshold must be given as a per cent value in in the range [0...1]
minimumThresholdminimum gray value different that must be visible in the image before an edge location may be considered a feature; minimumThreshold must be given a value great than 0
coarseLocalityMinimum distance between two results in the coarse layer during the ShapeFinder2 edge model search. If two of the candidates are closer than coarseLocality pixels in the coarse layer, the one with the lower quality will be eliminated. Keep in mind that this locality operates on the coarse layer: Setting it to a value of 10 will effectively lead to a minimum distance of 40 if the size factor (2^Scale) between the coarse and the fine layer is 4. Also note that if you perform a correlation step (precision set to either PrecisionMode.CorrelationCoarse or PrecisionMode.CorrelationFine) the actually reported results can (and are indeed not unlikely to) be less than coarseLocality * 2^Scale if the hill climbing algorithm brings them closer together.
Returns
list of all results that were found
Exceptions
ObjectDisposedExceptionIf this classifier or the Parent of plane has already been disposed
ArgumentNullExceptionIf the Parent of plane is null
CvbExceptionIf the selected plane has a data type other than 8 bits per pixel unsigned or if an unspecified error occurred
ArgumentOutOfRangeExceptionIf the relativeThreshold exceeds its valid ranges or if minimumThreshold is 0 or less or coarseLocality is less than 0

◆ UseCuda()

bool UseCuda ( CudaStatus  status)

Allows disabling the use of CUDA and returns whether CUDA will in fact be used.

Parameters
statusThe Cuda status. If CudaStatus.ForceDisable CUDA won't be used in search.
Returns
True if status is CudaStatus.Default and a CUDA capable device is present, false otherwise.

Property Documentation

◆ CoarseFeatures

ReadOnlyCollection<Point2D> CoarseFeatures
get

Features the classifier uses on the coarsely granular level.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ CoarseScale

int CoarseScale
get

Scale factor between the fine and the coarse feature level.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ ContrastMode

Contrast mode for which this classifier has been created.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ Extent

Rect Extent
get

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

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ FineFeatures

ReadOnlyCollection<Point2D> FineFeatures
get

Features the classifier uses on the finely granular level.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ Rotation

ValueRange<Angle> Rotation
get

Range of rotations for which this classifier has been generated. Rotations are given in degrees.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ RotationStep

double RotationStep
get

Step size at which the rotations in the classifier have been generated. Rotations steps are given in degrees.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ Scale

ValueRange<double> Scale
get

Range of scales for which this classifier has been generated.

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed

◆ ScaleStep

double ScaleStep
get

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

Exceptions
ObjectDisposedExceptionIf the classifier has already been disposed