转自:http://sites.google.com/site/opencv123/source_reading/cvfindface、
CvSeq * found = cvFindFace(gray,storage); for(int i = 0; i < (found ? found->total : 0); i++ ) { CvFace* face = (CvFace*)cvGetSeqElem( found, i ); CvRect& rc = face->MouthRect; cvRectangle(gray, cvPoint(rc.x, rc.y), cvPoint(rc.x+rc.width, rc.y+rc.height), CV_RGB(255,255,255)); }
typedef struct CvFace { CvRect MouthRect; CvRect LeftEyeRect; CvRect RightEyeRect; } CvFaceData; CvSeq * cvFindFace(IplImage * Image,CvMemStorage* storage); CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage);
class FaceFeature { FaceFeature(double dWeight,void * lpContour,bool bIsFeature); FaceFeature(); double m_dWeight; void * m_lpContour; bool m_bIsFaceFeature; };
class Face { public: Face(FaceTemplate * lpFaceTemplate); virtual ~Face(); inline bool isFeature(void * lpElem); virtual void Show(IplImage * /*Image*/){}; virtual void ShowIdeal(IplImage* /*Image*/){}; virtual void CreateFace(void * lpData) = 0; virtual bool CheckElem(void * lpCandidat,void * lpIdeal) = 0; virtual double GetWeight() = 0; protected: FaceFeature * m_lpIdealFace;//ideal face definition long m_lFaceFeaturesNumber; //total number of diferent face features long * m_lplFaceFeaturesCount;//number of each features fouded for this face FaceFeature ** m_lppFoundedFaceFeatures;//founded features of curen face double m_dWeight; };