手势识别代码以及部分原理

上传人:子 文档编号:44004384 上传时间:2018-06-08 格式:DOC 页数:11 大小:35KB
返回 下载 相关 举报
手势识别代码以及部分原理_第1页
第1页 / 共11页
手势识别代码以及部分原理_第2页
第2页 / 共11页
手势识别代码以及部分原理_第3页
第3页 / 共11页
手势识别代码以及部分原理_第4页
第4页 / 共11页
手势识别代码以及部分原理_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《手势识别代码以及部分原理》由会员分享,可在线阅读,更多相关《手势识别代码以及部分原理(11页珍藏版)》请在金锄头文库上搜索。

1、手势识别代码以及部分原理手势识别代码以及部分原理图像处理,目标识别,目标跟踪,模式识别OpenCV 学习利用 HandVu 进行手部动作识别分析(转) 2011-04-06 17:29:26| 分类: 默认分类 | 标签:opencv 手部识别 |举报|字号 订阅/* HandVu - a library for computer vision-based hand gesture* recognition.* Copyright (C) 2004 Mathias Kolsch, matzcs.ucsb.edu* This program is free software; you can r

2、edistribute it and/or* modify it under the terms of the GNU General Public License* as published by the Free Software Foundation; either version 2* of the License, or (at your option) any later version.* This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; witho

3、ut even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.* You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Pla

4、ce - Suite 330, * Boston, MA 02111-1307, USA.* $Id: hv_OpenCV.cpp,v 1.15 2006/01/03 21:44:15 matz Exp $*/#ifdef WIN32#include #endif#include #include #include #include #include #include “HandVu.h“IplImage *capture_image = 0;IplImage *display_image = 0;bool async_processing = false;int num_async_bufs

5、 = 30;IplImage *m_async_image = 0;int m_async_bufID = -1;bool sync_display = true;CvPoint origin;int select_object = 0;int sel_area_left=0, sel_area_top=0, sel_area_right=0, sel_area_bottom=0;bool correct_distortion = false;void OnMouse( int event, int x, int y, int /*flags*/, void* /*params*/ )if(

6、!capture_image )return;if( capture_image-origin )y = capture_image-height - y;if( select_object )sel_area_left = MIN(x,origin.x);sel_area_top = MIN(y,origin.y);sel_area_right = sel_area_left + CV_IABS(x - origin.x);sel_area_bottom = sel_area_top + CV_IABS(y - origin.y);sel_area_left = MAX( sel_area_

7、left, 0 );sel_area_top = MAX( sel_area_top, 0 );sel_area_right = MIN( sel_area_right, capture_image-width );sel_area_bottom = MIN( sel_area_bottom, capture_image-height );if( sel_area_right-sel_area_left 0 switch( event )case CV_EVENT_LBUTTONDOWN:origin = cvPoint(x,y);sel_area_left = sel_area_right

8、= x;sel_area_top = sel_area_bottom = y;select_object = 1;break;case CV_EVENT_LBUTTONUP:select_object = 0;break;void showFrame(IplImage* img, hvAction action)if (action=HV_DROP_FRAME) / HandVu recommends dropping the frame entirely/ printf(“HandVuFilter: dropping framen“);return; else if (action=HV_S

9、KIP_FRAME) / HandVu recommends displaying the frame, but not doing any further/ processing on it - keep going/ printf(“HandVuFilter: supposed to skip framen“); else if (action=HV_PROCESS_FRAME) / full processing was done and is recommended for following steps;/ keep going/printf(“HandVuFilter: proce

10、ssed framen“); else assert(0); / unknown actionhvState state;hvGetState(0, state);cvShowImage( “HandVu“, img );void displayCallback(IplImage* img, hvAction action)if (sync_display) cvCopy(img, display_image); else showFrame(img, action);int main( int argc, char* argv )CvCapture* capture = 0;if (argc

11、2) printf(“you need to specify a conductor file as first argumentn“);printf(“for example: ./config/default.conductorn“);return -1;string conductor_fname(argv1);/声明配置参数的对象printf(“will load conductor from file:n%sn“, conductor_fname.c_str();/屏显提示/*是否设定特定的摄像头,并初始化摄像头 */if( argc = 2 | argc = 3) int num

12、= 0;if (argc=3) num = atoi(argv2);capture = cvCaptureFromCAM( num );if (!capture) capture = cvCaptureFromAVI( argv2 ); if( !capture )fprintf(stderr,“Could not initialize capturing through OpenCV.n“);return -1;/* 屏显提示 */printf( “Hot keys: n“tESC - quit the programn“tr - restart the trackingn“t0-3 - s

13、et the overlay (verbosity) leveln“use the mouse to select the initial detection arean“ );/设定采集图像大小int p = 0; / according to docs, these calls dont work in OpenCV beta 4 yetp = cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);p = cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480)

14、;/获取一帧capture_image = cvQueryFrame( capture );if ( !capture_image ) fprintf(stderr,“Could not retrieve image through OpenCV.n“);return -1;/* allocate all the buffers */CvSize size = cvGetSize(capture_image);hvInitialize(size.width, size.height);/初始化要分析的图像大小hvLoadConductor(conductor_fname);/装载参数hvSta

15、rtRecognition();/开始识别hvSetOverlayLevel(2);/设置识别的覆盖区级别/* 设置同步异步识别 */if (async_processing) hvAsyncSetup(num_async_bufs, displayCallback);if (sync_display) display_image = cvCloneImage(capture_image);/* 设置鼠标事件的回调参数 */cvSetMouseCallback( “HandVu“, OnMouse );/* 设置窗口 */int success = cvNamedWindow( “HandVu

16、“, 1 );if (success!=1) printf(“cant open window - did you compile OpenCV with highgui support?“);return -1;fprintf(stderr, “initialized highguin“);hvStartGestureServer(1394,10);for (;) int c;if (async_processing) / asynchronous processing in HandVuif (sync_display) cvShowImage(“HandVu“, display_image);/ - main library call -hvAsyncGetImageBuffer(cvCopy(captu

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号