OpenCV  3.0.0-rc1
Open Source Computer Vision
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cv::CascadeClassifier Class Reference

Cascade classifier class for object detection. More...

#include "objdetect.hpp"

Public Member Functions

 CascadeClassifier ()
 
 CascadeClassifier (const String &filename)
 Loads a classifier from a file. More...
 
 ~CascadeClassifier ()
 
void detectMultiScale (InputArray image, std::vector< Rect > &objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size())
 Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles. More...
 
void detectMultiScale (InputArray image, std::vector< Rect > &objects, std::vector< int > &numDetections, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size())
 
void detectMultiScale (InputArray image, std::vector< Rect > &objects, std::vector< int > &rejectLevels, std::vector< double > &levelWeights, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size(), bool outputRejectLevels=false)
 
bool empty () const
 Checks whether the classifier has been loaded. More...
 
int getFeatureType () const
 
Ptr
< BaseCascadeClassifier::MaskGenerator
getMaskGenerator ()
 
void * getOldCascade ()
 
Size getOriginalWindowSize () const
 
bool isOldFormatCascade () const
 
bool load (const String &filename)
 Loads a classifier from a file. More...
 
bool read (const FileNode &node)
 Reads a classifier from a FileStorage node. More...
 
void setMaskGenerator (const Ptr< BaseCascadeClassifier::MaskGenerator > &maskGenerator)
 

Static Public Member Functions

static bool convert (const String &oldcascade, const String &newcascade)
 

Public Attributes

Ptr< BaseCascadeClassifiercc
 

Detailed Description

Cascade classifier class for object detection.

Constructor & Destructor Documentation

cv::CascadeClassifier::CascadeClassifier ( )
cv::CascadeClassifier::CascadeClassifier ( const String filename)

Loads a classifier from a file.

Parameters
filenameName of the file from which the classifier is loaded.
cv::CascadeClassifier::~CascadeClassifier ( )

Member Function Documentation

static bool cv::CascadeClassifier::convert ( const String oldcascade,
const String newcascade 
)
static
void cv::CascadeClassifier::detectMultiScale ( InputArray  image,
std::vector< Rect > &  objects,
double  scaleFactor = 1.1,
int  minNeighbors = 3,
int  flags = 0,
Size  minSize = Size(),
Size  maxSize = Size() 
)

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

Parameters
imageMatrix of the type CV_8U containing an image where objects are detected.
objectsVector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
scaleFactorParameter specifying how much the image size is reduced at each image scale.
minNeighborsParameter specifying how many neighbors each candidate rectangle should have to retain it.
flagsParameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSizeMinimum possible object size. Objects smaller than that are ignored.
maxSizeMaximum possible object size. Objects larger than that are ignored.

The function is parallelized with the TBB library.

Note
  • (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python2/facedetect.py
void cv::CascadeClassifier::detectMultiScale ( InputArray  image,
std::vector< Rect > &  objects,
std::vector< int > &  numDetections,
double  scaleFactor = 1.1,
int  minNeighbors = 3,
int  flags = 0,
Size  minSize = Size(),
Size  maxSize = Size() 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
imageMatrix of the type CV_8U containing an image where objects are detected.
objectsVector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
numDetectionsVector 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 to form the object.
scaleFactorParameter specifying how much the image size is reduced at each image scale.
minNeighborsParameter specifying how many neighbors each candidate rectangle should have to retain it.
flagsParameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSizeMinimum possible object size. Objects smaller than that are ignored.
maxSizeMaximum possible object size. Objects larger than that are ignored.
void cv::CascadeClassifier::detectMultiScale ( InputArray  image,
std::vector< Rect > &  objects,
std::vector< int > &  rejectLevels,
std::vector< double > &  levelWeights,
double  scaleFactor = 1.1,
int  minNeighbors = 3,
int  flags = 0,
Size  minSize = Size(),
Size  maxSize = Size(),
bool  outputRejectLevels = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. if outputRejectLevels is true returns rejectLevels and levelWeights

bool cv::CascadeClassifier::empty ( ) const

Checks whether the classifier has been loaded.

int cv::CascadeClassifier::getFeatureType ( ) const
Ptr<BaseCascadeClassifier::MaskGenerator> cv::CascadeClassifier::getMaskGenerator ( )
void* cv::CascadeClassifier::getOldCascade ( )
Size cv::CascadeClassifier::getOriginalWindowSize ( ) const
bool cv::CascadeClassifier::isOldFormatCascade ( ) const
bool cv::CascadeClassifier::load ( const String filename)

Loads a classifier from a file.

Parameters
filenameName 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.
bool cv::CascadeClassifier::read ( const FileNode node)

Reads a classifier from a FileStorage node.

Note
The file may contain a new cascade classifier (trained traincascade application) only.
void cv::CascadeClassifier::setMaskGenerator ( const Ptr< BaseCascadeClassifier::MaskGenerator > &  maskGenerator)

Member Data Documentation

Ptr<BaseCascadeClassifier> cv::CascadeClassifier::cc

The documentation for this class was generated from the following file: