在kinect sdk beta 2中,有一种方法可以获得关节的显示位置。在kinect sdk 1.5中是否有一个方法可以做同样的事情,或者我必须编写一个新的方法吗?
private Point getDisplayPosition(Joint joint)
{
float depthX, depthY;
_kinectNui.SkeletonEngine.SkeletonToDepthImage(joint.Position, out depthX, out depthY);
depthX = Math.Max(0, Math.Min(depthX * 320, 320)); //convert to 320, 240 space
depthY = Math.Max(0, Math.Min(depthY * 240, 240)); //convert to 320, 240 space
int colorX, colorY;
ImageViewArea iv = new ImageViewArea();
// only ImageResolution.Resolution640x480 is supported at this point
_kinectNui.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(ImageResolution.Resolution640x480, iv, (int)depthX, (int)depthY, (short)0, out colorX, out colorY);
// map back to skeleton.Width & skeleton.Height
return new Point((int)(imageContainer.Width * colorX / 640.0) , (int)(imageContainer.Height * colorY / 480) );
}
此方法取自Kinect Skeleton。
答案 0 :(得分:0)
请参阅Converting Kinect Methods from Beta 2, to Version 1了解新的,旧的和工作方法。工作方法是:
private Point getDisplayPosition(DepthImageFrame depthFrame, Joint joint)
{
float depthX, depthY;
DepthImagePoint depthPoint = sensor.MapSkeletonPointToDepth(joint.Position, depthImageFormat);
depthX = depthPoint.X;
depthY = depthPoint.Y;
depthX = Math.Max(0, Math.Min(depthX * 320, 320));
depthY = Math.Max(0, Math.Min(depthY * 240, 240));
int colorX, colorY;
ColorImagePoint colorPoint = depthFrame.MapToColorImagePoint(depthPoint.X, depthPoint.Y, sensor.ColorStream.Format);
colorX = colorPoint.X;
colorY = colorPoint.Y;
return new Point((int)(skeleton.Width * colorX / 640.0), (int)(skeleton.Height * colorY / 480));
}