📄 人yan检测的c-c++源代码 - hunnish的opencv专栏 - csdnblog.htm
字号:
</SCRIPT>
<DIV id=top>
<DIV>
<TABLE>
<TBODY>
<TR>
<TD class=HeaderTitles>
<H1><A class=headermaintitle id=Header1_HeaderTitle
href="http://blog.csdn.net/hunnish/">HUNNISH的OPENCV专栏</A></H1>
<P id=tagline>OpenCV、计算机视觉、模式识别和图像处理的爱好者</P></TD></TR></TBODY></TABLE></DIV>
<DIV class=HeaderBar>
<TABLE class=HeaderBar id=HeaderBar>
<TBODY>
<TR>
<TD class=HeaderBarTab noWrap> <A href="http://www.csdn.net/"
target=_blank>CSDN</A> | <A href="http://community.csdn.net/"
target=_blank>社区</A> | <A href="http://dev.csdn.net/"
target=_blank>技术中心</A> | <A id=Header1_MyLinks1_HomeLink
title=到聚合站点 href="http://blog.csdn.net/"
target=_blank>BLOG首页</A> | <A id=Header1_MyLinks1_PersonalHome
title="访问 HUNNISH的OPENCV专栏" href="http://blog.csdn.net/hunnish/"
target=_blank>我的首页</A> | <A id=Header1_MyLinks1_PersonalResume
href="http://job.csdn.net/resumes/hunnish.aspx">个人档案</A> | <A
id=Header1_MyLinks1_ContactLink accessKey=9
href="http://blog.csdn.net/hunnish/contact.aspx">联系作者</A> | <A
id=Header1_MyLinks1_Syndication
href="http://blog.csdn.net/hunnish/Rss.aspx">聚合</A> <A class=XMLLink
id=Header1_MyLinks1_XMLLink
href="http://blog.csdn.net/hunnish/Rss.aspx"><IMG
src="人yan检测的C-C++源代码 - HUNNISH的OPENCV专栏 - CSDNBlog.files/xml.gif"
border=0></A> | <A id=Header1_MyLinks1_HyperLink1
href="http://search.csdn.net/search_blog.asp"
target=_blank>搜索</A> | <A id=Header1_MyLinks1_Admin
href="http://writeblog.csdn.net/">登录</A> <IMG id=Header1_BlueTab
src="人yan检测的C-C++源代码 - HUNNISH的OPENCV专栏 - CSDNBlog.files/BlueTabRight.jpg"
align=absMiddle border=0> </TD>
<TD class=HeaderBarTabBack noWrap width="100%">
<DIV class=BlogStatsBar>
<TABLE class=BlogStatsBar>
<TBODY>
<TR>
<TD width="100%"></TD>
<TD class=BlogStatsBar noWrap> 33篇原创: 10篇翻译: 1篇转载: 102966次点击:
0个评论<SPAN style="DISPLAY: none">: 0个Trackbacks</SPAN>
</TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE></DIV></DIV>
<DIV id=leftmenu>
<H3>公告</H3>
<P>欢迎交流 OPENCV 以及计算机视觉、数字图像处理和模式识别等相关技术</P>
<P>网名: Hunnish</P>
<P>QQ: 30168537</P><A title=用狗狗订阅
href="http://www.gougou.com/sub/http://blog.csdn.net/hunnish/rss.aspx"
target=_blank><IMG
src="人yan检测的C-C++源代码 - HUNNISH的OPENCV专栏 - CSDNBlog.files/375618C3346766846DF9E4CFA9659733233A56E4.png"
border=0></A>
<H3 class=listtitle>文章</H3>
<UL class=list>
<LI class=listitem><A
href="http://blog.csdn.net/hunnish/category/59563.aspx">OPENCV</A><A
href="http://blog.csdn.net/hunnish/category/59563.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/hunnish/category/39744.aspx">翻译</A><A
href="http://blog.csdn.net/hunnish/category/39744.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/hunnish/category/59567.aspx">模式识别与图像处理</A><A
href="http://blog.csdn.net/hunnish/category/59567.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/hunnish/category/268014.aspx">人生感言</A><A
href="http://blog.csdn.net/hunnish/category/268014.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/hunnish/category/59566.aspx">数字水印与信息隐藏</A><A
href="http://blog.csdn.net/hunnish/category/59566.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/hunnish/category/59565.aspx">数字印章与加密</A><A
href="http://blog.csdn.net/hunnish/category/59565.aspx/rss">(RSS)</A></LI></UL>
<H3 class=listtitle>收藏</H3>
<UL class=list></UL>
<H3 class=listtitle>相册</H3><!--category title-->
<UL class=list></UL>
<H3 class=listtitle>=我的链接=</H3>
<UL class=list>
<LI class=listitem><A href="http://www.opencv.org.cn/" target=_self>OPENCV
中文网站</A>
<LI class=listitem><A
href="http://www.assuredigit.com/forum/display_forum_topics.asp?ForumID=11"
target=_self>OPENCV 论坛</A>
<LI class=listitem><A href="http://www.dhruvaraj.com/main.htm"
target=_self>一个电子图书站点</A>
<LI class=listitem><A href="http://citeseer.ist.psu.edu/cs"
target=_self>论文搜索网址CITESEER</A>
<LI class=listitem><A href="http://www.assuredigit.com/" target=_self>阿须数码</A>
<LI class=listitem><A href="http://forum.assuredigit.com/"
target=_self>阿须论坛</A></LI></UL>
<H3 class=listtitle>存档</H3>
<UL class=list>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2007/01.aspx">2007年01月(3)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2006/11.aspx">2006年11月(8)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2006/10.aspx">2006年10月(1)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2006/07.aspx">2006年07月(1)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2005/02.aspx">2005年02月(2)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2004/12.aspx">2004年12月(1)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2004/11.aspx">2004年11月(1)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2004/10.aspx">2004年10月(9)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2004/09.aspx">2004年09月(14)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2004/08.aspx">2004年08月(4)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2003/07.aspx">2003年07月(1)</A>
<LI><A
href="http://blog.csdn.net/hunnish/archive/2003/06.aspx">2003年06月(2)</A></LI></UL><SPAN
id=Anthem_RecentComments_ltlComments__><SPAN id=RecentComments_ltlComments>
<H3 class=listtitle>最近评论</H3>
<UL class=list>
<LI class=listitem>hunnish:<A title="点击查看《回复:OpenCV 书稿:前言》"
href="http://blog.csdn.net/hunnish/archive/2007/01/08/1476793.aspx#532453">还没有呢。估计5月份左右面世。</A>
<LI class=listitem>hunnish:<A title="点击查看《回复:OpenCV In Thanksgiving Day》"
href="http://blog.csdn.net/hunnish/archive/2006/11/25/1413865.aspx#532452">一样的,完全一样</A>
<LI class=listitem>footar:<A title="点击查看《回复:OpenCV 书稿:前言》"
href="http://blog.csdn.net/hunnish/archive/2007/01/08/1476793.aspx#532252">请问这本书出版了没有呢?谢谢</A>
<LI class=listitem>SuperCpp:<A title="点击查看《回复:OpenCV In Thanksgiving Day》"
href="http://blog.csdn.net/hunnish/archive/2006/11/25/1413865.aspx#532132">请问您用过OpenCV中的DCT变换吗?为什么跟MATLAB中做的结果不一样?</A>
<LI class=listitem>hunnish:<A title=点击查看《回复:2006,难以忘怀的一年》
href="http://blog.csdn.net/hunnish/archive/2007/01/01/1471914.aspx#529403">欢迎交流。所谓有朋自远方来,不亦乐乎!</A></LI></UL></SPAN></SPAN><BR><BR></DIV>
<DIV id=main>
<DIV class=Tag>
<SCRIPT language=javascript src=""></SCRIPT>
<DIV style="CLEAR: both"></DIV></DIV>
<SCRIPT>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</SCRIPT>
<DIV class=post>
<DIV class=postTitle><A
href="http://blog.csdn.net/hunnish/archive/2004/09/02/92039.aspx"><IMG height=13
src="人yan检测的C-C++源代码 - HUNNISH的OPENCV专栏 - CSDNBlog.files/authorship.gif"
width=15 border=0> 人脸检测的C/C++源代码</A> </DIV>
<DIV class=postText>
<P>人脸检测的C/C++源代码,曾发表于 OPENCV 的 MAILING LIST,主要是对OPENCV 3.1
版本发布的代码做了一些速度上的优化,并且解决了内存泄漏的问题。这个程序所使用的 Paul Viola 提出(该论文“Rapid Object Detection
using a Boosted Cascade of Simple Features”发表在 CVPR'01)的 Ada Boosted Cascade
算法可以说是目前最好最快的<FONT face=Tahoma>目标检测算法。</FONT></P>
<P><FONT face=Tahoma>关于OPENCV的介绍,参考:</FONT></P>
<P><A
href="http://blog.csdn.net/hunnish/archive/2004/09/13/102535.aspx">http://blog.csdn.net/hunnish/archive/2004/09/13/102535.aspx</A></P>
<P><FONT face=Tahoma>关于该算法的详细介绍,也可参考:</FONT></P><FONT face=Tahoma>
<P><FONT face=Tahoma><A
href="http://www.merl.com/people/viola/research/publications/CVPR-2001.pdf">http://www.merl.com/people/viola/research/publications/CVPR-2001.pdf</A></FONT></P></FONT>
<P><FONT face=Tahoma>以及:</FONT></P>
<P><FONT face=Tahoma><A
href="http://www.assuredigit.com/forum/display_topic_threads.asp?ForumID=11&TopicID=325">http://www.assuredigit.com/forum/display_topic_threads.asp?ForumID=11&TopicID=325</A></FONT></P>
<P><A
href="http://www.assuredigit.com/forum/display_topic_threads.asp?ForumID=11&TopicID=463">http://www.assuredigit.com/forum/display_topic_threads.asp?ForumID=11&TopicID=463</A></P>
<P><FONT face=Tahoma>运行文件下载:</FONT></P>
<P><A
href="http://www.assuredigit.com/product_tech/Demo_Download_files/Face.exe">http://www.assuredigit.com/product_tech/Demo_Download_files/Face.exe</A></P>
<P><FONT face=Tahoma>该程序可以对静止图像以及视频序列进行 face
tracking。对视频序列,请先插入USB接口的摄像头。</FONT></P>
<P><FONT face=Tahoma>====</FONT></P>
<P><FONT face=Tahoma>在OPENCV 3.1 版本,VC6.0下编译通过</FONT></P>
<P><FONT face=Tahoma>====</FONT></P>
<P>===<BR>#ifdef _CH_<BR>#define WIN32<BR>#error "The file needs cvaux, which is
not wrapped yet. Sorry"<BR>#endif</P>
<P>#ifndef _EiC<BR>#include "cv.h"<BR>#include "cvaux.h"<BR>#include
"highgui.h"</P>
<P>#endif</P>
<P>#ifdef _EiC<BR>#define WIN32<BR>#endif</P>
<P>#define ORIG_WIN_SIZE 24<BR>static CvMemStorage* storage = 0;<BR>static
CvHidHaarClassifierCascade* hid_cascade = 0;</P>
<P>#define WINNAME "Result"</P>
<P>void detect_and_draw( IplImage* image, IplImage* TempImage );</P>
<P>int main( int argc, char** argv )<BR>{<BR> CvCapture*
capture = 0;</P>
<P> CvHaarClassifierCascade* cascade =<BR>
cvLoadHaarClassifierCascade(
"<DEFAULT_FACE_CASCADE>",<BR>
cvSize( ORIG_WIN_SIZE, ORIG_WIN_SIZE ));<BR> hid_cascade =
cvCreateHidHaarClassifierCascade( cascade, 0, 0, 0, 1 );<BR>
cvReleaseHaarClassifierCascade( &cascade );</P>
<P> cvNamedWindow( WINNAME, 1 );<BR> storage
= cvCreateMemStorage(0);<BR> <BR> if( argc
== 1 || (argc == 2 && strlen(argv[1]) == 1 &&
isdigit(argv[1][0])))<BR> capture =
cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );<BR> else
if( argc == 2 )<BR> capture =
cvCaptureFromAVI( argv[1] ); </P>
<P> if( capture )<BR>
{<BR> IplImage *frame,
*temp;<BR> cvGrabFrame( capture
);<BR> frame = cvRetrieveFrame(
capture );<BR>
<BR> temp = cvCreateImage(
cvSize(frame->width/2,frame->height/2), 8, 3 );</P>
<P>
for(;;)<BR>
{<BR> if(
!cvGrabFrame( capture ))
<BR>
break;<BR>
frame = cvRetrieveFrame( capture
);<BR> if(
!frame
)<BR>
break;</P>
<P>
detect_and_draw( frame, temp );</P>
<P> if(
cvWaitKey( 10 ) >= 0
)<BR>
{<BR>
//cvReleaseImage( &frame
);<BR>
//cvReleaseImage( &temp
);<BR>
cvReleaseCapture( &capture
);<BR>
cvDestroyWindow(WINNAME);<BR>
return
0;<BR>
}<BR> } <BR>
}<BR> else <BR>
{<BR> char* filename = argc == 2 ?
argv[1] : (char*)"lena.jpg";<BR>
IplImage* image = cvLoadImage( filename, 1
);<BR> IplImage* temp = cvCreateImage(
cvSize(image->width/2,image->height/2), 8, 3 );</P>
<P> if( image
)<BR>
{<BR> cvFlip(
image, image, 0
);<BR>
image->origin =
IPL_ORIGIN_BL;<BR>
detect_and_draw( image, temp
);<BR>
cvWaitKey(0);<BR>
cvReleaseImage( &image
);<BR>
cvReleaseImage( &temp );<BR>
}<BR>
cvDestroyWindow(WINNAME);<BR> return
0;<BR> }<BR> return 0;<BR>}</P>
<P>void detect_and_draw( IplImage* img, IplImage* temp
)<BR>{<BR> int scale = 2;<BR> CvPoint pt1,
pt2;<BR> int i;</P>
<P> cvPyrDown( img, temp, CV_GAUSSIAN_5x5 );<BR>#ifdef
WIN32<BR> cvFlip( temp, temp, 0 );<BR>#endif
<BR> cvClearMemStorage( storage );</P>
<P> if( hid_cascade )<BR>
{<BR> CvSeq* faces =
cvHaarDetectObjects( temp, hid_cascade,
storage,<BR>
1.2, 2, CV_HAAR_DO_CANNY_PRUNING
);<BR> for( i = 0; i < (faces ?
faces->total : 0); i++ )<BR>
{<BR> CvRect*
r = (CvRect*)cvGetSeqElem( faces, i, 0
);<BR> pt1.x =
r->x*scale;<BR>
pt2.x = (r->x+r->width)*scale;<BR>#ifdef
WIN32
<BR> pt1.y =
img->height -
r->y*scale;<BR>
pt2.y = img->height -
(r->y+r->height)*scale;<BR>#else<BR>
pt1.y =
r->y*scale;<BR>
pt2.y =
(r->y+r->height)*scale;<BR>#endif
<BR>
cvRectangle( img, pt1, pt2, CV_RGB(255,255,0), 3
);<BR> }<BR> }</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -