Weight-Lifting Bar Detection with the Kinect
Vangos Pterneas is back with something I don't think I've seen before, using the Kinect to detect a weight-lifting bar. Just seeing sparks a number of interesting ideas... hummmm
Any weight-lifters reading this blog? If you are trying to combine technology with your daily weight-lifting exercise, look no further. Today, I’ll show you how to recognize a weight-lifting bar and display its distance from the floor using Kinect. This way, you’ll be able to track your progress and check how great you are performing, day after day. Here is a video of what we are going to accomplish after finishing this tutorial — please keep in mind that I’m an engineer, not a body-builder!
Cool, huh? Let’s see how to implement it in code…
- Kinect for XBOX v2 sensor with an adapter (or Kinect for Windows v2 sensor)
- Kinect for Windows v2 SDK
- Windows 8.1 or higher
- Visual Studio 2013 or higher
- A dedicated USB 3 port
Video & Source Code
As usual, I’m providing you with the complete source code, as well as a demo video.
The Bar Detection Algorithm
The heart of our algorithm is the BarDetectionEngine class. This class encapsulates all of the required details I’m going to cover below. I am not going to present the complete source code, since it’s more than 500 lines of C# code. I am rather going to explain the thought process and the logic behind the code.
In short, the algorithm consists of the following steps:
- Get the array of the raw depth data
- Get the array of the body-index data
- Detect the position of the Hand joints
- Find the depth points that have the same distance to the hand joints
- Exclude the depth points that belong to the body
- Smooth the values and set thresholds
- Process the resulting points to calculate the distance/height/angle of the bar
And, this is it, folks. You can explore the source code to see how I’m visualizing the bar and how I measure various other properties. The purpose of this tutorial is to showcase the power of processing raw depth frames using Kinect SDK v2.
Using the BarDetectionEngine
All of the above functionality has been encapsulated into a single class – BarDetectionEngine. You can use the BarDetectionEngine as follows:
“Wait! Do I need a weight lifting bar to try this?”
Well, not really. You do not need to have a weight lifting bar in your house or office. An ordinary broomstick would do the job just fine!
‘Til the next time, keep Kinecting!
If you enjoyed this article, consider checking Vitruvius. Vitruvius is a set of powerful Kinect extensions that will help you build stunning Kinect apps in minutes. Vitruvius includes avateering, HD Face, background removal, angle calculations, and more. Check it now.
Project Information URL: http://pterneas.com/2016/05/17/weight-lifting-bar-kinect/
Project Source URL: https://github.com/LightBuzz/kinect-weight-lifting-bar