-1

可能重复:
将 Kinect 方法从 Beta 2 转换为版本 1

在 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。

4

1 回答 1

0

有关新的、旧的和工作方法,请参阅将 Kinect 方法从 Beta 2 转换为版本 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));
}
于 2012-07-10T12:57:28.863 回答