class methods
- ofxCvHaarFinder()
- ~ofxCvHaarFinder()
- draw()
- findHaarObjects()
- getHeight()
- getWidth()
- setNeighbors()
- setScaleHaar()
- setup()
variables
ofxCvHaarFinder allows you to check an image for a match to a Haar classifier. The Haar Classifier is a data file generated from a training process where an application is "taught" how to recognize something in different contexts. This can be things like recognizing whether a certain sound is a word being spoken by a user, whether a gesture is a certain shape, or, in the image shown below, whether a pattern of pixels constitute a face.
A very basic set-up of an application using ofxCvHaarFinder would look like so:
app::setup() {
haarFinder.setup("haarcascade.xml"); // must be in /data/
}
app::update() {
haarFinder.findHaarObjects(imageToExamine);
}
app::draw() {
for(int i = 0; i < haarFinder.blobs.size(); i++) {
ofDrawRectangle( haarFinder.blobs[i].boundingRect );
}
}
ofxCvHaarFinder(...)
ofxCvHaarFinder::ofxCvHaarFinder(const ofxCvHaarFinder &finder)
Copy constructor.
draw(...)
void ofxCvHaarFinder::draw(float x, float y)
Draws any detected objects to the screen with a rectangle, like so:
findHaarObjects(...)
int ofxCvHaarFinder::findHaarObjects(const ofxCvGrayscaleImage &, int x, int y, int w, int h, int minWidth=0, int minHeight=0)
Takes an input ofxCvGrayscaleImage object and allows you to set the minimum width and height of areas that should be returned and a region of interest as an ofRectangle that you would like to limit haar finding to.
findHaarObjects(...)
int ofxCvHaarFinder::findHaarObjects(const ofxCvGrayscaleImage &input, int minWidth=0, int minHeight=0)
Takes an input ofxCvGrayscaleImage object and allows you to set the minimum width and height of areas that should be returned.
findHaarObjects(...)
int ofxCvHaarFinder::findHaarObjects(const ofxCvGrayscaleImage &input, ofRectangle &roi, int minWidth=0, int minHeight=0)
Takes an input ofxCvGrayscaleImage object and allows you to set the minimum width and height of areas that should be returned and a region of interest as an ofRectangle that you would like to limit haar finding to.
colorImg.setFromPixels(vidGrabber.getPixels());
grayImage = colorImg; // convert our color image to a grayscale image
faceFinder.findHaarObjects(grayImage);
for(int i = 0; i < faceFinder.blobs.size(); i++) {
ofRectangle roi = faceFinder.blobs[i].boundingRect;
eyeFinder.findHaarObjects(grayImage, roi);
}
findHaarObjects(...)
int ofxCvHaarFinder::findHaarObjects(ofImage &input, int minWidth=0, int minHeight=0)
Takes an input ofImage object and allows you to set the minimum width and height of areas that should be returned.
camera.grabFrame();
if(camera.isFrameNew())
{
img.setFromPixels(grab.getPixels());
finder.findHaarObjects(img);
}
findHaarObjects(...)
int ofxCvHaarFinder::findHaarObjects(ofPixels &input, int minWidth=0, int minHeight=0)
Takes an input ofPixels object and allows you to set the minimum width and height of areas that should be returned.
getHeight()
float ofxCvHaarFinder::getHeight()
Returns the height of the image area that is being examined.
getWidth()
float ofxCvHaarFinder::getWidth()
Returns the width of the image area that is being examined.
setNeighbors(...)
void ofxCvHaarFinder::setNeighbors(unsigned int neighbors)
Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, that might be useful if you want to do a customized grouping.
setup(...)
void ofxCvHaarFinder::setup(string haarFile)
This loads a Haar cascade file into the finder. This needs to be done before the Haar finder can be used with images.
ofxCvBlob blobs
ofxCvBlob ofxCvHaarFinder::blobs
Last updated 星期六, 17 八月 2024 20:45:50 UTC - 99bfb4fd7929e233b87b05758efc36f91505592e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue