我是这个网站的新手,我真的需要你的帮助,或者只是一个建议人员。
是否有人知道如何做或可以帮助我制作类似于此的应用程序?
Draw smooth line in InkCanvas WPF with Kinect
或类似的东西
我知道如何访问我的Kinect,检测并跟踪每个关节等。我不知道的唯一一个问题,我遇到的问题是我真的不知道如何制作一个能够追踪的功能在画布上画一条线。
任何人都可以帮助我吗?
答案 0 :(得分:0)
这里有很多例子:
powerpoint控件示例向您展示如何检测和跟踪指针,甚至如何检测某些手势。
修改强>
按照powerpoint控件的示例,在下面的代码中,我将向您展示如何使用椭圆跟踪我的手:
void sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
try
{
using (var skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame == null)
return;
if (skeletons == null ||
skeletons.Length != skeletonFrame.SkeletonArrayLength)
{
skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
}
skeletonFrame.CopySkeletonDataTo(skeletons);
}
Skeleton closestSkeleton = skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked)
.OrderBy(s => s.Position.Z * Math.Abs(s.Position.X))
.FirstOrDefault();
if (closestSkeleton == null)
return;
var rightFoot = closestSkeleton.Joints[JointType.FootRight];
var leftFoot = closestSkeleton.Joints[JointType.FootLeft];
var rightHand = closestSkeleton.Joints[JointType.HandRight];
var leftHand = closestSkeleton.Joints[JointType.HandLeft];
if (rightFoot.TrackingState == JointTrackingState.NotTracked ||
rightHand.TrackingState == JointTrackingState.NotTracked ||
leftHand.TrackingState == JointTrackingState.NotTracked)
{
//Don't have a good read on the joints so we cannot process gestures
return;
}
CoordinateMapper mapper = sensor.CoordinateMapper;
var point = mapper.MapSkeletonPointToColorPoint(closestSkeleton.Joints[JointType.Head].Position, sensor.ColorStream.Format);
var point1 = mapper.MapSkeletonPointToColorPoint(rightHand.Position, sensor.ColorStream.Format);
var point2 = mapper.MapSkeletonPointToColorPoint(leftHand.Position, sensor.ColorStream.Format);
// - Put Your Draw Code Here insted of the following:
SetEllipsePosition(ellipseRightFoot, rightFoot, false);
SetEllipsePosition(ellipseLeftFoot, leftFoot, false);
SetEllipsePosition(ellipseLeftHand, leftHand, isBackGestureActive);
SetEllipsePosition(ellipseRightHand, rightHand, isForwardGestureActive);
SetImagePosition(punhal, rightHand);
SetImagePosition2(punhal2, leftHand);
// -------------------------------------------------
catch
{
myException(this, new EventArgs());
}
}
这是Microsoft SDK中的一种方法,每当Kinect有效地跟踪骨架时,都会调用该方法。你只需要在我拥有SetEllipsePosition和SetImagePosition的地方把你的代码用于绘画。