Kinect Sdk 2.0 贴图坐标正确吗?

Kinect Sdk 2.0 Mapping Coordinates Correctly?

我希望能够正确映射坐标,以便在我的手在 InkCanvas 上移动时生成一条线。

我目前正在这样使用 DepthSpacePoint:

   DepthSpacePoint depthSpacePoint = this.coordinateMapper.MapCameraPointToDepthSpace(SkeletonPosition);
    jointPoints[jointType] = new Point(depthSpacePoint.X, depthSpacePoint.Y);

对于我的映射,我使用的是:

 /*Use these floats * 1000 to let the user draw on the Canvas*/
                float XSP = joints[JointType.HandRight].Position.X  * 1000;
                float YSP = joints[JointType.HandRight].Position.Y * 1000;

                /*Current Point is = Right Hand Floats * 1000*/
                currentPoint = new Point(XSP, YSP);

                /*Always add 0.1 to the new point to let the user draw, this will technically give a continous line effect as it draws every time the hand moves at a difference of 0.1*/
                nextPoint = new Point(XSP + 0.1, YSP + 0.1);

                /*Feed the Points into the function, Call while Right hand is Tracked*/
                this.Paint(currentPoint, nextPoint, PaintSurface);     

现在我可以在屏幕上画线,但是它没有正确映射到我右手所在的位置,我必须乘以 1000 才能看到 canvas 上的线,我在做什么错误的?我该如何纠正这个问题? 这是我的绘画功能:

    /*Function to Paint/Draw on the Screen*/
    public void Paint(Point startPoint, Point nextPoint, InkCanvas inkcanvas)
    {

        Line line = new Line(); //New Line

        /*If Co-ords are equal to 0,0 reset them*/
        if (currentPoint.X == 0 && currentPoint.Y == 0)
        {
            currentPoint = new Point();
            currentPoint = startPoint;
        }

        /*Colour of the line*/
        line.Stroke = Colour;

        /*Thickness Level*/
        line.StrokeThickness = 10;

        /*Make it less Jagged and Smoother by changing the Stroke Points*/
        line.StrokeDashCap = PenLineCap.Round;
        line.StrokeStartLineCap = PenLineCap.Round;
        line.StrokeEndLineCap = PenLineCap.Round;
        line.StrokeLineJoin = PenLineJoin.Round;

        /*Where to Draw the Line in terms of X and Y Positions*/
        line.X1 = currentPoint.X;
        line.Y1 = currentPoint.Y;
        line.X2 = nextPoint.X;
        line.Y2 = nextPoint.Y;

        /*Current Point = nextPoint*/
        currentPoint = nextPoint;

        /*Add The Line*/
        inkcanvas.Children.Add(line);

    }

我想通了,原来我可以简单地用颜色space点来记录右手的位置,然后在新函数中再次调用它来确定线的绘制点。

正在记录 CSP:

   ColorSpacePoint CSP = this.coordinateMapper.MapCameraPointToColorSpace(Joints[JointType.HandRight]);

然后编辑的函数:

    /*Function to Paint/Draw on the Screen*/
public void Paint(ColorSpacePoint Position, InkCanvas inkcanvas)
{

    Line line = new Line(); //New Line

    /*If Co-ords are equal to 0,0 reset them*/
    if (Position.X == 0 && Position.Y == 0)
    {
        NextPoint = Position
    }

    /*Colour of the line*/
    line.Stroke = Colour;

    /*Thickness Level*/
    line.StrokeThickness = 10;

    /*Make it less Jagged and Smoother by changing the Stroke Points*/
    line.StrokeDashCap = PenLineCap.Round;
    line.StrokeStartLineCap = PenLineCap.Round;
    line.StrokeEndLineCap = PenLineCap.Round;
    line.StrokeLineJoin = PenLineJoin.Round;

    /*Where to Draw the Line in terms of X and Y Positions*/
    line.X1 = Position.X;
    line.Y1 = Position.Y;
    line.X2 = Position.X + 0.01;
    line.Y2 = Position.Y + 0.01;

    /*Add The Line after Scaling*/
   Inkcanvas.SetLeft(line , Position.X - line.Width / 2);
   Ink canvas.SetTop(line, Position.Y - line.Height / 2);

    inkcanvas.Children.Add(line);

}

这将在用户右手所在的任何地方绘制细线,但我决定像这样使用省略号而不是绘制很多细线来形成一条大线:

public void DrawPoint(ColorSpacePoint point)
{
    // Create an ellipse.
    Ellipse ellipse = new Ellipse
    {
        Width = 20,
        Height = 20,
        Fill = Brushes.Red
    };

    // Position the ellipse according to the point's coordinates.
    Canvas.SetLeft(ellipse, point.X - ellipse.Width / 2);
    Canvas.SetTop(ellipse, point.Y - ellipse.Height / 2);

    // Add the ellipse to the canvas.
    canvas.Children.Add(ellipse);
}