資源簡介
基于VC++實現的人臉檢測,運用adaboost 算法實現的

代碼片段和文件信息
#include?“cv.h“
#include?“highgui.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#ifdef?_EiC
#define?WIN32
#endif
static?CvMemStorage*?storage?=?0;
static?CvHaarClassifierCascade*?cascade?=?0;
void?detect_and_draw(?IplImage*?image?);
const?char*?cascade_name?=
????“haarcascade_frontalface_alt.xml“;
/*????“haarcascade_profileface.xml“;*/
int?main(?int?argc?char**?argv?)
{
????CvCapture*?capture?=?0;
????IplImage?*frame?*frame_copy?=?0;
????int?optlen?=?strlen(“--cascade=“);
????const?char*?input_name;
????if(?argc?>?1?&&?strncmp(?argv[1]?“--cascade=“?optlen?)?==?0?)
????{
????????cascade_name?=?argv[1]?+?optlen;
????????input_name?=?argc?>?2???argv[2]?:?0;
????}
????else
????{
????????cascade_name?=?“C:\\Program?Files\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt2.xml“;
????????input_name?=?argc?>?1???argv[1]:0;
????}
????cascade?=?(CvHaarClassifierCascade*)cvLoad(?cascade_name?0?0?0?);
????if(?!cascade?)
????{
????????fprintf(?stderr?“ERROR:?Could?not?load?classifier?cascade\n“?);
????????fprintf(?stderr
????????“Usage:?facedetect?--cascade=\“\“?[filename|camera_index]\n“?);
????????return?-1;
????}
????storage?=?cvCreateMemStorage(0);
????if(?!input_name?||?(isdigit(input_name[0])?&&?input_name[1]?==?‘\0‘)?)
????????capture?=?cvCaptureFromCAM(?!input_name???0?:?input_name[0]?-?‘0‘?);
????else
????????capture?=?cvCaptureFromAVI(?input_name?);?
????cvNamedWindow(?“result“?1?);
????if(?capture?)
????{
????????for(;;)
????????{
????????????if(?!cvGrabframe(?capture?))
????????????????break;
????????????frame?=?cvRetrieveframe(?capture?);
????????????if(?!frame?)
????????????????break;
????????????if(?!frame_copy?)
????????????????frame_copy?=?cvCreateImage(?cvSize(frame->widthframe->height)
????????????????????????????????????????????IPL_DEPTH_8U?frame->nChannels?);
????????????if(?frame->origin?==?IPL_ORIGIN_TL?)
????????????????cvCopy(?frame?frame_copy?0?);
????????????else
????????????????cvFlip(?frame?frame_copy?0?);
????????????detect_and_draw(?frame_copy?);
????????????if(?cvWaitKey(?10?)?>=?0?)
????????????????break;
????????}
????????cvReleaseImage(?&frame_copy?);
????????cvReleaseCapture(?&capture?);
????}
????else
????{
????????const?char*?filename?=?input_name???input_name?:?(char*)“lena.jpg“;
????????IplImage*?image?=?cvLoadImage(?filename?1?);
????????if(?image?)
????????{
????????????detect_and_draw(?image?);
????????????cvWaitKey(0);
????????????cvReleaseImage(?&image?);
????????}
????????else
????????{
????????????/*?assume?it?is?a?text?file?containing?the
???????????????list?of?the?image?filenames?to?be?processed?-?one?per?line?*/
????????????FILE*?f?=?fopen(?filename?“rt“?);
????????????if(?f?)
????????????{
????????????????char?buf[1000+1];
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????875??2011-03-23?19:50??123\123.sln
????..A..H.??????7168??2011-03-23?20:02??123\123.suo
?????文件????????531??2011-03-24?18:56??123\123.dsw
?????文件??????41984??2011-04-26?08:37??123\123.ncb
?????文件????????823??2011-04-26?08:37??123\123.plg
?????文件???????4181??2011-03-24?19:33??123\123.dsp
?????文件?????102400??2011-04-26?08:37??123\123___Win32_Debug\vc60.pdb
?????文件?????508928??2011-04-26?08:37??123\123___Win32_Debug\123.pdb
?????文件?????208987??2011-04-26?08:37??123\123___Win32_Debug\123.exe
?????文件?????156672??2011-04-26?08:37??123\123___Win32_Debug\vc60.idb
?????文件????4133676??2011-04-26?08:37??123\123___Win32_Debug\123.pch
?????文件??????22732??2011-04-26?08:37??123\123___Win32_Debug\58.obj
?????文件?????234952??2011-04-26?08:37??123\123___Win32_Debug\123.ilk
?????文件??????29696??2011-03-23?19:51??123\Debug\123.exe
?????文件?????437248??2011-03-23?19:51??123\Debug\123.pdb
?????文件?????861012??2005-03-16?19:18??123\Debug\haarcascade_frontalface_alt2.xm
?????文件?????102400??2011-03-24?21:48??123\Debug\vc60.pdb
?????文件??????22631??2011-03-24?22:03??123\Debug\58.obj
?????文件??????25600??2011-04-04?19:42??123\Debug\58.pdb
?????文件???????4641??2011-03-23?20:01??123\123\123.vcproj
?????文件???????1159??2011-03-23?19:50??123\123\ReadMe.txt
?????文件????????233??2011-03-23?19:50??123\123\stdafx.h
?????文件????????498??2011-03-23?19:50??123\123\targetver.h
?????文件????????208??2011-03-23?19:50??123\123\stdafx.cpp
?????文件???????1427??2011-03-23?20:02??123\123\123.vcproj.PC-20110315JBZO.Administrator.user
?????文件???????5429??2011-03-23?20:02??123\123\123.cpp
?????文件???????3738??2011-03-23?20:02??123\123\Debug\BuildLog.htm
?????文件????????663??2011-03-23?19:51??123\123\Debug\123.exe.em
?????文件?????126976??2011-03-23?20:02??123\123\Debug\vc90.pdb
?????文件??????11437??2011-03-23?19:51??123\123\Debug\stdafx.obj
............此處省略18個文件信息
- 上一篇:KWIC問題C++版
- 下一篇:MFC socket 局域網聊天
評論
共有 條評論