Advertisement
Guest User

Untitled

a guest
May 27th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. //load cascade classifier
  2. String cascadeName = "haarcascade_profileface.xml";
  3. cv::CascadeClassifier cascade(cascadeName);
  4.  
  5. /* already used this option to load the xml file
  6. if( !cascade.load( cascadeName ) )
  7. {
  8.      std::cout << "ERROR: Could not load classifier cascade" << std::endl;
  9.     return -1;
  10. }*/
  11.  
  12. //image from pc
  13. Mat img = imread("faces.jpg", 1);
  14.  
  15. //convert to gray the img
  16. Mat gray, smallImg(img.rows, img.cols, CV_8UC1 );
  17. cvtColor( img, gray, CV_BGR2GRAY );
  18. resize( gray, smallImg, smallImg.size(), 0, 0, INTER_LINEAR );
  19. equalizeHist( smallImg, smallImg );
  20.  
  21. std::vector<Rect> faces;
  22. cascade.detectMultiScale( smallImg, faces,
  23.     1.1, 2, 0
  24.     //|CV_HAAR_FIND_BIGGEST_OBJECT
  25.     //|CV_HAAR_DO_ROUGH_SEARCH
  26.     |CV_HAAR_SCALE_IMAGE, Size(30, 30)
  27.      );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement