



免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* HandVu - a library for computer vision-based hand gesture* recognition.* Copyright (C) 2004 Mathias Kolsch, * This program is free software; you can redistribute 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; without 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 Place - 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.hIplImage *capture_image = 0;IplImage *display_image = 0;bool async_processing = false;int num_async_bufs = 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( !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_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 & sel_area_bottom-sel_area_top 0 ) hvSetDetectionArea(sel_area_left, sel_area_top, sel_area_right, sel_area_bottom); switch( event ) case CV_EVENT_LBUTTONDOWN: origin = cvPoint(x,y); sel_area_left = sel_area_right = 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_SKIP_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: processed framen); else assert(0); / unknown action hvState 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 (argc2) 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 = 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 - set 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 yet p = cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640); p = cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480); 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); hvStartRecognition(); 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, 1 ); if (success!=1) printf(cant open window - did you compile OpenCV with highgui support?); return -1; fprintf(stderr, initialized highguin); for (;) int c; if (async_processing) / asynchronous processing in HandVu if (sync_display) cvShowImage(HandVu, display_image); / - main library call - hvAsyncGetImageBuffer(&m_async_image, &m_async_bufID); cvCopy(capture_image, m_async_image); hvAsyncProcessFrame(m_async_bufID); / - else / synchronous processing in HandVu / - main library call - hvAction action = HV_INVALID_ACTION; action = hvProcessFrame(capture_image); / - showFrame(capture_image, action); c = cvWaitKey(10); if( c = 27 | c = q ) break; switch( c ) case r: hvStopRecognition(); hvStartRecognition(); break; case 0: hvSetOverlayLevel(0); break; case 1: hvSetOverlayLevel(1); break; case 2: hvSetOverlayLevel(2); break; case 3: hvSetOverlayLevel(3); break; case u: if (hvCanCorrectDistortion() correct_distortion = !correct_disto
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 深圳辅警历年试题及答案
- 负荷管理理论复习试题及答案
- 2025年机关单位餐饮项目提案报告
- 个体股份协议书范本合同
- 财务内勤考试试题及答案
- 惠州国企面试题及答案
- 2025led照明配件采购合同范本
- 车间电气安全试题及答案
- 干部素养面试题目及答案
- 及时更新的软件评测师试题及答案
- 2025版权威旧设备购买合同范本
- 东莞2025年东莞滨海湾新区管理委员会下属事业单位招聘笔试历年参考题库附带答案详解
- 新疆开放大学2025年春《国家安全教育》形考作业1-4终考作业答案
- 《脑炎护理查房》课件
- 职业院校技能大赛教学能力比赛备赛策略与实践经验分享
- 老年社会工作试题及答案
- 2025至2030中国厦门市数字经济行业发展趋势与投资策略研究报告
- GB/T 45451.2-2025包装塑料桶第2部分:公称容量为208.2 L至220 L的不可拆盖(闭口)桶
- 混凝土回弹考试题及答案
- 初级美甲笔试题及答案
- 多式联运物流模式下的智能运输管理系统开发方案
评论
0/150
提交评论