whyworry whyworry - 1 month ago 7
C# Question

Kinect properly statement of drawing function

i started the journey with the kinect and i have some sorts of problems, i try to learn from a tutorials and i choose this one here, but i have problem with declaration of DrawTrackedBoneLine and DrawClipedEdges how should be declared to work properly

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);
}
}


I siting and trying with brushes but its not work, it says "The name 'DrawTrackedBoneLine' does not exist in the current context" its obvious that visual is right but how to fix it

Answer

You have not declared the function DrawTrackedBoneLine, hence it 'does not exist in the current context'. I think the code on msdn is just an example, you have to work out how to do the drawing yourself.

Begin by declaring the functions:

private void DrawTrackedBoneLine(SkeletonPoint positionFrom, SkeletonPoint positionTo)
{
    // Code goes here
}

private void DrawNonTrackedBoneLine(SkeletonPoint positionFrom, SkeletonPoint positionTo)
{
    // Code goes here
}