none
Kinect v2.0 get Hierarchical joint orientation C# RRS feed

  • Question

  • Hi,

    I'd like to know how to get Hierarchical joint orientations in Kinect SDK V2.0.

    Thanks in advance,

    Sohaib


    • Edited by sohaib-l Wednesday, August 13, 2014 1:05 PM
    Wednesday, August 13, 2014 12:53 PM

Answers

  • The second jump start video (around 34:40) had an image of the hierarchy of joints:

    The code I use for a joint hierarchy (C++) is as follows, with the function updateParentFromType() being the part that created the hierarchy, joining the current joint type to its parent:

    class Joint
    {
    public:
      enum Type
      {
        SpineBase = 0, // the only joint without a parent
        SpineMid = 1,
        Neck = 2,
        Head = 3,      // no orientation (unless face tracking used)
        ShoulderLeft = 4,
        ElbowLeft = 5,
        WristLeft = 6,
        HandLeft = 7,
        ShoulderRight = 8,
        ElbowRight = 9,
        WristRight = 10,
        HandRight = 11,
        HipLeft = 12,
        KneeLeft = 13,
        AnkleLeft = 14,
        FootLeft = 15,     // no orientation
        HipRight = 16,
        KneeRight = 17,
        AnkleRight = 18,
        FootRight = 19,    // no orientation
        SpineShoulder = 20,
        HandTipLeft = 21,  // no orientation
        ThumbLeft = 22,    // no orientation
        HandTipRight = 23, // no orientation
        ThumbRight = 24,   // no orientation

        TypeCount = 25,
        TypeInvalid = -1
      };

      enum Tracking
      {
        NotTracked = 0,
        Inferred = 1,
        Tracked = 2
      };

      Type type = TypeInvalid; // joint type, used as an index into Body::joints
      Type parent = TypeInvalid; // parent joint, set to SpineBase for SpineBase
      Tracking track = NotTracked; // state of the joint tracking
      cv::Point3f pos = {0, 0, 0}; // 3D camera-space position of the joint
      cv::Vec4f orient = {0, 0, 0, 0}; // orientation of the bone before this joint, though zero for end joints

      void updateParentFromType()
      {
      switch (type) {

      //
      // Spine from spine base up to head.
      // NOTE: SpineBase is the only joint without a parent.
      //
      case SpineBase: parent = SpineBase; break;
      case SpineMid: parent = SpineBase; break;
      case SpineShoulder: parent = SpineMid; break;
      case Neck: parent = SpineShoulder; break;
      case Head: parent = Neck; break;

      //
      // Left arm from shoulder-level spine.
      //
      case ShoulderLeft: parent = SpineShoulder; break;
      case ElbowLeft: parent = ShoulderLeft; break;
      case WristLeft: parent = ElbowLeft; break;
      case HandLeft: parent = WristLeft; break;
      case HandTipLeft: parent = HandLeft; break;
      case ThumbLeft: parent = HandLeft; break;

      //
      // Right arm from shoulder-level spine.
      //
      case ShoulderRight: parent = SpineShoulder; break;
      case ElbowRight: parent = ShoulderRight; break;
      case WristRight: parent = ElbowRight; break;
      case HandRight: parent = WristRight; break;
      case HandTipRight: parent = HandRight; break;
      case ThumbRight: parent = HandRight; break;

      //
      // Left leg from spine base down.
      //
      case HipLeft: parent = SpineBase; break;
      case KneeLeft: parent = HipLeft; break;
      case AnkleLeft: parent = KneeLeft; break;
      case FootLeft: parent = AnkleLeft; break;

      //
      // Right leg from spine base down.
      //
      case HipRight: parent = SpineBase; break;
      case KneeRight: parent = HipRight; break;
      case AnkleRight: parent = KneeRight; break;
      case FootRight: parent = AnkleRight; break;
      }
      }
    };


    • Proposed as answer by sault Sunday, August 17, 2014 9:47 PM
    • Edited by sault Sunday, August 17, 2014 10:38 PM
    • Marked as answer by sohaib-l Monday, August 18, 2014 7:57 AM
    Sunday, August 17, 2014 9:39 PM

All replies

  • You have to walk the chain of joints starting from the spine base. There are other threads that discuss orientation that may provide more information.

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=kinectv2sdk&sort=relevancedesc&brandIgnore=True&searchTerm=joint+orientations


    Carmine Sirignano - MSFT

    Thursday, August 14, 2014 6:52 PM
  • Thank you for your Answer Carmine,

    from what I've read, Kinect SDK 2.0 gives only the Hierarchical orientations, but is there a way to get the joint hierarchy? for instance, for the 1.8 version, we have this hierarchy (the pictures below), but as long as we don't have the same joints with the V2.0, I didn't find the joint Hierarchy!

    thank you in advance,

    Sohaib

    Sunday, August 17, 2014 7:21 PM
  • The second jump start video (around 34:40) had an image of the hierarchy of joints:

    The code I use for a joint hierarchy (C++) is as follows, with the function updateParentFromType() being the part that created the hierarchy, joining the current joint type to its parent:

    class Joint
    {
    public:
      enum Type
      {
        SpineBase = 0, // the only joint without a parent
        SpineMid = 1,
        Neck = 2,
        Head = 3,      // no orientation (unless face tracking used)
        ShoulderLeft = 4,
        ElbowLeft = 5,
        WristLeft = 6,
        HandLeft = 7,
        ShoulderRight = 8,
        ElbowRight = 9,
        WristRight = 10,
        HandRight = 11,
        HipLeft = 12,
        KneeLeft = 13,
        AnkleLeft = 14,
        FootLeft = 15,     // no orientation
        HipRight = 16,
        KneeRight = 17,
        AnkleRight = 18,
        FootRight = 19,    // no orientation
        SpineShoulder = 20,
        HandTipLeft = 21,  // no orientation
        ThumbLeft = 22,    // no orientation
        HandTipRight = 23, // no orientation
        ThumbRight = 24,   // no orientation

        TypeCount = 25,
        TypeInvalid = -1
      };

      enum Tracking
      {
        NotTracked = 0,
        Inferred = 1,
        Tracked = 2
      };

      Type type = TypeInvalid; // joint type, used as an index into Body::joints
      Type parent = TypeInvalid; // parent joint, set to SpineBase for SpineBase
      Tracking track = NotTracked; // state of the joint tracking
      cv::Point3f pos = {0, 0, 0}; // 3D camera-space position of the joint
      cv::Vec4f orient = {0, 0, 0, 0}; // orientation of the bone before this joint, though zero for end joints

      void updateParentFromType()
      {
      switch (type) {

      //
      // Spine from spine base up to head.
      // NOTE: SpineBase is the only joint without a parent.
      //
      case SpineBase: parent = SpineBase; break;
      case SpineMid: parent = SpineBase; break;
      case SpineShoulder: parent = SpineMid; break;
      case Neck: parent = SpineShoulder; break;
      case Head: parent = Neck; break;

      //
      // Left arm from shoulder-level spine.
      //
      case ShoulderLeft: parent = SpineShoulder; break;
      case ElbowLeft: parent = ShoulderLeft; break;
      case WristLeft: parent = ElbowLeft; break;
      case HandLeft: parent = WristLeft; break;
      case HandTipLeft: parent = HandLeft; break;
      case ThumbLeft: parent = HandLeft; break;

      //
      // Right arm from shoulder-level spine.
      //
      case ShoulderRight: parent = SpineShoulder; break;
      case ElbowRight: parent = ShoulderRight; break;
      case WristRight: parent = ElbowRight; break;
      case HandRight: parent = WristRight; break;
      case HandTipRight: parent = HandRight; break;
      case ThumbRight: parent = HandRight; break;

      //
      // Left leg from spine base down.
      //
      case HipLeft: parent = SpineBase; break;
      case KneeLeft: parent = HipLeft; break;
      case AnkleLeft: parent = KneeLeft; break;
      case FootLeft: parent = AnkleLeft; break;

      //
      // Right leg from spine base down.
      //
      case HipRight: parent = SpineBase; break;
      case KneeRight: parent = HipRight; break;
      case AnkleRight: parent = KneeRight; break;
      case FootRight: parent = AnkleRight; break;
      }
      }
    };


    • Proposed as answer by sault Sunday, August 17, 2014 9:47 PM
    • Edited by sault Sunday, August 17, 2014 10:38 PM
    • Marked as answer by sohaib-l Monday, August 18, 2014 7:57 AM
    Sunday, August 17, 2014 9:39 PM
  • Thank you for your answer Sault! this is what I was looking for!
    Monday, August 18, 2014 7:58 AM