Class CascadeClassifier
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Cascade classifier class for object detection.
public class CascadeClassifier : DisposableCvObject, IDisposable, ICvPtrHolder
- Inheritance
-
CascadeClassifier
- Implements
- Inherited Members
Constructors
CascadeClassifier()
Default constructor
public CascadeClassifier()
CascadeClassifier(string)
Loads a classifier from a file.
public CascadeClassifier(string fileName)
Parameters
fileNamestringName of the file from which the classifier is loaded.
Methods
DetectMultiScale(Mat, double, int, HaarDetectionTypes, Size?, Size?)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
public virtual Rect[] DetectMultiScale(Mat image, double scaleFactor = 1.1, int minNeighbors = 3, HaarDetectionTypes flags = (HaarDetectionTypes)0, Size? minSize = null, Size? maxSize = null)
Parameters
imageMatMatrix of the type CV_8U containing an image where objects are detected.
scaleFactordoubleParameter specifying how much the image size is reduced at each image scale.
minNeighborsintParameter specifying how many neighbors each candidate rectangle should have to retain it.
flagsHaarDetectionTypesParameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSizeSize?Minimum possible object size. Objects smaller than that are ignored.
maxSizeSize?Maximum possible object size. Objects larger than that are ignored.
Returns
- Rect[]
Vector of rectangles where each rectangle contains the detected object.
DetectMultiScale(Mat, out int[], out double[], double, int, HaarDetectionTypes, Size?, Size?, bool)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
public virtual Rect[] DetectMultiScale(Mat image, out int[] rejectLevels, out double[] levelWeights, double scaleFactor = 1.1, int minNeighbors = 3, HaarDetectionTypes flags = (HaarDetectionTypes)0, Size? minSize = null, Size? maxSize = null, bool outputRejectLevels = false)
Parameters
imageMatMatrix of the type CV_8U containing an image where objects are detected.
rejectLevelsint[]levelWeightsdouble[]scaleFactordoubleParameter specifying how much the image size is reduced at each image scale.
minNeighborsintParameter specifying how many neighbors each candidate rectangle should have to retain it.
flagsHaarDetectionTypesParameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSizeSize?Minimum possible object size. Objects smaller than that are ignored.
maxSizeSize?Maximum possible object size. Objects larger than that are ignored.
outputRejectLevelsbool
Returns
- Rect[]
Vector of rectangles where each rectangle contains the detected object.
DisposeUnmanaged()
Releases unmanaged resources
protected override void DisposeUnmanaged()
Empty()
Checks whether the classifier has been loaded.
public virtual bool Empty()
Returns
GetFeatureType()
public int GetFeatureType()
Returns
GetOriginalWindowSize()
public virtual Size GetOriginalWindowSize()
Returns
IsOldFormatCascade()
public bool IsOldFormatCascade()
Returns
Load(string)
Loads a classifier from a file.
public bool Load(string fileName)
Parameters
fileNamestringName of the file from which the classifier is loaded. The file may contain an old HAAR classifier trained by the haartraining application or a new cascade classifier trained by the traincascade application.
Returns
Read(FileNode)
Reads a classifier parameters from a file storage
public virtual bool Read(FileNode fn)
Parameters
fnFileNode