Development With Kinect .NET SDK (Part I) – Installation and Development Environment Setup

The Kinect SDK is a developer toolkit for developing applications. This SDK provides a fantastic interface to interact with Kinect programmatically. The Kinect for Windows SDK beta includes drivers that interact with H/W and provides an interface to interact with device, APIs for  interacting with  Camera, Sensors, microphone and Motor. The SDK provides capabilities to the developers who build applications with  C#, VB or C++  with Visual Studio 2010  which is running on Windows 7. I started developing application with Kinect SDK almost 2 months back, from the day when I received my Kinect Device. I tweeted about my first application over here  and I am still learning about the Kinect SDK API’s and how to use them in different ways. Let’s share the learning over here. I will keep posting as step by step to allow you to  understand the API’s and get inside Kinect development. I will write a series of post where I will discuss about fundamentals of Kinect SDK API and developing Application using it and yes Step by Step and obviously with Demo Project

So what are the thing we are going to learn today ? Well, we will learn about the system requirements and the installation of the Kinect device, which will ensure that our device setup properly and we are good to start with development.

Get Ready with Your Development Environment

The current version of Kinect for Windows SDK beta 1  needs below requirements to start

Hardware

  • Kinect for Xbox 360 sensor
  • Computer with a dual-core, 2.66-GHz or faster processor
  • Windows 7–compatible graphics card that supports DirectX® 9.0c capabilities
  • 2-GB RAM (4-GB RAM recommended)

Software

Refer ^ for more information

Download and Install Kinect for Windows SDK beta

Download the SDK Beta, Once you have the development environment setup ready. Please make sure you are downloading the SDK Version based on 64bit or 32bit Operating System. Once done with download, install it. You really do not need to plugin your Kinect devices during the installation of SDK.

 Know your Kinect Device

Before checking out Driver installation, let’s have a quick look into the basic H/W elements of Kinect. This contains 3d Depth Sensors, RGB Camera which is used for Video Capturing , Array of MIC and TILT.

image

Kinect SDK provides some API to interact with motorized tilt to enables the camera up or down 27 degrees  . This API is the part of Kinect Camera.

image

I will be talking details about each and everything in my upcoming post while exploring the API’s for each every section.

Checkout your Installation of Device Driver

Plug in your Kinect USB cable with Computer. Once Windows detects the devices, you will get the LED Indicator blinking ( Yeah, this one is mine) .

WP_000633

Wait for Windows to recognize the sponsor’s.  You can check it out from Control Panel > Device Manager for the installed device driver. By default with only USB connection, Windows will detect only the device, as shown in below picture.

image

But, Camera , Sensors and Audio is yet to detect. Here is a point, To detect all  Kinect elements, device need some high power supply. For that you need to plug the power supply to your Kinect Device from external Power Source. This will enables windows to detect all the components of Kinect Devices.

image

Here is the Quick Video for the Device detection.

Kinect Device Detection : A Small Clip Recorded

Test Your Device

You have done with setup and installation. Let have a quick test your device.  Kinect SDK installs few sample application , Sample Skeletal Viewer is one of them. Just run that application, you will able to see your view in Depth View Skeletal View and Camera View.

image

If all of them are coming up. Your are all set to start development.

What else Kinect SDK installed for Developers ?

Yes, Kinect SDK also installed a best resource to learn Kinect SDK Development and Explore the APIs. This installation contains, Kinect SDK API Reference file. I learned most of the things from here itself.

How Application Interacts with Kinect

You have already installed SDK and Kinect Setup properly . So before start with development, let have a look how Application interacts with Kinect Devices. Kinect SDK Installed set of API to interact with Devices, You application will talk to those APIs and APIs will talk to Devices. Below images shows the same flow.

image

Staring With Application Development  :

Finally all the setup are done.  Let’s  have start some development with Visual Studio 2010 and create a small application  which will Initialize Kinect Sensor and display the Unique device name

Fire a new instance of Visual Studio, Select New Project Option from file Menu and Select “WPF Application” Template , Give the name as “MyFirstKinectDemo”

image

Click on OK, It will create a blank WPF Application for you.  Before going ahead, first lets design the UI as show in below

image

Below code snippet  is the XAML markup for the above design. Well, its very simple.

Now it’s time to interact with Kinect SDK API’s. To start with, you need to first add the reference of  Kinect SDK assemblies. Navigate to solution explorer, Right Click on the Project and Select “Add Reference”

image

The assembly you need to add is “Microsoft.Research.Kinect.dll” ,  You can search for Kinect keyword in the Assembly search text box to get it faster.

image

This will add Microsoft.Research.Kinect.dll as reference to your project. The top level view of this assembly  in Object Explorer given as below. These two are the different segment of Kinect APIs.

image

If you want to interact with NUI ( Natural User Interface)   API  like camera, sensors, Skeleton viewer  you have to use the below namespaces.

image

If you want to interact with Kinect Audio Array, you have to include

image

For this application, we will be using NUI API hence we will be adding below namespaces with our code.

using Microsoft.Research.Kinect.Nui;

First of all you need to define the runtime of Kinect as shown in below,  this represents the instance of Kinect Sensor.

image

After that,  initialize the runtime with the options you want to use. Below are this Runtime options which Kinect Supports

image

In the next article I will discuss more about the runtime options. For this example,  use RuntimeOptions.UseColor to use the RGB camera.

Below is complete Code snippet for Initialize and Uninitialized the Kinect Device.


    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        ///
        /// </summary>
        Runtime nuiRuntime = new Runtime();

        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Handles the Click event of the buttonInitialize control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void buttonInitialize_Click(object sender, RoutedEventArgs e)
        {
           // Intialize Kinect Device with UseColor Runtime Option
            nuiRuntime.Initialize(RuntimeOptions.UseColor);
            MessageBox.Show("Device Runtime Initialized");

            //Get the Camera Device Name
            labelDeviceName.Content = nuiRuntime.NuiCamera.UniqueDeviceName;
        }

        /// <summary>
        /// Handles the Click event of the buttonUnInitialize control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void buttonUnInitialize_Click(object sender, RoutedEventArgs e)
        {
            // Uninitilize Runtime
            nuiRuntime.Uninitialize();
            MessageBox.Show("Device Runtime UnInitialized");
        }
    }

That’s all, Run the Application and Click on “Initialize Kinect Runtime” , your application will initialize a runtime of Kinect device via SDK APIs and you will get below message as written in code.

image

image

After the acceptance of the initialize message, you will get the Unique Camera device name.

image

image

Clicking on “Uninitialized Kinect Runtime, button will execute the below code to uninitialized device

image

image

Download Sample

Well, That’s all . To Summarize the stuff what I have discussed till now is, setting up your development environment, installing Kinect SDK, Detecting  the devices and a small application to initialize the  Kinect devices. This is only the beginning, we will talk a lot more about API and will start with something new in my next post.

More Study and Reference

Thanks !

Abhijit

22 comments

  1. Pingback: DotNetShoutout
  2. Thanks a lot man!
    I successfully developed a whole application and the Kinect Sensor was unplugged from the power supply, so it wasn’t able to initialize the runtime.
    After searching for over an hour, this is the first post that helped me with the Driver setup.

    Like

  3. you are article is very good.but i don’t have kinect xbox
    how to capture video through windows c# application?

    Like

  4. Hello,
    I’ve tried to learn the basics of kinect-coding with your tutorial, but after the change of the API, I’ve had to change some parts of the code (Runtime = KinectSensor) . Unfortunately, C# tells me at “KinectSensor ks = new KinectSensor();” that there is no constructor defined.
    I’m very confused about that and so I would be rather pleased, if you could help me to understand / deal with it.
    Thanks in advance.

    Like

    1. Hi, This article is pretty old and wrote on Beta SDK.
      With the new SDK u will get reference of Kinect as
      KinectSensor sensor= KinectSensor.KinectSensors[0];

      Now, you can start the sensor by using
      sensor.Start();

      Let me know if you need any help on this. Would be happy to help.

      Like

  5. Hello Abhijit Jana,
    I am about to start a project kinect sensor for Gestures(free control of medical Images,i.e zapping images, zooming or reduce images with gestures ). Here some information about my system:Windows 7 x64Bits
    Processor: Intel(R) Core (TM) i5-4200M CPU @ 2.50GHz 2.50GHz
    4,00 GB 64Bit OS
    Visual Studio Express 2013. Is this Okay?
    I have ordered for a kinect Sensor .
    How do i check for ” Windows 7–compatible graphics card that supports DirectX® 9.0c capabilities” property
    What do you mean by “Microsoft .NET Framework 4.0” ? do i need to download it?
    Is SDK v 1.7 Okay in place of SDK Beta?
    Thanks in Advance for your kind reply

    Like

Leave a comment