Kinect 手势识别之挥手(C++实现)

本文介绍了如何将原版代码改编为C++版本,实现Kinect设备的手势识别功能,特别是挥手动作的检测。通过详细步骤和代码片段,读者可以理解C++中Kinect手势识别的实现原理。
摘要由CSDN通过智能技术生成

以下代码是根据这里改编成C++版的,实现思路上相同,但是细节有差异,不影响理解

#include<iostream>
#include<Windows.h>
#include<NuiApi.h>
#include<ctime>
#include<cassert>
#include<process.h>

#pragma comment(lib,"kinect10.lib")
using namespace std;

HANDLE DetectionEvent = CreateEvent( NULL, false, false, NULL );

// 记录手势当前位置
enum GesturePos{
	NonePos = 0,
	Left,
	Right,
	Neutral
};

// 判断识别状态
enum DetectionState{
	NoneState = 0,
	Success,
	Failed,
	InProgress
};

// 判断手势需要的数据
struct DataState{
	GesturePos Pos;		// 每个人的左右手
	DetectionState State;
	int times;
	time_t timestamp;
	void Reset()
	{
		Pos = GesturePos::NonePos;
		State = DetectionState::NoneState;
		times = 0;
		timestamp = 0;
	}
};

// 完成手势判断逻辑功能
class GestureDetection{
public:
	GestureDetection( float neutral_threshold, int times, double difftimes )
		: neutral_threshold( neutral_threshold )
		, times(times)
		, difftimes(difftimes)
		, left_hand(0)
		, right_hand(1)
	{
		for( int i = 0; i < NUI_SKELETON_COUNT; i++ )
		{
			wave_datas[i][left_hand].Reset();
			wave_datas[i][right_hand].Reset();
		}
	}
	// 功能:循环接收骨骼数据,如果识别出为挥手动作则输出:success,
	// 识别失败
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值