Developing kinect for Windows v2.0 App with Visual Studio 2015 on Windows 10

Developing kinect for Windows v2.0 App with Visual Studio 2015 on Windows 10

You can develop app using  Kinect for Windows V2.0 on Windows 10 as similar  to previous version of Operating Systems. I am receiving several questions on building Kinect for Windows SDK application on Windows 10. Tough I personally responded to most the questions,  to benefits for the larger audience here is a quick post to Getting started with Kinect SDK v2.0 App on Windows 10 using Visual Studio 2015.

Must Read : Kinect for Windows SDK Tips and Tricks

Requirements :

  • Kinect for Windows V2 Device
  • Kinect for Windows SDK v2.0
  • Windows 10
  • Visual Studio 2015

Verify Device Settings and Connection

Now, First things firstYou must ensure your Kinect devices is Connected properly and you device can recognized it.  Couple of months back I did another post on Running Kinect for Windows applications on Windows 10 – Things you should verify which shows how to verify your device settings.

To quickly recall and verify

Go To PC Settings –> Devices –> Connected Devices

Device Settings

If the devices connected properly, and power is turned on, your Connected Devices section should display a “Kinect” deice, that connected to a USB 3.0

Kinect Device loaded

If you verify above setting and device recognized properly, you should be to good to run and build your Kinect applications.

Start Building the App :

Once you verify the device the settings and connection, you are ready to build the app. Now you can build app using WPF or Windows 8.1 store app or even a console app depends on your requirement. As of now we don’t have support for Universal Apps with Kinect SDK v2.0 .

For this demo, let’s start creating a new Windows 8.1 blank app project with name “KinectOnWindows10”’

Kinect on Windows 10 - New Project
Kinect on Windows 10 – New Project

Select the “Add Reference…” from the context menu of the project “References” options.

image

In the Reference Manager dialog windows, move the “Windows 8.1” –> “Extension” and then select “WindowsPreview.Kinect” and Click on OK.

image

This will add required packages for your store app that will use the Kinect for Windows Device.

image

That’s it.  add the following name space and few basic line of code with a textblock control in your app to just start and stop the Kinect sensor.

using WindowsPreview.Kinect;
namespace KinectOnWindows10
{
    public sealed partial class MainPage : Page
    {
        KinectSensor sensor;
        public MainPage()
        {
            this.InitializeComponent();
            Loaded += MainPage_Loaded;
            Unloaded += MainPage_Unloaded;
        }

        private void MainPage_Unloaded(object sender, RoutedEventArgs e)
        {
            if (sensor != null && sensor.IsOpen)
            {
                sensor.Close();
            }
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.sensor = KinectSensor.GetDefault();
            if (sensor != null)
            {
                sensor.Open();

                if (sensor.IsOpen)
                {
                    KinectMessage.Text = "Developing kinect for Windows v2.0 App with Visual Studio 2015 on Windows 10";
                }
            }
        }
    }
}

Run the App, and once Kinect Start you should be able to see the following output

image

 

Accessing Kinect Camera and Audio :

Above example does not access any Kinect features like Camera, Sensors or even audio. If you want to access them you must ensure you are giving right access to your app.

Go to the App Package manifest and select “Microphone” and “WebCam

image

Run the app with the above capabilities. Then move to Privacy –> Camera and Microphone.  Then you should be able to view your app in the list of devices access.

image

image

If you don’t see your app listed here and you want to access those devices, you have to ensure if the capabilities are set in package manifest. Otherwise you won’t be able to access them

That’s it for now. This is a very simple post and hope this will give you good start if you want to start building Kinect App. I will share few more post on Kinect Device coming days.

Hope this helps !

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.