我已经研究了好几天了,但没有成功,看看其他问题是堆栈溢出是我的来源之一。我正在使用 Kinect for Windows 创建一个程序,它将跟踪用户的关节并在单独的“屏幕”上绘制骨架,我已经映射了关节本身,并且我正在使用图像(红点)来演示位置映射的关节。
我的下一步是通过从一个关节到另一个关节画一条线来构建骨架本身,我遇到的问题是如何画线......我倾向于使事情过于复杂,所以我想知道我是否只是在制作对自己来说困难的事情,而不是仅仅找到最简单的解决方案。
我觉得我已经完成了 99% 的工作,但我仍然遇到一个我无法理解的错误,请在错误消息和相关的 C# 代码下方找到。
"cannot convert from 'Microsoft.Kinect.SkeletonPoint' to 'System.Windows.Point"
代码:
private void DrawBone (Joint jointFrom, Joint jointTo)
{
Brush centerPointBrush;
Pen trackedBonePen = new Pen(Brushes.White, TrackedBoneThickness);
inferredBonePen = new Pen(Brushes.Gray, InferredBoneThickness);
DrawingVisual visual = new DrawingVisual();
DrawingContext context = visual.RenderOpen();
centerPointBrush = Brushes.Red;
if (jointFrom.TrackingState == JointTrackingState.NotTracked
|| jointTo.TrackingState == JointTrackingState.NotTracked)
{
return;
}
if (jointFrom.TrackingState == JointTrackingState.Inferred
|| jointTo.TrackingState == JointTrackingState.Inferred)
{
context.DrawLine(inferredBonePen,jointFrom.Position, jointTo.Position);
}
if (jointFrom.TrackingState == JointTrackingState.Tracked
|| jointTo.TrackingState == JointTrackingState.Tracked)
{
context.DrawLine(trackedBonePen, jointFrom.Position, jointTo.Position);
}
}
与开头的行相关的错误context.DrawLine
,因为这些是DrawLine
函数的不正确参数,我得到一个伴随的错误:
Error 4 The best overloaded method match for
'System.Windows.Media.DrawingContext.DrawLine(System.Windows.Media.Pen,
System.Windows.Point, System.Windows.Point)' has some invalid arguments