PageRenderTime 65ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/libfaces/face/facedetect.cpp

https://github.com/usmanghani/Misc
C++ | 39 lines | 23 code | 12 blank | 4 comment | 4 complexity | 8ae45fe2f7f8a135be087830af5884fe MD5 | raw file
  1. #include "stdafx.h"
  2. #include "facedetect.h"
  3. vector<RECT> facedetect (IplImage* image, CvHaarClassifierCascade* cascade)
  4. {
  5. //CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*)cvLoad(classifierfilename);
  6. //IplImage* image = cvLoadImage(imagefilename);
  7. CvMemStorage* storage = cvCreateMemStorage ( );
  8. vector<RECT> list;
  9. if( cascade && image && storage )
  10. {
  11. CvSeq* faces = cvHaarDetectObjects( image, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(40, 40) );
  12. for( int i = 0; i < (faces ? faces->total : 0); i++ )
  13. {
  14. CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
  15. RECT rect ;
  16. rect.left = r->x;
  17. rect.right = r->x + r->width;
  18. rect.top = r->y;
  19. rect.bottom = r->y + r->height;
  20. list.push_back(rect);
  21. }
  22. }
  23. cvReleaseMemStorage(&storage);
  24. //cvReleaseImage(&image);
  25. //cvReleaseHaarClassifierCascade(&cascade);
  26. return list;
  27. }