Cascade Classifier
API reference for cascade-based object detection and HOG descriptor computation.CascadeClassifier
Cascade classifier class for object detection using Haar or LBP features.Constructor
Path to the classifier file (e.g., haarcascade_frontalface_default.xml)
Methods
load
Loads a classifier from a file.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.
true if the classifier was loaded successfully
detectMultiScale
Detects objects of different sizes in the input image.Matrix of type CV_8U containing an image where objects are detected
Output vector of rectangles where each rectangle contains a detected object
Parameter specifying how much the image size is reduced at each image scale
Parameter specifying how many neighbors each candidate rectangle should have to retain it
Parameter with the same meaning for an old cascade as in cvHaarDetectObjects. Not used for new cascades.
Minimum possible object size. Objects smaller than this are ignored.
Maximum possible object size. Objects larger than this are ignored. If maxSize == minSize, model is evaluated on single scale.
The function does not correct lens distortion. If camera parameters are known, it’s recommended to undistort the input image first.
detectMultiScale (with detection counts)
Vector of detection numbers for the corresponding objects. An object’s number of detections is the number of neighboring positively classified rectangles that were joined together.
detectMultiScale (with confidence levels)
Output vector of reject levels for each detection
Output vector containing the certainty of classification at the final stage for each detection
Set to true to retrieve the final stage decision certainty of classification
empty
Checks whether the classifier has been loaded.true if the classifier is empty
Example Usage
- C++
- Python
HOGDescriptor
Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. Based on the algorithm introduced by Navneet Dalal and Bill Triggs.Constructor
Detection window size. Default is Size(64, 128). Must align to block size and block stride.
Block size in pixels. Default is Size(16, 16). Must align to cell size.
Block stride. Default is Size(8, 8). Must be a multiple of cell size.
Cell size. Default is Size(8, 8).
Number of bins used in the calculation of histogram of gradients. Default is 9.
File name containing HOGDescriptor properties and coefficients for the linear SVM classifier
Methods
compute
Computes HOG descriptors of given image.Matrix of type CV_8U containing an image where HOG features will be calculated
Output matrix of type CV_32F containing computed descriptors
Window stride. Must be a multiple of block stride.
Padding around the image
Vector of specific locations to compute descriptors at
detect
Performs object detection without a multi-scale window.Matrix of type CV_8U or CV_8UC3 containing an image where objects are detected
Vector of points where each point contains left-top corner of detected object boundaries
Vector that will contain confidence values for each detected object
Threshold for the distance between features and SVM classifying plane
Window stride. Must be a multiple of block stride.
Padding around the image
Vector of specific locations to search
detectMultiScale
Detects objects of different sizes in the input image.Matrix of type CV_8U or CV_8UC3 containing an image where objects are detected
Vector of rectangles where each rectangle contains the detected object
Vector that will contain confidence values for each detected object
Coefficient of the detection window increase
Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping.
Indicates whether to use meanshift grouping algorithm
setSVMDetector
Sets coefficients for the linear SVM classifier.Coefficients for the linear SVM classifier
getDefaultPeopleDetector
Returns coefficients of the classifier trained for people detection (for 64x128 windows).getDaimlerPeopleDetector
Returns coefficients of the classifier trained for people detection (for 48x96 windows).Properties
winSize(Size): Detection window size. Default Size(64, 128).blockSize(Size): Block size in pixels. Default Size(16, 16).blockStride(Size): Block stride. Default Size(8, 8).cellSize(Size): Cell size. Default Size(8, 8).nbins(int): Number of bins. Default 9.derivAperture(int): Derivative aperture.winSigma(double): Gaussian smoothing window parameter.histogramNormType(HistogramNormType): Histogram normalization type.L2HysThreshold(double): L2-Hys normalization method shrinkage.gammaCorrection(bool): Flag to specify gamma correction preprocessing.svmDetector(std::vector<float>): Coefficients for the linear SVM classifier.nlevels(int): Maximum number of detection window increases. Default 64.signedGradient(bool): Indicates whether signed gradient will be used.
Example Usage
- C++
- Python
