资源简介

基于OpenCV+vs2008的手势检测,检测英文字母A的手势,利用了OpenCV的haar特征级联分类器,效果可好

资源截图

代码片段和文件信息

/************************************************************************
* Copyright(c) 2011  Yang Xian
* All rights reserved.
*
* File: handGestureDetection.cpp
* Brief: 手势检测
* Version: 1.0
* Author: Yang Xian
* Email: xyang2011@sinano.ac.cn
* Date: 2011/12/01
* History:
************************************************************************/
#include 
#include 
#include 
#include 

#include 

using namespace std;
using namespace cv;

/** Function Headers */
void detectAndDisplay( Mat frame );

/** Global variables */
String face_cascade_name = “hand.xml“;
CascadeClassifier CHandCascade;
string window_name = “Hand Gesture Detection“;

int main(int argc const char** argv)
{
Mat frame;

//-- 1. Load the cascades
if( !CHandCascade.load( face_cascade_name ) )
{
printf(“--(!)Error loading\n“);
return -1;
}

//-- 2. Read the video stream
CvCapture* capture = cvCaptureFromCAM( -1 );
//  VideoCapture capture(“hand.avi“);

if(/*capture.isOpened()*/capture)
{
while( true )
{
frame = cvQueryframe( capture );
//  capture >> frame;

//-- 3. Apply the classifier to the frame
if( !frame.empty() )

detectAndDisplay( frame );
}
else
{
printf(“ --(!) No captured frame -- Break!“);
break; 
}

int c = waitKey(10);
if((char)c == 27)
{
break;


}
}
return 0;
}

/**
* @function detectAndDisplay
*/
void detectAndDisplay( Mat frame )
{
std::vector hands;
Mat frame_gray;

cvtColor( frame frame_gray CV_BGR2GRAY );
equalizeHist( frame_gray frame_gray );
//-- Detect faces
CHandCascade.detectMultiScale(frame_gray hands 1.1 2 CV_HAAR_DO_CANNY_PRUNING Size(40 40));

for(size_t i=0; i {
rectangle(frame hands[i] Scalar(2550255));

//-- Show what you got
imshow( window_name frame );
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      72462  2011-11-29 14:19  handGestureDetection\Debug\hand.xml

     文件      57856  2011-12-03 09:00  handGestureDetection\Debug\handGestureDetection.exe

     文件     446680  2011-12-03 09:00  handGestureDetection\Debug\handGestureDetection.ilk

     文件    4885504  2011-12-03 09:00  handGestureDetection\Debug\handGestureDetection.pdb

     文件       6632  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug\BuildLog.htm

     文件        621  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug\handGestureDetection.exe.intermediate.manifest

     文件     130533  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug\handGestureDetection.obj

     文件         67  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug\mt.dep

     文件     404480  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug\vc90.idb

     文件     700416  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug\vc90.pdb

     文件    5395040  2011-10-28 08:19  handGestureDetection\handGestureDetection\hand.AVI

     文件      72462  2011-11-29 14:19  handGestureDetection\handGestureDetection\hand.xml

     文件       2036  2011-12-03 09:00  handGestureDetection\handGestureDetection\handGestureDetection.cpp

     文件       3803  2011-12-03 08:59  handGestureDetection\handGestureDetection\handGestureDetection.vcproj

     文件       1423  2011-12-03 09:17  handGestureDetection\handGestureDetection\handGestureDetection.vcproj.HP98402794308.Administrator.user

     文件    5778432  2011-12-03 09:17  handGestureDetection\handGestureDetection.ncb

     文件        926  2011-12-01 14:00  handGestureDetection\handGestureDetection.sln

    ..A..H.      9216  2011-12-03 09:17  handGestureDetection\handGestureDetection.suo

     目录          0  2011-12-03 09:00  handGestureDetection\handGestureDetection\Debug

     目录          0  2011-12-03 09:06  handGestureDetection\Debug

     目录          0  2011-12-03 09:00  handGestureDetection\handGestureDetection

     目录          0  2011-12-01 15:49  handGestureDetection

----------- ---------  ---------- -----  ----

             17968589                    22


评论

共有 条评论