Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //load cascade classifier
- String cascadeName = "haarcascade_profileface.xml";
- cv::CascadeClassifier cascade(cascadeName);
- /* already used this option to load the xml file
- if( !cascade.load( cascadeName ) )
- {
- std::cout << "ERROR: Could not load classifier cascade" << std::endl;
- return -1;
- }*/
- //image from pc
- Mat img = imread("faces.jpg", 1);
- //convert to gray the img
- Mat gray, smallImg(img.rows, img.cols, CV_8UC1 );
- cvtColor( img, gray, CV_BGR2GRAY );
- resize( gray, smallImg, smallImg.size(), 0, 0, INTER_LINEAR );
- equalizeHist( smallImg, smallImg );
- std::vector<Rect> faces;
- cascade.detectMultiScale( smallImg, faces,
- 1.1, 2, 0
- //|CV_HAAR_FIND_BIGGEST_OBJECT
- //|CV_HAAR_DO_ROUGH_SEARCH
- |CV_HAAR_SCALE_IMAGE, Size(30, 30)
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement