Skeleton & Gestures Kinect v2 SDK Sample Code, VB.NET'ed
Martyn Atkins (C9 Profile), interested in the Kinect for Windows v2 is more of a VB.NET guy than C#. So he's taken it upon himself to rework some of the samples into VB.NET.
Best of all he's sharing that with all of us!
This code sample is my own re-working into Visual Basic of a some classes from the C# DiscreetGestureBasics-WPF sample code included in the Kinect for Windows SDK 2.0 Public Preview. The code handles skeletal processing and display plus discrete gesture recognition.
The code I've written and provided here is a work in progress, so I'm providing it purely as a good headstart for VB.NET coders delving into the SDK since the current examples are are present in C#. Please forgive any hack-and-slash coding shortcuts as this is very much a work in progress and very much prototype code :) That said, feedback and comments are welcome.
Building the Sample
You'll need Visual Studio 2013 (or VS 2012 with some tweaking) to open, compile and run the sample code in the solution. It's set-up for .NET 4.5 and 64-bit compilation. Of course, you'll also need the latest Kinect v2 for Windows SDK 2.0 Public Preview (the code provided references build 1409 of the v2 SDK public preview).
Visual Studio Solution references (may need updating if the SDK changes path):
The sample will compile and run, displaying live skeletal data in a simple Windows Forms application. The skeletal tracker class (GestureDetector.vb) generates live skeletal data from the bodies tracked by the Kinect Sensor and uses their skeletal points to draw output bitmap images frame-by-frame (as Bitmap objects) in real time when a valid Kinect v2 sensor is detected.
At the moment, the gesture detection class (GestureDetector.vb) is ready-to-go, but not yet being used in the sample code provided. You'll need to build your own gesture database using the SDK Visual Gesture Builder and alter the code to detect your gestures from that database. You'll see from the code that my sample is eventually going to track some left and right footed "kicking" gestures for a psychological response experiment.
Source Code Files
- StartScreen.vb - The main GUI (Windows Forms) screen for displaying things.
- SkeletalTracker.vb - This class parses Kinect skeletal and hand-tracking data and outputs skeleton display frames as live sequences of bitmap images (snippet below):
- GestureDetector.vb - The gesture detection class (set up for discrete gestures, but could easily be adapted for continuous ones). Currently not in use, but is ready to go with little modification. Sample of gesture detection method shown below
Essential viewing and reading:
Project Information URL: https://code.msdn.microsoft.com/Kinect-v2-SDK-Sample-Code-67fc213b
Project Source URL: https://code.msdn.microsoft.com/Kinect-v2-SDK-Sample-Code-67fc213b