gpt4 book ai didi

sdk - 如何使用 Microsoft Kinect for Windows SDK ver 1.7 C# 检测张开/闭合的手

转载 作者:行者123 更新时间:2023-12-01 00:48:34 25 4
gpt4 key购买 nike

我最近开始使用 Microsoft Kinect for Windows SDK 来使用 Kinect 设备编程一些东西。

我正在努力寻找一种方法来检测某只手是闭合还是打开。

我看到了 Kinect for Windows Toolkit,但文档不存在,我找不到让它工作的方法。

有谁知道检测手的情况的简单方法吗?如果不需要使用 Kinect 工具包,那就更好了。

最佳答案

这就是我最终的做法:

首先,我们需要一个看起来像这样的虚拟类:

public class DummyInteractionClient : IInteractionClient
{
public InteractionInfo GetInteractionInfoAtLocation(
int skeletonTrackingId,
InteractionHandType handType,
double x,
double y)
{
var result = new InteractionInfo();
result.IsGripTarget = true;
result.IsPressTarget = true;
result.PressAttractionPointX = 0.5;
result.PressAttractionPointY = 0.5;
result.PressTargetControlId = 1;

return result;
}
}

然后,在主应用程序代码中,我们需要像这样声明交互事件处理程序:

this.interactionStream = new InteractionStream(args.NewSensor, new DummyInteractionClient());
this.interactionStream.InteractionFrameReady += InteractionStreamOnInteractionFrameReady;

最后,处理程序本身的代码:

private void InteractionStreamOnInteractionFrameReady(object sender, InteractionFrameReadyEventArgs e)
{
using (InteractionFrame frame = e.OpenInteractionFrame())
{
if (frame != null)
{
if (this.userInfos == null)
{
this.userInfos = new UserInfo[InteractionFrame.UserInfoArrayLength];
}

frame.CopyInteractionDataTo(this.userInfos);
}
else
{
return;
}
}



foreach (UserInfo userInfo in this.userInfos)
{
foreach (InteractionHandPointer handPointer in userInfo.HandPointers)
{
string action = null;

switch (handPointer.HandEventType)
{
case InteractionHandEventType.Grip:
action = "gripped";
break;

case InteractionHandEventType.GripRelease:
action = "released";

break;
}

if (action != null)
{
string handSide = "unknown";

switch (handPointer.HandType)
{
case InteractionHandType.Left:
handSide = "left";
break;

case InteractionHandType.Right:
handSide = "right";
break;
}

if (handSide == "left")
{
if (action == "released")
{
// left hand released code here
}
else
{
// left hand gripped code here
}
}
else
{
if (action == "released")
{
// right hand released code here
}
else
{
// right hand gripped code here
}
}
}
}
}
}

关于sdk - 如何使用 Microsoft Kinect for Windows SDK ver 1.7 C# 检测张开/闭合的手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18729142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com