Created
January 15, 2013 09:36
-
-
Save thorikawa/4537526 to your computer and use it in GitHub Desktop.
Simple example for CascadeClassifier.detectMultiScale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/opencv.hpp> | |
#include <vector> | |
using namespace cv; | |
using namespace std; | |
int main () { | |
Mat img = imread("lena.jpg"); | |
CascadeClassifier cascade; | |
if (cascade.load("haarcascade_frontalface_alt.xml")) { | |
vector<Rect> faces; | |
//cascade.detectMultiScale(img, faces, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING, Size(30, 30), Size(200, 200)); | |
cascade.detectMultiScale(img, faces, 1.1, 3, CV_HAAR_FIND_BIGGEST_OBJECT, Size(30, 30), Size(200,200)); | |
printf("%zd face(s) are found.\n", faces.size()); | |
for (int i = 0; i < faces.size(); i++) { | |
Rect r = faces[i]; | |
printf("a face is found at Rect(%d,%d,%d,%d).\n", r.x, r.y, r.width, r.height); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment