0
我希望能夠正確地映射座標,以便在InkCanvas移動時我的手在其上生成一條線。Kinect Sdk 2.0地圖座標正確嗎?
我目前使用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才能看到畫布上的線條,我做錯了什麼?我該如何糾正? 這是我的畫圖功能:
/*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);
}