Put down the measuring tape. Using the Kinect to find your height

Description

When I saw this, the first thing I thought was just how cool a thing an amusement park could build with this. Gone could be the days of the "You must be taller than this bar," instead replaced with an interactive, themed for the park, height measurement experience. Image standing there with a virtual Mickey or Donald or Bugs Bunny and using the Kinect to measure your children's height, compared to them? (Can't you just see Mickey holding up his virtual hand over a child's head and saying, "Great! You made it? I can't wait to see you..." or a sad Mickey when the child isn't tall enough?)

Kinect for Windows: Find user height accurately

Some people ask me if there is a way to determine the height of a user standing in front of a Kinect device. The answer is definitely positive: We can detect the user's height regardless of her distance from the sensor! We only need some very basic Math knowledge. Let's find out more...

The algorithm of finding the user's height

Kinect provides you with the coordinates (X, Y and Z) of 20 skeleton joints. Someone might think that a person's height is the distance from the head joint to a foot joint, right? Wrong! Your users might stand in bended knees, they might lean a bit to the left or to the right. If you try to calculate the distance defined from the head joint to one of the foot joints, you'll get a far from accurate result.

Another point of interest is that Kinect gives you the center of the head joint. This means that you'll need to add 9 - 12 centimetres to the calculated height. You won't be able to calculate the total height with 100% accuracy. If you need more accuracy, you'll need to detect the end of the head using the depth stream. Not that difficult, but let's focus on the skeleton stream right now.

If you examine the human skeleton joints a little more carefully, you'll notice that the height is the sum of the lengths of the following line segments:

  • Head - ShoulderCenter
  • ShoulderCenter - Spine
  • Spine - HipCenter
  • HipCenter - KneeLeft or KneeRight
  • KneeLeft / KneeRight - AnkleLeft / AnkleRight
  • AnkleLeft / AnkleRight - FootLeft / FootRight

Project Information URL: http://studentguru.gr/b/vangos/archive/2012/05/07/kinect-for-windows-find-user-height-accurately.aspx

Project Download URL: http://studentguru.gr/cfs-file.ashx/__key/telligent-evolution-components-attachments/01-1119-00-00-00-13-54-17/KinectUserHeight.zip

Project Source URL: http://studentguru.gr/cfs-file.ashx/__key/telligent-evolution-components-attachments/01-1119-00-00-00-13-54-17/KinectUserHeight.zip

image

Finally, you can use this extension method within a custom application easily:

void Sensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
    using (var frame = e.OpenSkeletonFrame())
    {
        if (frame != null)
        {
            Skeleton[] skeletons = new Skeleton[frame.SkeletonArrayLength];
            frame.CopySkeletonDataTo(skeletons);

            var skeleton = skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault();

            if (skeleton != null)
            {
                double height = skeleton.Height();
            }
        }
    }
}

You can now integrate this code to your own applications and find out the user's height! Download the complete WPF application in order to see it in action right now!

Enjoy kinecting!

Contact Information:

 

Update 12/24/2013: Links to the download updated...

The Discussion

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.