-1

Possible Duplicate:
Converting Kinect Methods from Beta 2, to Version 1

In kinect sdk beta 2, there is a method to get display position of joints. Is there a method at kinect sdk 1.5 which does the same thing or must i write a new method?

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

this method is taken from Kinect Skeleton.

Community
  • 1
  • 1
hellzone
  • 5,393
  • 25
  • 82
  • 148
  • 1
    See http://stackoverflow.com/questions/10367582/converting-kinect-methods-from-beta-2-to-version-1, as it is the same question and has an answer. – Liam McInroy Jul 10 '12 at 12:52
  • I was busy typing an answer to your `FullAjaxExceptionHandler` question and you deleted it .. :) Well, the answer is covered by http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener/3909382#3909382 – BalusC Jun 25 '13 at 11:42
  • @BalusC Sorry :D I just realize that problem is about ajax and non-ajax buttons. http://stackoverflow.com/questions/17296420/primefaces-fullajaxexceptionhandler-ajax-request – hellzone Jun 25 '13 at 11:46
  • In your deleted question, you was clearly using `actionListener` instead of `action`. Exceptions which you throw from action listeners do not trigger the error page. Carefully read the link in my previous comment to the bottom. – BalusC Jun 25 '13 at 11:49

1 Answers1

0

See Converting Kinect Methods from Beta 2, to Version 1 for the new, old, and working methods. The working method is:

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));
}
Community
  • 1
  • 1
Liam McInroy
  • 4,339
  • 5
  • 32
  • 53