• 大小: 17.52MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-31
  • 语言: 其他
  • 标签: 人脸识别  opencv  

资源简介

opencv实现的人脸检测,其中包括面部,眼睛,嘴巴,鼻子(需要修改分类器名称,分类器已全部包含在工程中)

资源截图

代码片段和文件信息

#include “cv.h“  
#include “highgui.h“  
#include   
  
void displaydetection(IplImage* pInpImgCvSeq* pFaceRectSeqchar* FileName);  
  
int main(int argcchar** argv)  
{  
    IplImage* pInpImg=0;  
    CvHaarClassifierCascade* pCascade=0;        //指向后面从文件中获取的分类器  
    CvMemStorage* pStorage=0;                   //存储检测到的人脸数据  
    CvSeq* pFaceRectSeq;                        //用来接收检测函数返回的一系列的包含人脸的矩形区域  
      
 ///*   if (argc<2)  
 //   {  
 //       printf(“missing name of image file!\n“);  
 //       return -1;  
 //   }  */
  
    //初始化  
//    pInpImg=cvLoadImage(argv[1]1);   
pInpImg=cvLoadImage(“1.jpg“1);
    pStorage=cvCreateMemStorage(0);             //创建默认大先64k的动态内存区域  
    pCascade=(CvHaarClassifierCascade*)cvLoad(“haarcascade_frontalface_alt_tree.xml“);       //加载分类器  
  
    if (!pInpImg||!pStorage||!pCascade)  
    {  
        printf(“initialization failed:%s\n“(!pInpImg)?“can‘t load image file“:(!pCascade)?“can‘t load haar-cascade---make sure path is correct“:“unable to allocate memory for data storage“argv[1]);  
        return -1;  
    }  
    //人脸检测  
    pFaceRectSeq=cvHaarDetectobjects(pInpImgpCascadepStorage  
        1.22CV_HAAR_DO_CANNY_PRUNINGcvSize(4040));  
    //将检测到的人脸以矩形框标出。  
    displaydetection(pInpImgpFaceRectSeqargv[1]);  
  
    cvReleaseImage(&pInpImg);  
    cvReleaseHaarClassifierCascade(&pCascade);  
    cvReleaseMemStorage(&pStorage);  
    return 0;  
}  
void displaydetection(IplImage* pInpImgCvSeq* pFaceRectSeqchar* FileName)  
{  
    int i;  
    cvNamedWindow(“haar window“1);  
    printf(“the number of face is %d\n“pFaceRectSeq->total);  
    for (i=0;i<(pFaceRectSeq?pFaceRectSeq->total:0);i++)  
    {  
        CvRect* r=(CvRect*)cvGetSeqElem(pFaceRectSeqi);  
        CvPoint pt1={r->xr->y};  
        CvPoint pt2={r->x+r->widthr->y+r->height};  
printf(“x = %d y = %d width = %d heigth = %d\n“ r->xr->yr->widthr->height);  
//      cvSetImageROI(pInpImg*r);  
//      IplImage* dst=cvCreateImage(cvSize(92112)pInpImg->depthpInpImg->nChannels);  
//      cvResize(pInpImgdstCV_INTER_LINEAR);  
//      cvSaveImage(“lian.jpg“dst);  
        cvRectangle(pInpImgpt1pt2CV_RGB(02550)340);  
    }  
    cvShowImage(“haar window“pInpImg);  
//  cvResetImageROI(pInpImg);  
    cvWaitKey(0);  
    cvDestroyWindow(“haar window“);  
}  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-10 10:22  OpenCv-人脸识别\
     目录           0  2018-01-10 10:16  OpenCv-人脸识别\Debug\
     文件       90270  2018-01-10 10:16  OpenCv-人脸识别\Debug\1.jpg
     文件       28672  2016-08-06 20:30  OpenCv-人脸识别\Debug\OpenCv.exe
     文件      316432  2016-08-06 20:30  OpenCv-人脸识别\Debug\OpenCv.ilk
     文件      461824  2016-08-06 20:30  OpenCv-人脸识别\Debug\OpenCv.pdb
     目录           0  2018-01-10 10:19  OpenCv-人脸识别\OpenCv\
     文件       90270  2018-01-10 10:16  OpenCv-人脸识别\OpenCv\1.jpg
     目录           0  2018-01-10 10:18  OpenCv-人脸识别\OpenCv\Debug\
     文件       90270  2018-01-10 10:16  OpenCv-人脸识别\OpenCv\Debug\1.jpg
     文件       15224  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\CL.read.1.tlog
     文件         610  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\CL.write.1.tlog
     文件         406  2016-08-06 20:27  OpenCv-人脸识别\OpenCv\Debug\OpenCv.exe.embed.manifest
     文件         472  2016-08-06 20:27  OpenCv-人脸识别\OpenCv\Debug\OpenCv.exe.embed.manifest.res
     文件         381  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\OpenCv.exe.intermediate.manifest
     文件          47  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\OpenCv.lastbuildstate
     文件        2260  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\OpenCv.log
     文件       25709  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\OpenCv.obj
     文件         713  2016-08-06 20:17  OpenCv-人脸识别\OpenCv\Debug\OpenCv.vcxprojResolveAssemblyReference.cache
     文件           0  2016-08-06 20:17  OpenCv-人脸识别\OpenCv\Debug\OpenCv.write.1.tlog
     文件         202  2016-08-06 20:27  OpenCv-人脸识别\OpenCv\Debug\OpenCv_manifest.rc
     文件        1114  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\cl.command.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link-cvtres.read.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link-cvtres.write.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.5064-cvtres.read.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.5064-cvtres.write.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.5064.read.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.5064.write.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.7468-cvtres.read.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.7468-cvtres.write.1.tlog
     文件           2  2016-08-06 20:30  OpenCv-人脸识别\OpenCv\Debug\link.7468.read.1.tlog
............此处省略95个文件信息

评论

共有 条评论