手部位置跟踪opencv程序

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

* HandVu - a library for computer vision-based hand gesture

* recognition.

* Copyright (C) 2004 Mathias Kolsch, matz@

*

* 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.h"

IplImage *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 frame\n");

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 frame\n");

} else if (action==HV_PROCESS_FRAME) {

// full processing was done and is recommended for following steps;

// keep going

//printf("HandVuFilter: processed frame\n");

} else {

assert(0); // unknown action

}

hvState state;

相关文档
最新文档