Skeleton class

This class offers a convenient way to convert the skeleton data frames received by a Kinect sensor into a Skeleton object, which can be rendered in openGL as a stick figure using JogAmp's JOGL Java library. The use of JOGL library is optional and is not required if you don't use the drawing method provided in the Skeleton class.

This class is part of the J4K library, which is included in the University of Florida Digital Worlds (ufdw.jar) Java library. This library was developed by Prof. Angelos Barmpoutis, and further extended by the students and faculty who work in the SAGE program (Serious and Applied Gaming Environments) at the Digital Worlds Institute. You can find more information about how to join our graduate and undergraduate programs at this link (

If you use this Java library in your research, please cite the following article, which introduced this library:
A. Barmpoutis. 'Tensor Body: Real-time Reconstruction of the Human Body and Avatar Synthesis from RGB-D', IEEE Transactions on Cybernetics, Special issue on Computer Vision for RGB-D Sensors: Kinect and Its Applications, October 2013, Vol. 43(5), Pages: 1347-1356. Download PDF - Kinect Avatars paper [VIDEO DEMO]

package edu.ufl.digitalworlds.j4k;

public class Skeleton {

The following method constructs an empty Skeleton object.

    /*This method constructs an empty Skeleton.*/    
    public Skeleton();

Alternatively, you can use the following static methods to create Skeleton objects from the Kinect data, or create a skeleton in a default natural stance.

    /*This method returns a Skeleton in a default stance (standing person 
      with open hands).*/

    public static Skeleton defaultStance();

    /*These methods convert the skeleton frame data received from a Kinect
      sensor to a Skeleton object.*/

    public static Skeleton getSkeleton(int id, boolean[] flags, float[] positions,
 float[] orientations, byte[] states, J4KSDK kinect);
    public static Skeleton getSkeleton(int id, boolean[] flags, float[] positions,
 float[] orientations, byte[] states, byte type);
    public static Skeleton getSkeleton(int id, boolean[] flags, float[] positions,
 float[] orientations, byte[] states, J4K1 kinect);
    public static Skeleton getSkeleton(int id, boolean[] flags, float[] positions,
 float[] orientations, byte[] states, J4K2 kinect);

The Skeleton class contains several methods for accessing the skeleton data (joint coordinates and various flags or IDs).

    /*With this method you can update the skeleton by providing
      the joint positions received by a Kinect sensor.*/

    public void setJointPositions(float joint_positions[]);

    /*This method returns the current joint positions of the

    public float[] getJointPositions();

    /*With this method you can update the skeleton by providing
      the joint orientations received by a Kinect sensor.*/

    public void setJointOrientations(float joint_orientations[]);

    /*This method returns the current joint orientations of the

    public float[] getJointOrientations();

    /*With this method you can update the current 
      joint tracking states of the skeleton.*/

    public void setJointTrackingStates(byte joint_state[]);

    /*This method returns the current joint tracking states of the

    public byte[] getJointTrackingStates();

    /*This method returns the X coordinate of a particular
      joint in the Skeleton.*/

    public float get3DJointX(int joint_id);
    /*This method returns the Y coordinate of a particular
      joint in the Skeleton.*/

    public float get3DJointY(int joint_id);
    /*This method returns the Z coordinate of a particular
      joint in the Skeleton.*/

    public float get3DJointZ(int joint_id);
    /*This method returns the X,Y,Z coordinates of a particular
      joint in the Skeleton as a double array of size 3.*/

    public double[] get3DJoint(int joint_id);

    /*This method returns the 2D projection of a particular joint projected on an
      image of a given pixel width and height. The method returns the X,Y pixel
      coordinates of the projected joint in the Skeleton as an int array of size 2.*/

    public int[] get2DJoint(int joint_id, int width, int height);

    /*With this method you can set the 'IsTracked' flag.*/
    public void setIsTracked(boolean skeleton_tracked);    

    /*This method returns the current value of the 'IsTracked'

    public boolean isTracked();
    /*This method returns true if the Joint is
      either tracked or inferred.*/

    public boolean isJointTrackedOrInferred();
    /*This method returns true only if the joint
      is tracked.*/

    public boolean isJointTracked();
    /*With this method you can set the player ID that corresponds
      to this Skeleton.*/
    public void setPlayerID(int id);
    /*This method returns the current player ID associated with 
      this Skeleton.*/

    public int getPlayerID();

    /*This method returns the value of the 'TimesDrawn' counter.*/    
    public int getTimesDrawn(){return times_drawn;}
    /*This method increases by 1 the 'TimesDrawn' counter.*/
    public void increaseTimesDrawn(){times_drawn+=1;}

You can also display a skeleton as a simple stick-man model using the following method.

    /*This method displays the Skeleton as a stick figure. It requires
      the JOGL Java library.*/

    public void draw(GL2 gl);

The Skeleton class also contains several auxiliary methods for reading the orientation of various body parts. These methods can be used in various human-computer interaction applications.

    /*The following methods compute the orientations and transformations
      of various body parts, which may be used for human-computer interaction.*/

    public double getBodyOrientation();
    public double[] getTorsoOrientation();
    public double[] getRelativeNUICoords();
    public double getTorsoTransform(double[] transf, double[] inv_transf);
    public double getHeadTransform(double[] transf, double[] inv_transf);
    public double getFixHeadTransform(double[] transf, double[] inv_transf);
    public double getShoulderTransform(double[] transf, double[] inv_transf);
    public double getBetweenHandsTransform(double[] transf, double[] inv_transf);
    public double getRightThighTransform(double[] transf, double[] inv_transf);
    public double getLeftThighTransform(double[] transf, double[] inv_transf);
    public double getRightLegTransform(double[] transf, double[] inv_transf);
    public double getLeftLegTransform(double[] transf, double[] inv_transf);
    public double getRightArmTransform(double[] transf, double[] inv_transf);
    public double getLeftArmTransform(double[] transf, double[] inv_transf);
    public double getRightForearmTransform(double[] transf, double[] inv_transf);
    public double getLeftForearmTransform(double[] transf, double[] inv_transf);    

Finally, the Skeleton class contains several constant integers that enumerate the joints in the skeleton model.

    /*The following constant values enumerate the tracking state of the joints.*/
    public final static byte NOT_TRACKED=0;
    public final static byte INFERRED=1;
    public final static byte TRACKED=2;

    /*The following constant values enumerate the joints in the skeleton.*/
    public final static int SPINE_BASE=0;
    public final static int SPINE_MID=1;
    public final static int NECK=2;
    public final static int HEAD=3;
    public final static int SHOULDER_LEFT=4;
    public final static int ELBOW_LEFT=5;
    public final static int WRIST_LEFT=6;
    public final static int HAND_LEFT=7;
    public final static int SHOULDER_RIGHT=8;
    public final static int ELBOW_RIGHT=9;
    public final static int WRIST_RIGHT=10;
    public final static int HAND_RIGHT=11;
    public final static int HIP_LEFT=12;
    public final static int KNEE_LEFT=13;
    public final static int ANKLE_LEFT=14;
    public final static int FOOT_LEFT=15;
    public final static int HIP_RIGHT=16;
    public final static int KNEE_RIGHT=17;
    public final static int ANKLE_RIGHT=18;
    public final static int FOOT_RIGHT=19;
    public final static int SPINE_SHOULDER=20;
    public final static int HAND_TIP_LEFT=21;
    public final static int THUMB_LEFT=22;
    public final static int HAND_TIP_RIGHT=23;
    public final static int THUMB_RIGHT=24;
    public final static int JOINT_COUNT=25;

What to do next:
  • You can download several source code examples from the Source Code Examples website.
  • You can also read a brief tutorial on "How to write your own Kinect-Java programs".

  • Disclaimer: The names JAVA and KINECT and their associated logos are trademarks of their respective copyright owners Oracle and Microsoft. None of these companies endorse, fund, or are in any way associated with the J4K library.

    Disclaimer: This software is provided for free without any warranty expressed or implied for academic, research, and strictly non commercial purposes only. By downloading this library you accept the Terms and Conditions.

    University of Florida, Digital Worlds Institute, P.O.Box 115810, 101 Norman Gym, Gainesville, FL 32611-5810, USA