Auxilliary Tool:
A specific object detector that uses OpenCV's Haar Cascade Classifier to detect objects. The performance / behavior of the object detector is stored in an XML file, which is passed in in the constructor. The XML file provided in the data directory may be used for finding faces, or you can use OpenCV to train your own.
More...
#include <OpenCVHaarDetector.h>
Public Member Functions | |
OpenCVHaarDetector () | |
Placeholder Constructor. | |
OpenCVHaarDetector (const char *filename) | |
Constructor. | |
OpenCVHaarDetector (OpenCVHaarDetector *detectorToCopy) | |
Deep Copy Constructor: Create a Haar detector that is identical to the one copied. | |
~OpenCVHaarDetector () | |
Default Destructor. | |
std::vector< cv::Rect > | detectObjects (IplImage *image) |
Virtual Method for overridden from parent class (ObjectDetector). Applies the cvHaarDetectObjects() method to the provided image patch. | |
void | setHaarCascadeScaleFactor (double factor) |
Sets the factor by which the image-patch-search-scale is increased. Should be greater than 1. By default, the scale factor is 1.1, meaning that faces are searched for at sizes that increase by 10%. | |
void | setHaarCascadeMinSize (int size) |
Sets the minimum patch size at which the classifier searches for the object. By default, this is 0, meaning that the smallest size appropriate to XML file is used. In the case of the frontal face detector provided, this happens to be 20x20 pixels. | |
void | setDetectorSource (std::string newFileName) |
Change the file used by the object detector for doing detecting. This is critical if a weights file is located at an absolute path that may have changed from training time. | |
Protected Member Functions | |
void | readFromStream (std::istream &in) |
Virtual Method for inheriting classes to override: An object detector should be able to read in its properties from a file, and reinitialize itself appropriately. | |
void | addToStream (std::ostream &out) |
Virtual Method for inheriting classes to override: An object detector should be able to serialize itself to be saved in a file. |
Auxilliary Tool:
A specific object detector that uses OpenCV's Haar Cascade Classifier to detect objects. The performance / behavior of the object detector is stored in an XML file, which is passed in in the constructor. The XML file provided in the data directory may be used for finding faces, or you can use OpenCV to train your own.
OpenCVHaarDetector::OpenCVHaarDetector | ( | ) |
Placeholder Constructor.
Used to create a placeholder for an object detector, which can then be read from a file stream using the >> operator. Typical usage for this constructor is:
detector = new OpenCVHaarDetector();
in >> detector;
OpenCVHaarDetector::OpenCVHaarDetector | ( | const char * | filename ) |
Constructor.
Used to create an object detector out of a previously stored XML file.
filename | The name of the XML file that contains all of the features / weights / etc. needed by the Haar Cascaded Object Detector. The provided file, "data/haarcascade_frontalface_alt2.xml" is distributed with OpenCV. OpenCV can be used to train detectors of objects other than frontal faces. |
OpenCVHaarDetector::~OpenCVHaarDetector | ( | ) |
Default Destructor.
Deallocates all memory associated with the haar detector.
vector< Rect > OpenCVHaarDetector::detectObjects | ( | IplImage * | image ) | [virtual] |
Virtual Method for overridden from parent class (ObjectDetector). Applies the cvHaarDetectObjects() method to the provided image patch.
image | The image to be searched for some target object. |
Implements ObjectDetector.
void OpenCVHaarDetector::setDetectorSource | ( | std::string | newFileName ) | [virtual] |
Change the file used by the object detector for doing detecting. This is critical if a weights file is located at an absolute path that may have changed from training time.
When an ObjectDetector is loaded from disk, it will try to reload its weights file from the same source used in training. If this fails, a warning will be printed, and the detector's source will need to be set.
Implements ObjectDetector.
void OpenCVHaarDetector::setHaarCascadeMinSize | ( | int | size ) |
Sets the minimum patch size at which the classifier searches for the object. By default, this is 0, meaning that the smallest size appropriate to XML file is used. In the case of the frontal face detector provided, this happens to be 20x20 pixels.
size | The width/height of the smallest patches to try to detect the object. |
void OpenCVHaarDetector::setHaarCascadeScaleFactor | ( | double | factor ) |
Sets the factor by which the image-patch-search-scale is increased. Should be greater than 1. By default, the scale factor is 1.1, meaning that faces are searched for at sizes that increase by 10%.
factor | The size-granularity of object search. |