Kinect 2 for Windows Demo App

The Hands On Labs to complete a sample application for Windows 8.1 and the Kinect 2 for Windows

Kinect 2 Hands On Labs

Kinect On Image

Lab 1: Initial Kinect2.0 Project Setup

Estimated Time to Complete: 10min

This lab is part of a series which takes you through the creation process of a Windows 8.1 Store Application which uses every available feature of the Kinect 2. This is the first lab in the series, and it shows you how to set up the initial development environment to build an app using Kinect 2.

This lab will explain the following:

  1. How to make a new project for Windows 8.1
  2. How to download and reference the Kinect 2.0 SDK.
  3. How to get the Kinect 2 sensor in code and build a successful app.
  4. How to open the sensor and turn on the Kinect 2 from code.

This lab comes with a starting point solution and a completed solution of the covered exercises if required.

Exercise 1 - Project Setup

This exercise will show you how to set up the development environment for building a Kinect for Windows 2 application in Windows 8.1, and how to access the Default Sensor in code. This lab and all subsequent labs in this series are built using C# and assume you have a fundamental knowledge of the language. The screenshots here are from Visual Studio Pro 2013 Update 2 but Community Edition is identical.

  1. Open Visual Studio 2013 and create a new project in a directory you can access. Click File > New > Project and select a Blank App for Windows in C#. Name the project Kinect2Sample. Then click OK to create the project:
    New Project Image

  2. The project will be created with the default MainPage.xaml and App.xaml, and added to the project in the Solution Explorer on the right:
    Solution Explorer

  3. If you have not downloaded the public Kinect 2 SDK, you should download it and install it before proceeding: ~280MB

  4. Once installed, the Kinect 2 SDK can be referenced for use in the new project. In the Solution Explorer, right click References and click Add Reference… to open the Reference Manager.

  5. To add the WindowsPreview.Kinect.dll which uses the .NetCore library (suitable for Windows Store apps), follow these steps:

    • a. Click Extensions on the left.
    • b. In the center panel, scroll down to the bottom and check WindowsPreview.Kinect.
      Reference Manager Image
    • c. Click OK to add the reference.

  6. Kinect 2.0 applications are compatible with x86 and x64 architectures, but are not compatible with ARM systems. This dependency from the Kinect 2.0 library means that you must change the project configuration to either x86 or x64 instead of the currently set “Any CPU” .

    • a. Click BUILD then Configuration Manager… to open the Configuration Manager.
    • b. Click the dropdown box under Active Solution Platform: and select x64.
      Configuration Manager Image
    • c. Click Close.
    • d. Open the project properties by right Clicking the Kinect2Sample project in the solution explorer, then clicking Properties.
    • e. Click the Build tab on the left, then beside Platform: select x64 from the dropdown.
    • f. Click FILE, then Save All or hit Ctrl + Shift + S to save all files.

  7. Now you can build and run the application to make sure the references work and are compatible. Click BUILD then Build Solution, then the project will build and should present no errors. To Run or Debug the application you can either:

    • a. Click DEBUG then Start Debugging, or
    • b. In the Debug toolbar, click the Green Play Arrow button next to the target environment which should be set to Local Machine.
      Debug Toolbar Image
      The application will install on the Local Machine as a Windows 8.1 Store app and launch itself with Visual Studio as the attached debugger.

  8. Upon running or debugging the application, you will see a gray screen, because there is nothing yet in the application to show. Back in Visual Studio, select the menu DEBUG, Stop Debugging or click the Red Stop Square in the Debugging toolbar.

    In the future, the steps 7 and 8 are required when asked to Build and Run the application.

  9. Open the MainPage.xaml.cs code behind file in Visual Studio by double clicking it.

  10. To get the default sensor for the Kinect, add the WindowsPreview.Kinect namespace, and a private class level variable for the KinectSensor. Then in the constructor of MainPage class select the default sensor and open it. To do this, add the highlighted code below:

  11. // ... other namespaces
    using WindowsPreview.Kinect;
    namespace Kinect2Sample
        public sealed partial class MainPage : Page
                    private KinectSensor kinectSensor = null;
            public MainPage()
                    // one sensor is currently supported
                    this.kinectSensor = KinectSensor.GetDefault();
                    // open the sensor
  12. Now add the Capability for the application to use the Kinect as a webcam and microphone device. Open the Package.appxmanifest by double clicking it in the Solution Explorer. Navigate to the Capabilities tab, then tick the Microphone and Webcam capabilities:

    Capabilities Image
  13. Make sure the Kinect 2.0 device is now plugged into both power and a USB3.0 port on the machine.

  14. Build and Run the application, and you will be prompted to allow the Kinect:
    Permissions Prompt Image
    Click Allow.
    NOTE: if you click Block by accident, then you can re-enable the microphone and camera through settings for the app in the charms bar.

  15. The same black screen will appear in the application but the infrared depth lights and the white status led of the Kinect 2 will turn on!
    Kinect On Image

  16. Stop debugging now. The Kinect 2.0 is ready to be used and this is the end of the first exercise.


This lab has taught you how to create a Windows 8.1 Store application to work with Kinect for Windows 2.0. The code references the SDK within WindowsPreview which is a Windows 8.1 extension SDK.

If you wish to make a Windows 8.1 desktop application (a non-store application) with full access to the .Net Framework, then there is a different Kinect reference to can use. To use the desktop Kinect library reference, follow these steps: To add The Microsoft.Kinect.dll which uses the full .NetFramework library, follow these steps in the Reference Manager.

  1. Click Browse… to browse to the installed location of the Kinect library.
  2. Navigate to the following path: C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Assemblies
  3. Highlight the Microsoft.Kinect.dll library there and Click Add. The Microsoft.Kinect.dll will be added in the reference manager already checked, so Click OK.
    Reference Manager Image

Currently the Kinect is simply turning on in the application, and with this confirmation you know that the application is activating the Kinect.

There is code available for the completed solution of the project in this lab. The next lab will begin from this code.

  • Next Lab: 02

  • This Lab Code
  • Back to Top