반응형

http://docs.opencv.org/trunk/modules/objdetect/doc/cascade_classification.html?highlight=haar

Haar-like Feture

참고문헌

P. Viola and M. Jones, “Robust real-time face detection,” in Proc. 8th IEEE Int. Conf. Comput. Vision, vol. 2, pp. 747, Vancouver, Canada, July 2001.

#include <iostream>

#include "opencv2\highgui\highgui.hpp"
#include "opencv2\imgproc\imgproc.hpp"
#include "opencv2\core\core.hpp"
#include "opencv2\objdetect\objdetect.hpp"
#pragma comment(lib,"opencv_core248d.lib")
#pragma comment(lib,"opencv_highgui248d.lib")
#pragma comment(lib,"opencv_imgproc248d.lib")
#pragma comment(lib,"opencv_objdetect248d.lib")

using namespace std;
using namespace cv;

// xml 파일은 opencv 폴더에서 찾아보세요.

const char* classifier = "d:\\haar\\haarcascade_frontalface_alt.xml";

int main()
{
    Mat image = imread("조석.jpg", 1);

CascadeClassifier cascade;
vector<Rect> faces;

if (0 == cascade.load(classifier))
{
    cout << "Error CascadeClassifier load" << endl;
    exit(0);
}

cascade.detectMultiScale(image, faces, 1.2, 3, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));

for (size_t i = 0; i < faces.size(); i++)
{
    rectangle(image, faces[i], Scalar(255, 255, 255), 2, 8, 0);
}

imshow("window",image);
waitKey(0);

return 0;

}

xml 은 opencv 폴더에 있습니다.

얼굴 외에도 눈 코 입 등등..

자세한 설명은 기회가 되면 하도록 하겠습니다.

예제를 잘 활용하시길 바래요

http://docs.opencv.org/trunk/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html#cascade-classifier

반응형
Posted by kev1n
,