我用kinect开始了旅程,我遇到了一些问题,我尝试从教程中学习并选择这一个here,但我对DrawTrackedBoneLine和DrawClipedEdges的声明有问题应该如何声明正常工作
private void DrawBone(Joint jointFrom, Joint jointTo)
{
Brush bone = null;
Brush TrackedBone = new SolidColorBrush(Color.FromArgb(132, 54, 63, 78));
Brush NonTracked = new SolidColorBrush(Color.FromArgb(45, 36, 23, 12));
if (jointFrom.TrackingState == JointTrackingState.NotTracked ||
jointTo.TrackingState == JointTrackingState.NotTracked)
{
return; // nothing to draw, one of the joints is not tracked
}
if (jointFrom.TrackingState == JointTrackingState.Inferred ||
jointTo.TrackingState == JointTrackingState.Inferred)
{
DrawNonTrackedBoneLine (jointFrom.Position, jointTo.Position); // Draw thin lines if either one of the joints is inferred
}
if (jointFrom.TrackingState == JointTrackingState.Tracked &&
jointTo.TrackingState == JointTrackingState.Tracked)
{
DrawTrackedBoneLine(jointFrom.Position, jointTo.Position); // Draw bold lines if the joints are both tracked
}
}
private void RenderClippedEdges(Skeleton skeleton)
{
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Bottom))
{
DrawClippedEdges(FrameEdges.Bottom); // Make the border red to show the user is reaching the border
}
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Top))
{
DrawClippedEdges(FrameEdges.Top);
}
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Left))
{
DrawClippedEdges(FrameEdges.Left);
}
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Right))
{
DrawClippedEdges(FrameEdges.Right);
}
}
我选择并尝试使用画笔,但它不起作用,它说“当前上下文中不存在名称'DrawTrackedBoneLine'”显然视觉是正确的,但如何解决它
答案 0 :(得分:0)
您尚未声明函数DrawTrackedBoneLine,因此它“在当前上下文中不存在”。我认为msdn上的代码只是一个例子,你必须自己解决如何绘图的问题。
首先声明函数:
private void DrawTrackedBoneLine(SkeletonPoint positionFrom, SkeletonPoint positionTo)
{
// Code goes here
}
private void DrawNonTrackedBoneLine(SkeletonPoint positionFrom, SkeletonPoint positionTo)
{
// Code goes here
}