Page 1 of 4
This e-book is for Version 1.0 of the Kinect SDK together with the Windows version of the Kinect hardware. It brings together articles in the series Getting started with Microsoft Kinect SDK which was based on the final beta of the SDK. These articles are still available.
Practical Windows Kinect in C#
Practical Windows Kinect in C#
- Introduction to Kinect
- Getting started with Microsoft Kinect SDK 1
- Using the Depth Sensor
- The Player Index
- Depth and Video Space
- The Full Skeleton
- A 3D Point Cloud
The Microsoft official SDK for Kinect version 1.0 is easy to use. Basically you download it, plug the Kinect into a free USB socket and start programming. You can create applications in C#, VB or any .NET language including C++. Its only disadvantage is that it only works with Windows 7 and 8.
As well as being easy to use, the new SDK is also significantly more powerful than the open source alternatives. It has an improved body tracker and it supports the Kinect's sound hardware.
You can also now use the SDK to create commercial applications which you can sell without the need to pay a licence fee to Microsoft. The only downside is that you have to buy the Windows Kinect rather than the Xbox 360 version, and this is more expensive because it isn't subsidized by revenue from games.
Currently the SDK does work with the Xbox 360 version of the Kinect but some features - near mode, for example - are not supported. If you want to make full use of the SDK then you really do need the Windows version.
It is also worth noting that, while you can use the Xbox 360 version with the development environment, the runtime environment will reject it and request a Windows Kinect. What this means is that you can use a cheap Kinect Xbox 360 to get started, but once you have perfected your application you need to move to the Windows device to make use of it.
In this chapter we look at how easy it is to start writing software using C#.
First you need to prepare the hardware and this isn't without its difficulties.
Using the Xbox 360 Kinect
If you need to make use of the Xbox version of the Kinect then you will have to make some adjustments to the hardware. If you are using the Windows version then you simply plug the device in as it is made to work with a standard USB connector.
If you look at the plug on the end of the cable that comes out of the Kinect you will realise that what you have looks like a USB connector but not quite. The connector used is a proprietary connector designed to allow the Kinect to be plugged into the new black Xbox 360 without the use of an external power supply. Older Xboxes don't have the special connector and they come with an external power supply which has an adaptor to convert the Kinect plug into a standard USB connector and power supply connector.
If you have bought a Kinect with a recent Xbox as a bundle then you will need to buy the adaptor/power supply. At the moment these are only available from the Microsoft store. If you go to:
then you should be able to select a local version of the store from the list if you are not in the US. To find the appropriate power supply search on Kinect Sensor Power Supply. The unit costs less than $20 but be warned they seem to go out of stock very quickly. At the moment there are no 3rd party adaptors but this is likely to change.
If you can't wait for the unit to be back in stock or if you want to make something custom then it is quite easy to work out the pin connections:
If you look at the end of the connector pin 1 is next to the beveled corner with pins 2 to 5 next to it and pin 6 below it. You can, of course, do the job by cutting the cable and wiring a 12V supply and a standard USB connector.
Once you have solved the problem of plugging the Kinect in, your next step is to download the software. This is trivial. Go to Download the SDK and allow the installer to run, it automatically installs the correct version for your hardware. Unplug the Kinect before and during installation. If you installed an earlier beta of the SDK then uninstall it first.
Next you need a copy of Visual Studio. If you don't have a full copy of Visual Studio then simply download the Express version and install it: http://www.microsoft.com/express.
Once you have installed the SDK you can plug in your Kinect and you should see the drivers automatically install. To check that they have been installed you should be able to see four Kinect devices in the Device Manager.
There is also a Kinect audio device listed under Sound,video and game controllers:
To check that they have worked try running the "Sample Skeletal Viewer" from the Sample Browser. This shows the depth map, video and the detected skeleton of anyone in the view.
If you find it's not working you are probably too close.
There is also a complete demo of a game - The Shape Game - that involves tracking two players at the same time. The source code for both samples is included with the SDK and once you get beyond the beginnings you can use them as the basis for your own applications.
If you find that the device drivers aren't installed you need to make sure that you install the SDK and then plugged the Kinect in.
If not the simple solution is to disconnect it and then plug it back in when it should be recognized and the drivers installed.