资源简介

我使用OpenCV2.4.4的windows版本+Qt4.8.3+VS2010的编译器做了一个手势识别的小程序。 本程序主要使到了Opencv的特征训练库和最基本的图像处理的知识,包括肤色检测等等。 废话不多,先看一下基本的界面设计,以及主要功能:

资源截图

代码片段和文件信息

#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\n“ );
        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  HandGesture\HandGesture.pro
     文件       17435  2013-07-12 13:03  HandGesture\HandGesture.pro.user
     文件        6433  2013-07-12 10:53  HandGesture\handgesturedialog.cpp
     文件        1665  2013-07-12 10:33  HandGesture\handgesturedialog.h
     文件        9569  2013-07-12 10:53  HandGesture\handgesturedialog.ui
     目录           0  2013-11-05 18:40  HandGesture\InfoDoc\
     文件       14143  2009-10-25 21:26  HandGesture\InfoDoc\gestureFeatureFile.yml
     文件          79  2009-10-25 21:26  HandGesture\InfoDoc\gestureFile.txt
     文件       72462  2011-11-29 14:19  HandGesture\InfoDoc\hand.xml
     文件         350  2013-05-30 00:23  HandGesture\main.cpp
     目录           0  2013-11-05 18:40  HandGesture\OthersDocument\
     文件        9084  2013-06-01 09:48  HandGesture\OthersDocument\FaceDetection.cpp
     目录           0  2013-11-05 18:40  HandGesture\OthersDocument\fingertips\
     文件        4452  2011-01-12 17:18  HandGesture\OthersDocument\fingertips\fingertips.cpp
     文件        9728  2010-12-01 09:14  HandGesture\OthersDocument\fingertips\fingertips.suo
     目录           0  2013-11-05 18:40  HandGesture\OthersDocument\fingertips\images\
     文件       41078  2010-11-26 16:34  HandGesture\OthersDocument\fingertips\images\down-000.bmp
     文件       41078  2010-11-26 16:35  HandGesture\OthersDocument\fingertips\images\down-001.bmp
     文件       41078  2010-11-26 16:34  HandGesture\OthersDocument\fingertips\images\left-000.bmp
     文件       41078  2010-11-26 16:35  HandGesture\OthersDocument\fingertips\images\left-001.bmp
     文件       41078  2010-11-26 16:34  HandGesture\OthersDocument\fingertips\images\right-000.bmp
     文件       41078  2010-11-26 16:35  HandGesture\OthersDocument\fingertips\images\right-001.bmp
     文件       41078  2010-11-26 16:34  HandGesture\OthersDocument\fingertips\images\straight-000.bmp
     文件       41078  2010-11-26 16:35  HandGesture\OthersDocument\fingertips\images\straight-001.bmp
     文件       41078  2010-11-26 16:34  HandGesture\OthersDocument\fingertips\images\up-000.bmp
     文件       41078  2010-11-26 16:35  HandGesture\OthersDocument\fingertips\images\up-001.bmp
     目录           0  2013-11-05 18:40  HandGesture\SRC\
     文件       33249  2013-06-01 00:41  HandGesture\SRC\AIGesture.cpp
     文件        2602  2013-05-30 14:32  HandGesture\SRC\AIGesture.h
     文件         895  2013-05-28 11:34  HandGesture\SRC\GestrueInfo.cpp
............此处省略493个文件信息

评论

共有 条评论