绘制2个跟踪骨架Kinect SDK v1.6的最接近的骨骼(肩部 - 头部) [英] Draw the closest Bone (Shoulder - Head) of 2 tracking skeletons Kinect SDK v1.6
本文介绍了绘制2个跟踪骨架Kinect SDK v1.6的最接近的骨骼(肩部 - 头部)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在寻找一种解决方案来绘制最近骨架的骨骼。我编写了代码来绘制第一个跟踪骨架的骨骼。如果第二个人比第一个人更接近我想画第二个骨架的骨头。也许有人知道怎么做
呢?
Hello, I'm looking a solution to draw the bone of the closest skeleton. I wrote code to draw the first tracking skeleton's bone. If the second person will closer than first I want to draw bone of second skeleton. Maybe somebody have any idea how to do it?
void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
// check for frame drop.
if (skeletonFrame == null)
{
return;
}
// copy the frame data in to the collection
skeletonFrame.CopySkeletonDataTo(totalSkeleton);
// get the first Tracked skeleton
skeleton = (from trackskeleton in totalSkeleton
where trackskeleton.TrackingState == SkeletonTrackingState.Tracked
select trackskeleton).FirstOrDefault();
if (skeleton != null)
{
if (skeleton.Joints[JointType.ShoulderCenter].TrackingState == JointTrackingState.Tracked && skeleton.Joints[JointType.Head].TrackingState == JointTrackingState.Tracked)
{
myCanvas.Children.Clear();
this.DrawHead();
}
}
}
}
// Draws the head.
private void DrawHead()
{
if (skeleton != null)
{
drawBone(skeleton.Joints[JointType.ShoulderCenter], skeleton.Joints[JointType.Head]);
}
}
// Draws the bone.
void drawBone(Joint trackedJoint1, Joint trackedJoint2)
{
Line skeletonBone = new Line();
skeletonBone.Stroke = Brushes.Black;
skeletonBone.StrokeThickness = 3;
Point joint1 = this.ScalePosition(trackedJoint1.Position);
skeletonBone.X1 = joint1.X;
skeletonBone.Y1 = joint1.Y;
Point joint2 = this.ScalePosition(trackedJoint2.Position);
skeletonBone.X2 = joint2.X;
skeletonBone.Y2 = joint2.Y;
myCanvas.Children.Add(skeletonBone);
}
/// <summary>
/// Scales the position.
/// </summary>
/// <param name="skeletonPoint">The skeltonpoint.</param>
/// <returns></returns>
private Point ScalePosition(SkeletonPoint skeletonPoint)
{
// return the depth points from the skeleton point
DepthImagePoint depthPoint = this.sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(skeletonPoint, DepthImageFormat.Resolution640x480Fps30);
return new Point(depthPoint.X, depthPoint.Y);
}
}
}
推荐答案
请参阅"如何选择要跟踪的用户"
see "How to select the users to track"
如果您查看SDK工具包中的Kinect Explorer示例,有几种设置主动跟踪的方法
If you look at the Kinect Explorer samples in the SDK Toolkit, there are several ways of setting up active tracking
这篇关于绘制2个跟踪骨架Kinect SDK v1.6的最接近的骨骼(肩部 - 头部)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文