Class CascadeClassifier
Cascade classifier class for object detection.
Implements
Inherited Members
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class CascadeClassifier : DisposableCvObject, ICvPtrHolder
Constructors
| Improve this Doc View SourceCascadeClassifier()
Default constructor
Declaration
public CascadeClassifier()
CascadeClassifier(String)
Loads a classifier from a file.
Declaration
public CascadeClassifier(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the file from which the classifier is loaded. |
Methods
| Improve this Doc View SourceDetectMultiScale(Mat, Double, Int32, HaarDetectionTypes, Nullable<Size>, Nullable<Size>)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
Declaration
public virtual Rect[] DetectMultiScale(Mat image, double scaleFactor = 1.1, int minNeighbors = 3, HaarDetectionTypes flags = (HaarDetectionTypes)0, Size? minSize = null, Size? maxSize = null)
Parameters
Type | Name | Description |
---|---|---|
Mat | image | Matrix of the type CV_8U containing an image where objects are detected. |
System.Double | scaleFactor | Parameter specifying how much the image size is reduced at each image scale. |
System.Int32 | minNeighbors | Parameter specifying how many neighbors each candidate rectangle should have to retain it. |
HaarDetectionTypes | flags | Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade. |
System.Nullable<OpenCvSharp.Size> | minSize | Minimum possible object size. Objects smaller than that are ignored. |
System.Nullable<OpenCvSharp.Size> | maxSize | Maximum possible object size. Objects larger than that are ignored. |
Returns
Type | Description |
---|---|
OpenCvSharp.Rect[] | Vector of rectangles where each rectangle contains the detected object. |
DetectMultiScale(Mat, out Int32[], out Double[], Double, Int32, HaarDetectionTypes, Nullable<Size>, Nullable<Size>, Boolean)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
Declaration
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
Type | Name | Description |
---|---|---|
Mat | image | Matrix of the type CV_8U containing an image where objects are detected. |
System.Int32[] | rejectLevels | |
System.Double[] | levelWeights | |
System.Double | scaleFactor | Parameter specifying how much the image size is reduced at each image scale. |
System.Int32 | minNeighbors | Parameter specifying how many neighbors each candidate rectangle should have to retain it. |
HaarDetectionTypes | flags | Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade. |
System.Nullable<OpenCvSharp.Size> | minSize | Minimum possible object size. Objects smaller than that are ignored. |
System.Nullable<OpenCvSharp.Size> | maxSize | Maximum possible object size. Objects larger than that are ignored. |
System.Boolean | outputRejectLevels |
Returns
Type | Description |
---|---|
OpenCvSharp.Rect[] | Vector of rectangles where each rectangle contains the detected object. |
DisposeUnmanaged()
Releases unmanaged resources
Declaration
protected override void DisposeUnmanaged()
Overrides
| Improve this Doc View SourceEmpty()
Checks whether the classifier has been loaded.
Declaration
public virtual bool Empty()
Returns
Type | Description |
---|---|
System.Boolean |
GetFeatureType()
Declaration
public int GetFeatureType()
Returns
Type | Description |
---|---|
System.Int32 |
GetOriginalWindowSize()
Declaration
public virtual Size GetOriginalWindowSize()
Returns
Type | Description |
---|---|
OpenCvSharp.Size |
IsOldFormatCascade()
Declaration
public bool IsOldFormatCascade()
Returns
Type | Description |
---|---|
System.Boolean |
Load(String)
Loads a classifier from a file.
Declaration
public bool Load(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name 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
Type | Description |
---|---|
System.Boolean |
Read(FileNode)
Reads a classifier parameters from a file storage
Declaration
public virtual bool Read(FileNode fn)
Parameters
Type | Name | Description |
---|---|---|
FileNode | fn |
Returns
Type | Description |
---|---|
System.Boolean |