none
How to get coordinate between joint in skeleton using kinect sdk 1.6 RRS feed

  • Question

  • Hi everybody, I need your answer to:

     How to get coordinate between joint in skeleton , i'm using kinect sdk 1.6

    for example 

    I want to get right hand joint coordinate to spine joint coordinate?

    Until now I just can get joint coordinate from position, but it is coordinate joint to kinect camera, not between joint 

    sorry for my bad english


    • Edited by simpleton game Saturday, February 23, 2013 6:03 AM wrong write join to joint
    Saturday, February 23, 2013 6:00 AM

Answers

  • Depending on the result you need, a simple coordinate translation (subtraction) may be sufficient:

    SkeletonPoint RelativeToSpine(Skeleton s, JointType t)
    {
        SkeletonPoint p = s.Joints[t];
        SkeletonPoint spine = s.Joints[JointType.Spine];
        return new SkeletonPoint { X = p.X - spine.X, Y = p.y - spine.Y, Z = p.z - spine.Z };
    }

    This should work well if the user is facing directly toward the sensor. It that's all you need, then you're done.

    If you need to compensate for a user facing a different direction, you'll need to also apply a rotation. You will need to choose a pair of joints that will define the direction the user is facing relative to the sensor. For example, you might decide that the positions of the left and right hips will define the user's rotation relative to the Y axis, and rotate your point accordingly:

    SkeletonPoint LocalJointPosition(Skeleton s, JointType t)
    {
        SkeletonPoint p = RelativeToSpine(s, t);
        SkeletonPoint left = s.Joints[JointType.HipLeft];
        SkeletonPoint right = s.Joints[JointType.HipRight];
        float yRotation = (float)Math.Atan2(left.Z - right.Z, right.X - left.X);
        float cos = (float)Math.Cos(yRotation);
        float sin = (float)Math.Sin(yRotation);
        return new SkeletonPoint { X = (cos * p.X) - (sin * p.Z), Y = p.Y, Z = (sin * p.X) + (cos * p.Z) };
    }

    I haven't tested the code above, so it's possible that I may have a +/- sign wrong in there somewhere. But those are the general principles.


    John | Kinect for Windows development team

    Thursday, February 28, 2013 1:35 AM

All replies

  • Depending on the result you need, a simple coordinate translation (subtraction) may be sufficient:

    SkeletonPoint RelativeToSpine(Skeleton s, JointType t)
    {
        SkeletonPoint p = s.Joints[t];
        SkeletonPoint spine = s.Joints[JointType.Spine];
        return new SkeletonPoint { X = p.X - spine.X, Y = p.y - spine.Y, Z = p.z - spine.Z };
    }

    This should work well if the user is facing directly toward the sensor. It that's all you need, then you're done.

    If you need to compensate for a user facing a different direction, you'll need to also apply a rotation. You will need to choose a pair of joints that will define the direction the user is facing relative to the sensor. For example, you might decide that the positions of the left and right hips will define the user's rotation relative to the Y axis, and rotate your point accordingly:

    SkeletonPoint LocalJointPosition(Skeleton s, JointType t)
    {
        SkeletonPoint p = RelativeToSpine(s, t);
        SkeletonPoint left = s.Joints[JointType.HipLeft];
        SkeletonPoint right = s.Joints[JointType.HipRight];
        float yRotation = (float)Math.Atan2(left.Z - right.Z, right.X - left.X);
        float cos = (float)Math.Cos(yRotation);
        float sin = (float)Math.Sin(yRotation);
        return new SkeletonPoint { X = (cos * p.X) - (sin * p.Z), Y = p.Y, Z = (sin * p.X) + (cos * p.Z) };
    }

    I haven't tested the code above, so it's possible that I may have a +/- sign wrong in there somewhere. But those are the general principles.


    John | Kinect for Windows development team

    Thursday, February 28, 2013 1:35 AM
  • XnVector3D jointPos = jointTrans.position.position;
    XnMatrix3X3 torsoRotMat = jointTrans.orientation.orientation;
    Eigen::Affine3d transform_kinect_joint1;
    Eigen::Matrix4d torsoMat;  

    torsoMat<< torsoRotMat.elements[0], torsoRotMat.elements[1], -torsoRotMat.elements[2], jointPos.X,
    torsoRotMat.elements[3], torsoRotMat.elements[4], -torsoRotMat.elements[5], jointPos.Y,
    -torsoRotMat.elements[6], -torsoRotMat.elements[7], torsoRotMat.elements[8], -jointPos.Z,
    0.0f, 0.0f, 0.0f, 1.0f;

    transform_kinect_joint1 = torsoMat;
    // when you get two transform from kincet to the skeleton joint, then you do
    transform_joint2_joint1 = transform_kinect_joint2.inverse * transform_kinect_joint1;


    Friday, April 26, 2013 8:32 AM