我使用OpenCV2.4.4的windows版本+Qt4.8.3+VS2010的编译器做了一个手势识别的小程序。
本程序主要使到了Opencv的特征训练库和最基本的图像处理的知识,包括肤色检测等等。
废话不多,先看一下基本的界面设计,以及主要功能:
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-11-05 18:39 HandGesture
文件 6093 2013-07-12 10:15 HandGestureHandGesture.pro
文件 17435 2013-07-12 13:03 HandGestureHandGesture.pro.user
文件 6433 2013-07-12 10:53 HandGesturehandgesturedialog.cpp
文件 1665 2013-07-12 10:33 HandGesturehandgesturedialog.h
文件 9569 2013-07-12 10:53 HandGesturehandgesturedialog.ui
目录 0 2013-11-05 18:40 HandGestureInfoDoc
文件 14143 2009-10-25 21:26 HandGestureInfoDocgestureFeatureFile.yml
文件 79 2009-10-25 21:26 HandGestureInfoDocgestureFile.txt
文件 72462 2011-11-29 14:19 HandGestureInfoDochand.xml
文件 350 2013-05-30 00:23 HandGesturemain.cpp
目录 0 2013-11-05 18:40 HandGestureOthersDocument
文件 9084 2013-06-01 09:48 HandGestureOthersDocumentFaceDetection.cpp
目录 0 2013-11-05 18:40 HandGestureOthersDocumentfingertips
文件 4452 2011-01-12 17:18 HandGestureOthersDocumentfingertipsfingertips.cpp
文件 9728 2010-12-01 09:14 HandGestureOthersDocumentfingertipsfingertips.suo
目录 0 2013-11-05 18:40 HandGestureOthersDocumentfingertipsimages
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesdown-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesdown-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesleft-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesleft-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimages
ight-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimages
ight-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesstraight-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesstraight-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesup-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesup-001.bmp
目录 0 2013-11-05 18:40 HandGestureSRC
文件 33249 2013-06-01 00:41 HandGestureSRCAIGesture.cpp
文件 2602 2013-05-30 14:32 HandGestureSRCAIGesture.h
文件 895 2013-05-28 11:34 HandGestureSRCGestrueInfo.cpp
............此处省略493个文件信息
#include “handgesturedialog.h“
#include “ui_handgesturedialog.h“
#include
HandGestureDialog::HandGestureDialog(QWidget *parent) :
QDialog(parent)
ui(new Ui::HandGestureDialog)
{
ui->setupUi(this);
cam = NULL;
frame = NULL;
isRun = 1;
time_intervals = 100;
timer = new QTimer(this);
imag = new QImage();
gesturecount = 0;
status_switch = Nothing;
pt = NULL;
r = 0;
afterSkin = NULL;
connect(timer SIGNAL(timeout()) this SLOT(readFarme()));
ui->pushButton_CloseCamera->setDisabled (true);
ui->pushButton_ShowPause->setDisabled (true);
ui->pushButton_SnapImage->setDisabled (true);
}
HandGestureDialog::~HandGestureDialog()
{
delete ui;
}
void HandGestureDialog::StartRecongizeHand (IplImage *img)
{
// Create a string that contains the exact cascade name
// Contains the trained classifer for detecting hand
const char *cascade_name=“hand.xml“;
// Create memory for calculations
static CvMemStorage* storage = 0;
// Create a new Haar classifier
static CvHaarClassifierCascade* cascade = 0;
// Sets the scale with which the rectangle is drawn with
int scale = 1;
// Create two points to represent the hand locations
CvPoint pt1 pt2;
// Looping variable
int i;
// Load the HaarClassifierCascade
cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name 0 0 0 );
// Check whether the cascade has loaded successfully. Else report and error and quit
if( !cascade )
{
fprintf( stderr “ERROR: Could not load classifier cascade
“ );
return;
}
// Allocate the memory storage
storage = cvCreateMemStorage(0);
// Create a new named window with title: result
cvNamedWindow( “result“ 1 );
// Clear the memory storage which was used before
cvClearMemStorage( storage );
// Find whether the cascade is loaded to find the hands. If yes then:
if( cascade )
{
// There can be more than one hand in an image. So create a growable sequence of hands.
// Detect the objects and store them in the sequence
CvSeq* hands = cvHaarDetectobjects( img cascade storage
1.1 2 CV_HAAR_DO_CANNY_PRUNING
cvSize(40 40) );
// Loop the number of hands found.
for( i = 0; i < (hands ? hands->total : 0); i++ )
{
// Create a new rectangle for drawing the hand
CvRect* r = (CvRect*)cvGetSeqElem( hands i );
// Find the dimensions of the handand scale it if necessary
pt1.x = r->x*scale;
pt2.x = (r->x+r->width)*scale;
pt1.y = r->y*scale;
pt2.y = (r->y+r->height)*scale;
// Draw the rectangle in the input image
cvRectangle( img pt1 pt2 CV_RGB(23020232)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-11-05 18:39 HandGesture
文件 6093 2013-07-12 10:15 HandGestureHandGesture.pro
文件 17435 2013-07-12 13:03 HandGestureHandGesture.pro.user
文件 6433 2013-07-12 10:53 HandGesturehandgesturedialog.cpp
文件 1665 2013-07-12 10:33 HandGesturehandgesturedialog.h
文件 9569 2013-07-12 10:53 HandGesturehandgesturedialog.ui
目录 0 2013-11-05 18:40 HandGestureInfoDoc
文件 14143 2009-10-25 21:26 HandGestureInfoDocgestureFeatureFile.yml
文件 79 2009-10-25 21:26 HandGestureInfoDocgestureFile.txt
文件 72462 2011-11-29 14:19 HandGestureInfoDochand.xm
文件 350 2013-05-30 00:23 HandGesturemain.cpp
目录 0 2013-11-05 18:40 HandGestureOthersDocument
文件 9084 2013-06-01 09:48 HandGestureOthersDocumentFaceDetection.cpp
目录 0 2013-11-05 18:40 HandGestureOthersDocumentfingertips
文件 4452 2011-01-12 17:18 HandGestureOthersDocumentfingertipsfingertips.cpp
文件 9728 2010-12-01 09:14 HandGestureOthersDocumentfingertipsfingertips.suo
目录 0 2013-11-05 18:40 HandGestureOthersDocumentfingertipsimages
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesdown-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesdown-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesleft-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesleft-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimages
ight-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimages
ight-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesstraight-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesstraight-001.bmp
文件 41078 2010-11-26 16:34 HandGestureOthersDocumentfingertipsimagesup-000.bmp
文件 41078 2010-11-26 16:35 HandGestureOthersDocumentfingertipsimagesup-001.bmp
目录 0 2013-11-05 18:40 HandGestureSRC
文件 33249 2013-06-01 00:41 HandGestureSRCAIGesture.cpp
文件 2602 2013-05-30 14:32 HandGestureSRCAIGesture.h
文件 895 2013-05-28 11:34 HandGestureSRCGestrueInfo.cpp
............此处省略493个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)