cvFindFace

转自:http://sites.google.com/site/opencv123/source_reading/cvfindface、

 

很明显cvFindFace是用于找脸的函数,
涉及到的文件有
src/cvaux/_cvfacedetection.h
src/cvaux/cvfindface.cpp

调用方法,初始化工作略去

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)); } 

这里出现的新面孔有cvFindFace和CvFace,我们分别瞧瞧

在include/opencv/cvaux.h中我们看到

typedef struct CvFace { CvRect MouthRect; CvRect LeftEyeRect; CvRect RightEyeRect; } CvFaceData; CvSeq * cvFindFace(IplImage * Image,CvMemStorage* storage); CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage); 

简单明了
并且cvFindFace还有个实现类似功能的兄弟叫cvPostBoostingFindFace

我们继续探索奥秘,来到了src/cvaux/cvfindface.cpp,发现里头就只有这么两个函数定义

CvSeq * cvFindFace(IplImage * Image,CvMemStorage* lpStorage) { FaceDetection FD; FD.SetBoosting(false); FD.FindFace(Image); CvSeq * lpSeq = cvCreateSeq(0,sizeof(*lpSeq),sizeof(CvFace),lpStorage); FD.CreateResults(lpSeq); return lpSeq; } CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* lpStorage) { FaceDetection FD; FD.SetBoosting(true); FD.FindFace(Image); CvSeq * lpSeq = cvCreateSeq(0,sizeof(*lpSeq),sizeof(CvFace),lpStorage); FD.CreateResults(lpSeq); return lpSeq; } 

哦,原来两兄弟就是这么点差距呀~~
喜悦之余,遇到第二个新面孔,FaceDetection 

再一次回到src/cvaux/_cvfacedetection.h


List 自然是一个链表的数据结构咯,ListElem是链表的每一个node,node里装的是啥呢?
装的是Face

List/ListElem->Face

class FaceFeature { FaceFeature(double dWeight,void * lpContour,bool bIsFeature); FaceFeature(); double m_dWeight; void * m_lpContour; bool m_bIsFaceFeature; }; 



FaceTemplate 
is a list of FaceFeature 
FaceFeature use it to create RFace
-> MouthFaceTemplate
-> BoostingFaceTemplate

Face只是一个接口,真正的实现是RFace

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; }; 


class RFace:public Face { struct FaceData { CvRect LeftEyeRect; CvRect RightEyeRect; CvRect MouthRect; double Error; }; RFace(FaceTemplate * lpFaceTemplate); virtual ~RFace(); virtual bool CheckElem(void * lpCandidat,void * lpIdeal); virtual void CreateFace(void * lpData); virtual void Show(IplImage* Image); virtual void ShowIdeal(IplImage* Image); virtual double GetWeight(); };  

 

你可能感兴趣的:(数据结构,image,struct,Class,化工,features)