将右手的位置保存为“主页”位置 [英] Save position of right hand as "home"-position
问题描述
当Kinect跟踪我的右手(JointType.HandRight)时,我希望它将手的当前位置保存为"home"位置,稍后可以参考,例如我的权利手从"家"位置向右移动。
我是编程的新手,非常感谢节目和解释的代码(并注意现有代码中是否存在任何错误或缺失的内容)!谢谢!
When the Kinect has tracked my right hand (JointType.HandRight), I want it to save the current position of the hand as a "home"-position which later can be referred to when for example my right hand moves to the right from the "home"-position. I'm a novice in programming and would highly appreciate code for show and an explanation (and note if there's anything in the existing code that's wrong or missing)! Thanks!
// Find the right hand joint
IList<Microsoft.Kinect.Body> bodies;
void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
{
var reference = e.FrameReference.AcquireFrame();
using (var frame = reference.BodyFrameReference.AcquireFrame())
{
if (frame != null)
{
bodies = new Microsoft.Kinect.Body[frame.BodyFrameSource.BodyCount];
frame.GetAndRefreshBodyData(bodies);
foreach (var body in bodies)
{
if (body != null)
{
if (body.IsTracked)
{
// Find the joint
Joint handRight = body.Joints[Microsoft.Kinect.JointType.HandRight];
// Around here maybe having the code which saves the current position as "home"
}
}
}
}
}
}
推荐答案
您可以创建一个变量来存储该信息:
You can just create a variable for storing that info:
IList<Microsoft.Kinect.Body> bodies;
Joint homeRightHandPosition;
void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
{
//...
if(body.IsTracked)
{
homeRightHandPosition = body.Joints[JointType.HandRight];
}
//...
}
这是一个"简单的答案",应用程序中的信息存储取决于一点点关于你以后如何计划使用该信息。
This was a "simple answer", information storage in apps depends a little on how you are planning to use that info later.
这篇关于将右手的位置保存为“主页”位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!