Table of Contents

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

fileName string

Name 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

image Mat

Matrix of the type CV_8U containing an image where objects are detected.

scaleFactor double

Parameter specifying how much the image size is reduced at each image scale.

minNeighbors int

Parameter specifying how many neighbors each candidate rectangle should have to retain it.

flags HaarDetectionTypes

Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

minSize Size?

Minimum possible object size. Objects smaller than that are ignored.

maxSize Size?

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

image Mat

Matrix of the type CV_8U containing an image where objects are detected.

rejectLevels int[]
levelWeights double[]
scaleFactor double

Parameter specifying how much the image size is reduced at each image scale.

minNeighbors int

Parameter specifying how many neighbors each candidate rectangle should have to retain it.

flags HaarDetectionTypes

Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

minSize Size?

Minimum possible object size. Objects smaller than that are ignored.

maxSize Size?

Maximum possible object size. Objects larger than that are ignored.

outputRejectLevels bool

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

bool

GetFeatureType()

public int GetFeatureType()

Returns

int

GetOriginalWindowSize()

public virtual Size GetOriginalWindowSize()

Returns

Size

IsOldFormatCascade()

public bool IsOldFormatCascade()

Returns

bool

Load(string)

Loads a classifier from a file.

public bool Load(string fileName)

Parameters

fileName string

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

bool

Read(FileNode)

Reads a classifier parameters from a file storage

public virtual bool Read(FileNode fn)

Parameters

fn FileNode

Returns

bool