People often have difficulty getting started with Kinect programming. This VS 2012 project template for WPF and C# stubs out many standard patterns developed over the months since the Kinect SDK was first released including setting up stream event handlers, deallocating streams and closing the sensor, gracefully handling situations like accidentally unplugging the Kinect sensor.
This project template will work with both the Kinect 4 Windows sensor as well as the standard Xbox Kinect sensor for development mode.
- People often have difficulty getting started with Kinect programming. This VS 2012 project template for WPF and C# stubs out many standard patterns developed over the months since the Kinect SDK was first released including setting up stream event handlers, deallocating streams and closing the sensor, gracefully handling situations like accidentally unplugging the Kinect sensor.
- Microsoft has released latest version of Kinect SDK for Windows and Kinect Developer Toolkit for Windows. The Kinect for Windows Software Development Kit (SDK) enables developers to create applications that support gesture and voice recognition, using Kinect sensor technology on computers running Windows 7, Windows 8, Windows 8.1, and Windows.
The template additionally includes extension methods for the Kinect Sensor object that makes it easy to create a green screen (background subtraction) image, a color blob image, or draw a player skeleton.
These are provided to make it easier to replicate the most common visualization scenarios for presentations or quick prototypes. The extension methods are based on the ones I originally wrote for the Apress bookBeginning Kinect Programming with the Microsoft Kinect SDK.
A deeper discussion of the capabilities of this project template can be found here.
Installed - using it to detect the hands in 3D space. The Kinect for Windows Developer Toolkit contains updated and new source code samples, Kinect Fusion, Kinect Interactions, Kinect Studio, and other resources to simplify developing Kinect for Windows applications.
Following are some key features:
1. Initialization Code
All the initialization code and Kinect stream event handlers are stubbed out in theInitSensor method. All you need to do is uncomment the streams you want to use. Additionally, the event handler code is also stubbed out with the proper pattern for opening and disposing of frame objects. Whatever you need to do with the image, depth and skeleton frames can be done inside those using statements. This code also uses the latest agreed upon best practices for efficiently managing streamed data as of the 1.7 SDK.
2. Disposal Code
Whatever you enable in the InitSensor method you will need to disable and dispose of in theDeInitSensor method. Again, this just requires uncommenting the appropriate lines. TheDeInitSensor also implements a disposal pattern that is somewhat popular now. The sensor is actually shut down on a background thread rather than on the main thread. I’m not sure if this is a best practice as such, but it resolves a problem many C# developers were running into in shutting down their Kinect-enabled applications.
3. Status Changed Code
The Kinect can actually be disconnected in mid-process or simply not be on when you first run an application. It is also surprisingly common to forget to plug the Kinect’s power supply in. Generally, your application will just crash in such situations. If you properly handle the KinectSensors.StatusChanged event, however, your application will just start up again when you get the sensor plugged back in. A pattern for doing this was first introduced in the KinectChooser component in the Developer Toolkit. A lightweight version of this pattern is included in the Kinect Application Project Template.
4. Extension Methods
Mac os x lion 10.7 5 11g63 upgrade. While most people were working on controls for the Kinect 4 Windows SDK, Clint Rutkas and the Coding4Fun guys brilliantly came up with the idea of developing extension methods for handling the various Kinect streams.
Kinect Windows Developer Toolkit V1.8
The extension methods included with this template provide lots of conversions from bitmaps byte arrays toBitmapSource types (useful for WPF image controls) and vice-versa. This allows you to do something easy like display a color stream which otherwise can be rather hairy. The snippet below assumes there is an image control in theMainWindow named canvas.
Microsoft Kinect Sdk 1.8
More in line with the original Coding4Fun Toolkit, the extension methods also make some very difficult scenarios trivial – for instance background subtraction (also known as green screening), skeleton drawing, player masking. These methods should make it easier for quickly mock up a demo or even show off the power of the Kinect in the middle of a presentation using just a few lines of code.