资源简介
使用OpenNI类库实现。在Kinect的支持下,通过对手势的识别和跟踪,来代替鼠标移动和点击。该程序使人能够徒手控制PC,如用Firefox浏览网页,玩水果忍者等等。此程序为非MFC版本。开发教程:http://blog.csdn.net/chenxin_130/article/details/6693390
代码片段和文件信息
/*************************************
Kinect Skeleton
Author: Xin Chen 2011
Blog:http://blog.csdn.net/chenxin_130
**************************************/
#include “AppMessage.h“
#include
/*
#pragma comment (lib“user32“)
*/
//Location and move angle last time for each userId(Hand Id)
CvPoint lastLocation[MAX_HAND_NUM];
int isHandTracking[MAX_HAND_NUM]={0};
int isClickDown=0;
void addTrackingId(int userId)
{
isHandTracking[userId]=1;
}
void removeTrackingId(int userId)
{
isHandTracking[userId]=0;
}
CvPoint getLastLocation(int userId)
{
return lastLocation[userId];
}
void messageHandler(CvPoint &location int userIdint flag)
{
//initialize the lastLocation from the location obtained by the first time
if(lastLocation[userId].x==0&&lastLocation[userId].y==0)
{
lastLocation[userId].x=location.x;
lastLocation[userId].y=location.y;
}
if(flag==REAL_MOUSE_CLICK)
{
if(!isClickDown)
{
mouse_event(MOUSEEVENTF_LEFTDOWN0000);
}
else {
mouse_event(MOUSEEVENTF_LEFTUP0000);
}
isClickDown=1-isClickDown;
}
else if(flag==REAL_MOUSE_MOVE)
{
int firstHandId=-1;
for(int i=0;i {
if(isHandTracking[i]!=0)
{
if(firstHandId==-1)
{
firstHandId=i;
break;
}
}
}
if(abs(location.x-lastLocation[userId].x)<5)
{
location.x=lastLocation[userId].x;
}
if(abs(location.y-lastLocation[userId].y)<5)
{
location.y=lastLocation[userId].y;
}
if(userId==firstHandId)
{
//mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE
//(location.x-320)*65536/640*2location.y*65536/480*200);
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE
(location.x-160)*65536/640*2(location.y-120)*65536/480*200);
}
}
lastLocation[userId].x=location.x;
lastLocation[userId].y=location.y;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-10-20 22:47 KinectMouseControl\
目录 0 2011-10-20 22:48 KinectMouseControl\KinectMouseControl\
文件 1945 2011-10-20 22:44 KinectMouseControl\KinectMouseControl\AppMessage.cpp
文件 443 2011-10-20 22:41 KinectMouseControl\KinectMouseControl\AppMessage.h
文件 219 2011-10-20 22:41 KinectMouseControl\KinectMouseControl\KinectGesture.h
文件 6242 2011-10-20 22:44 KinectMouseControl\KinectMouseControl\KinectGestureMain.cpp
文件 4166 2011-10-19 20:32 KinectMouseControl\KinectMouseControl\KinectMouseControl.vcproj
文件 920 2011-10-19 20:26 KinectMouseControl\KinectMouseControl.sln
文件 16896 2011-10-20 22:47 KinectMouseControl\KinectMouseControl.suo
目录 0 2011-10-20 22:48 KinectMouseControl\Release\
文件 17920 2011-10-20 22:44 KinectMouseControl\Release\KinectMouseControl.exe
相关资源
- kinect2.0数据采集及点云生成代码C++
- Kinect c++试验版的切水果游戏
- OpenNI体感应用开发实战 [任侃 著] 20
- KinectV2 实现鼠标控制VS2013 C++版
- MFC kinect 骨骼识别
- KinectV2彩色图片尺寸变换代码变换后与
- kinect+openGL+openNI+opencv实现三维重建
- Kinect2.0采集图像帧并保存
- Kinect2.0 骨骼点获取
- Kinectv2 __MFC
- kinect+opengl 生成并显示点云
- Kinectv2_深度图和骨骼图源码
- Kinect2.0+PCL实现点云显示
- Kinect v2 跌到检测函数
- 基于Camshift+Kalman的多目标跟踪
- Kinect程序开发帮助文档C++
- 完整的实时深度图平滑代码像素滤波
- opencv2深度图滤波
- 基于kinect的人体动作识别系统
评论
共有 条评论