openni+nite体感鼠标模拟3(左右手选择)

选择左右手是通过,一开始我们在Psi姿势识别人体,然后摆动需要控制的手,完成左右手选择。

void SelectHand()
{
	if (selectHand)
	{
		putText(cvBGRImage,"Please select your control hand!",Point(320,240),1,1,Scalar(255,255,255));
		if (abs(imagepointReal[0].X-imagepointReal[2].X)>abs(1.5*(imagepointReal[8].X-imagepointReal[2].X)))
		{
			isLeft=true;
			selectHand=false;
		}
		if (abs(imagepointReal[1].X-imagepointReal[3].X)>abs(1.5*(imagepointReal[7].X-imagepointReal[3].X)))
		{
			isRight=true;
			selectHand=false;
		}

	}
}

然后通过winapi进行鼠标的控制

void MouseMove()
{
	if (isLeft)
	{
		int CursorPox_X=(int)((imagepoint[0].X/640)*ScreenRes_X+100);
		int CursorPox_Y=(int)((imagepoint[0].Y/480)*ScreenRes_Y+50);
		SetCursorPos(CursorPox_X,CursorPox_Y);
	}
	if (isRight)
	{
		int CursorPox_X=(int)((imagepoint[1].X/640)*ScreenRes_X+100);
		int CursorPox_Y=(int)((imagepoint[1].Y/480)*ScreenRes_Y+50);
		SetCursorPos(CursorPox_X,CursorPox_Y);
	}
}
不过,这种方法鼠标抖动比较厉害,后面会利用NITE再进行优化

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值