Installing and Using the Kinect Sensor (Beta 2 SDK)

This content is no longer current. Our recommendation for up to date content: http://channel9.msdn.com/Series/KinectQuickstart/Setting-up-your-Development-Environment
Please use the newly updated Kinect for Windows SDK Quickstart series. The content below will only work with the Beta 2 version of the Kinect for Windows SDK.
This video covers how to set up your development environment. You may find it easier to follow along by downloading the Kinect for Windows SDK Quickstarts samples and slides that have been updated for Beta 2 (Nov, 2011).
The video in the Kinect for Windows SDK has not been updated, but the tutorial below has the following changes:
Some samples use DirectX and the Microsoft Speech APIs. For these demos to work, you must download the correct pre-requisite software.
Kinect for Windows SDK:
Visual Studio:
DirectX Samples (for C++ Skeletal Viewer)
Speech Samples:
For Speech samples:
Visual Basic / C# – In the Add Reference dialog, switch to the .NET tab, click the Component Name header to sort references alphabetically, then scroll down to select Microsoft.Research.Kinect and click OK. Make sure to select 1.0.0.45.
Within your project, you can now add a using statement to reference the Kinect namespaces:
C#
using Microsoft.Research.Kinect.Nui; using Microsoft.Research.Kinect.Audio;
Visual Basic
Imports Microsoft.Research.Kinect.Nui Imports Microsoft.Research.Kinect.Audio
Go to http://c4fkinect.codeplex.com and download the latest version of the Coding4Fun Kinect Toolkit. This library is filled with useful items to help with a variety of tasks, such as converting the data from the Kinect to a data array or Bitmap.
Depending on if you are building a WPF or Windows Form application, we have two different DLLs:
C#
// if you're using WPF using Coding4Fun.Kinect.Wpf; // if you're using WinForms using Coding4Fun.Kinect.WinForm;
Visual Basic
' if you're using WPF Imports Coding4Fun.Kinect.Wpf ' if you're using WinForms Imports Coding4Fun.Kinect.WinForm
For NUI, we have to initialize and uninitialize the runtime. In our examples, we typically will initialize on the Loaded event on the Window and we'll uninitialize on the Closed event. Depending on what needs to be done, the Initialize method on the runtime will be tweaked though the concepts stay the same.
Go to the properties window (F4), select the MainWindow, select the Events tab, and double click on the Loaded event to create the Window_Loaded event
Create a new Runtime variable named “nui” outside of the Window_Loaded event. When the Window_Loaded event fires, we will call the SetupKinect method that checks to see if there is at least one Kinect plugged in, and if there is, it uses the first Kinect (0 representing the first Kinect) and initializes the Runtime (more details on that later).
C#
//Kinect Runtime Runtime nui; private void Window_Loaded(object sender, RoutedEventArgs e) { SetupKinect(); } private void SetupKinect() { if (Runtime.Kinects.Count == 0) { this.Title = "No Kinect connected"; } else { //use first Kinect nui = Runtime.Kinects[0]; nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking); } }
Visual Basic
'Kinect Runtime Private nui As Runtime Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) SetupKinect() AddHandler Runtime.Kinects.StatusChanged, AddressOf Kinects_StatusChanged End Sub Private Sub SetupKinect() If Runtime.Kinects.Count = 0 Then Me.Title = "No Kinect connected" Else 'use first Kinect nui = Runtime.Kinects(0) nui.Initialize(RuntimeOptions.UseColor Or RuntimeOptions.UseDepthAndPlayerIndex Or RuntimeOptions.UseSkeletalTracking) End If End Sub
You can see how many Kinects are connected by getting the count of Kinects as shown in the code below. Note that for multiple Kinects, you can only have one Kinect do skeletal tracking at a time (color and depth camera work for all) and each Kinect needs to be in its own USB hub, otherwise it won’t have enough USB bandwidth.
C#
[code lang=”csharp”]
int KinectCount = Runtime.Kinects.Count;
[/code]
Visual Basic
[code lang=”vb”]
Dim KinectCount as Integer = Runtime.Kinects.Count
[/code]
You can also handle events when the status changes for Kinects that are plugged in. To do this, first register for the StatusChanged event as shown below. When this event fires, it returns a KinectStatus enum with the following possible values: Connected, Error, Disconnected, NotReady, or NotPowered.
C#
[code lang=”csharp”]
Runtime.Kinects.StatusChanged += new EventHandler<StatusChangedEventArgs>(Kinects_StatusChanged);
…
void Kinects_StatusChanged(object sender, StatusChangedEventArgs e)
{
string message = "Status Changed: ";
switch (e.Status)
{
case KinectStatus.Connected:
message += "Connected";
break;
case KinectStatus.Disconnected:
message += "Disconnected";
break;
case KinectStatus.Error:
message += "Error";
break;
case KinectStatus.NotPowered:
message += "Not Powered";
break;
case KinectStatus.NotReady:
message += "Not Ready";
break;
default:
if (e.Status.HasFlag(KinectStatus.Error))
{
message += "Kinect error";
}
break;
}
this.Title = message;
}
[/code]
Visual Basic
[code lang=”vb”]
AddHandler Runtime.Kinects.StatusChanged, AddressOf Kinects_StatusChanged
…
Private Sub Kinects_StatusChanged(sender As Object, e As StatusChangedEventArgs)
Dim message As String = "Status Changed: "
Select Case e.Status
Case KinectStatus.Connected
message += "Connected"
Exit Select
Case KinectStatus.Disconnected
message += "Disconnected"
Exit Select
Case KinectStatus.[Error]
message += "Error"
Exit Select
Case KinectStatus.NotPowered
message += "Not Powered"
Exit Select
Case KinectStatus.NotReady
message += "Not Ready"
Exit Select
Case Else
If e.Status.HasFlag(KinectStatus.[Error]) Then
message += "Kinect error"
End If
Exit Select
End Select
Me.Title = message
End Sub
[/code]
In the Window_Loaded event, initialize the runtime with the options you want to use. For this example, set RuntimeOptions.UseColor to use the RGB camera:
C#
nui.Initialize(RuntimeOptions.UseColor);
Visual Basic
nui.Initialize(RuntimeOptions.UseColor)
RuntimeOptions is a Flag enumeration, this means you can set multiple options as parameters in the Initialize method by separating them with the pipe "|" character (the "or" operator) in c# or the "Or" operator in Visual Basic. The example below sets the runtime to use the color camera, a depth camera, and skeletal tracking:
C#
nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking );
Visual Basic
nui.Initialize(RuntimeOptions.UseColor Or RuntimeOptions.UseDepthAndPlayerIndex Or RuntimeOptions.UseSkeletalTracking)
Remember that when you are done using the Kinect Runtime, you should call the Uninitialize method. For a WPF application, you would typically do this in the Windows_Closed event:
C#
nui.Uninitialize();
Visual Basic
nui.Uninitialize()
Is the Microsoft Kinect Speech Platform not available for download yet or something like that. The link above doesn't seem to actually be a link and it's nowhere on the Kinect SDK pages like the SDK sample says.
Just a "stupid question"... where should I put the coding4fun files I extracted from the zip file??? Thanks
@alex:It doesn't matter where you put them, if you go to recent files you can browse to them. Once you reference them you should be good to go. If you move them, you might have to re-reference them.
Does the speech recognition platform work if your system locale and UI language are not US/English?
Uninitialize does not stop the IR projector.
How can I stop the IR - projector? Thanks
Runtime error occurs after adding nui:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.'
@Bas: The Kinect for Windows Runtime Language Pack (version 0.9) is the acoustic model for the Kinect for Windows SDK. That is optimized for using Kinect as a microphone and is English only. You should be able to use another recognizer that supports multiple languages, but it won't be as optimized as the Kinect Runtime language pack.
@Mix: Can you send the inner exception? See if you have an option to "Copy Exception details to clipboard" and respond with them!
I installed SP1 for VS 2010, restarted my system, created a new solution from scratch and no longer receive this error. Thanks.
@Mix: Great to hear
@Peter: I have the same problem. Once I run an application once, the IR projector stays on until I actually unplug the Kinect from the USB port.
Hi there,
Coding4Fun Kinect Toolkit. Where do i place the Extracted files to bring them up in the reference list?
Thankyou in advance
@Jiggles : Use the browse option tab in the add reference window to find them! et voila. That's what I did and worked fine!
I got an error " Could not load file or assembly 'INuiInstanceHelper.dll' or one of its dependencies. The specified module could not be found." I am attempting a WinForms app, but it did the same, I also tried referencing the dll, and rebuilding - no luck.
I got it. Needed SP1, If any errors occur Install SP1 from http://www.microsoft.com/download/en/details.aspx?id=23691
@Austin: bet you had VS open while you did the install, restarting should fix this. I've logged a bug with the team.
Just a note for a correction:
using Coding4Fun.Kinect.WPF;
Where it says WPF, actually Wpf should not be capitalized, it's really:
using Coding4Fun.Kinect.Wpf;
And don't forget to add the reference to the Coding4Fun .dll, which can be done (after downloading the .dll from codeplex) in the Solution Explorer by right clicking References>Add Reference>Browse.
@Tom_Anderson: fixed
@Austin: Checked with the kinect team, it is a known issue. https://social.msdn.microsoft.com/Forums/en-US/kinectsdk/thread/927a8e6f-ce08-4fe8-9819-e5e05dd0d9d6
Hi,
Could you post the tutorial for C/C++?
Thanks.
J'ai un petit soucis. J'ai fait exactement comme cité en haut mais quand je veut générer, tout est blanc et rien n es'affiche. Pouvez-vous m'aidez s'il vous plait?
I have done all the things as the page said, but when I debug the program, it always throw an exception which is said "An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Research.Kinect.dll
Additional information: Failed in native DLL. HRESULT=0x80080014."
I don't know why. And I can't run the demo(SkeletalViewer and the ShapeGame) which is contained in the SDK normally, everytime I double click it (with the kinect connected to the computer ) ,the computer must crashed and with no response, if I don't connect the computer with kinect, the demo can run , but with no picture. I really want to know the reason, if I didnt install the SDK correctly or I didnt install the speech recognition correctly or something else ?
Hey folks, I am getting this error here
Error 1 Could not load file or assembly 'Coding4Fun.Kinect.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) C:\Users\kAh00t\AppData\Local\Temporary Projects\WpfApplication1\MainWindow.xaml 1 1 WpfApplication1
and
Error 2 System.IO.FileLoadException was thrown on "C:\Users\kAh00t\AppData\Local\Temporary Projects\WpfApplication1\MainWindow.xaml": Could not load file or assembly 'Coding4Fun.Kinect.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) C:\Users\kAh00t\AppData\Local\Temporary Projects\WpfApplication1\MainWindow.xaml 1 1 WpfApplication1
when trying to follow this tutorial
any help or ideas as to why this may be happening would be very much appreciated!
David
...
I had the same problem as kAh00t !!!!
Error 1 Could not load file or assembly 'Coding4Fun.Kinect.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) C:\Users\kAh00t\AppData\Local\Temporary Projects\WpfApplication1\MainWindow.xaml 1 1 WpfApplication1
and
Error 2 System.IO.FileLoadException was thrown on "C:\Users\kAh00t\AppData\Local\Temporary Projects\WpfApplication1\MainWindow.xaml": Could not load file or assembly 'Coding4Fun.Kinect.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) C:\Users\kAh00t\AppData\Local\Temporary Projects\WpfApplication1\MainWindow.xaml 1 1 WpfApplication1
That was really helpful.
thank u so much.
Could not find the closed event... why is it not available to me? Found the loaded event no problem.
Is there any other language pack for this which is not american version ??
Hi, well I have a problem with this line in c#:
if (Runtime.Kinects.Count == 0)
{
this.Title = "No Kinect connected";
}
The word Kinects has problem in the compilation, the problem says:
Microsoft.kinect.nui.runtime does not mean contain a definition for Kinects
Maybe you can help me
Regards
@Fernando:
Fernando, this functionality is available on the beta 2 version only, you can download it at kinectforwindows.org
can i have 1 of the finished source code and the design of kinect application for my computer..???
you should try making a video we can actually see. Its so distorted, i cant see what is on your screen.
*edit* i mean the video streaming, some of these videos for download are 500mb's!
i already plug in my kinect device to the laptop.
but when i debug the app, it appeared "no kinect connected".
what is going on? hmmm....
by the way...forget to mention...the kinect works fine....just those kinect camera and sensor....
This simply doesn't work on a windows 7 64 bit machine. My kinect is plugged into the wall with a working outlet. All of the devices are listed correctly in device manager. my computer understands that there is a kinect device connected. The Kinect API however does not. The static Microsoft.Research.Kinect.Nui.Runtime.Kinects call returns an empty KinectDeviceCollection (count = 0). Only the audio samples work. I do not now nor ever have had any other other kinect api(s) installed on this machine. also using vs2010 sp1 with .net 4.0. Any one have any ideas? Thanks in advance.
Angelo Graham,
i've no idea too...haha
Now, running the risk of asking a really stupid question, what is this code supposed show on screen when a kinect is detected?
I mean, when there's no kinect conected, it shows the sentence on the window title, just like it's decribed in the code. However, when the kinect is connected, I get an empty white screen. Is it correct?
I had stated previously that "This simply doesn't work on a windows 7 64 bit machine." I have since installed the SDK on a Windows 7 64bit desktop. I can now say it actaully does work and it is pretty cool. I am still having trouble getting it to work on my laptop though. I suspect there must be some sort of software or hardware conflict. If I figure out the issue, I will post it here. I dont know if it is related or not but the working computer lists only 1 device icon for the Kinect in the "Devices and Printer" view. The non working environment lists four icons, one for each component (camera, device, hub, and USB composite device).
I got kinect working on 64-bit computer also on a laptop. Open ni drivers definitely cause conflict.
Hi,
Whenever I try to follow this, or any other, tutorial I get the following issue:
Any reference to Runtime.Kinects is underlined and the message is:
"Kinects is not a member of Microsoft.Research.Kinect.Nui.Runtime"
I also get this error when I download the project files from the website and try to run them.
Please help.
Thanks,
Matt
I have the same problem as Matt. No definition for Kinects
Matt,
You have to download beta2 from kinectforwindows.org
I actually have the same problem as Matt.
All the Runtime stuff is all underlined red. My imports/usings have "exclaimation marks".
I have installed everything and still dont work.
Quick question..do I need to calibrate first before the head is detected? Is it possible to only detect the upper body and get the skeleton?
Ok, im new at all this. but im trying to learn. so when i put all of this in and fix all of the errors, i go to run it. and all i get is a blank white window. how can i fix this? heres my exact imput:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Research.Kinect.Audio;
using Microsoft.Research.Kinect.Nui;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
Runtime nui = new Runtime();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
nui.Initialize(RuntimeOptions.UseColor);
}
private void Window_Closed(object sender, EventArgs e)
{
nui.Uninitialize();
}
}
}
I'm having a problem with adding the c4f CodePlex dll references. As mentioned multiple times in the above posts, I browse to the DLL's but it doesn't show up on the list of other references.
I think the problem may be because I'm using Visual Studio 11 Preview on Windows 8. Is this a known issue? How do I add references in VS11? Or is it better if I stick with the rest of the crowd and revert back to 2010?
EDIT: Once I browse for a reference DLL file, it automatically adds it to the project - it doesn't show up on the "Reference Manager" window as shown in the video.
my kinect is already connected but when i run the program only shows a white window. Help me.
@Nozue do you find a solution? i got the same window.
All of the demo's that come with it work awesomely for me, and I've been having a lot of fun working with the camera in my own apps.
I'm trying to get into working with some of the Speech stuff though and I'm having a lot of trouble. I know my Speech libraries are installed properly because I can build and run the ShapeGame demo that has a Microsoft.Speech dependency. However, when I try and add that as a reference to my own project, I can't find it anywhere.
What am I doing wrong?
I've installed the kinect sdk correctly but I can't find the refference "Windows.Reaserch.Kinect"? Please help me.
i have teh same problem. I can't find the microsoft.research.kinect. pls help
Same can't find microsoft.research anywhere, please help
Hello,
I have the same pb, cannot find microsoft.research anywhere...
Thanks for any help :)
Hello, I found it finally I had to uninstall the kinect version 1.0 that i had, and install the 1.0-Beta version, then just refer to it from the "references" tab under the project.
I have another question, hope someone can help : I have a reference to microsoft.Kinect but it is marqued by an exlamation point (that means I have to refer to it) but I can't have Microsoft.Kinect anymore since I uninstalled the version I had, also I don't think both versions can cohabitate...
Thanks
Hi, I too cannot find the Microsoft.Research.Kinect reference. I don't want to be installing Beta versions if I can help it.
Is there a resolution yet?
This tutorial is out of date -- the link at the top sends you to the new Kinect Quickstart quide. The current version of the Kinect SDK uses the Microsoft.Kinect namespace, however the API has changed, so do see: https://channel9.msdn.com/Series/KinectQuickstart.
Hican any one help me.... I cannot find the Microsoft.Research.Kinect reference
Thanks in advance !
http://code.google.com/p/theforceteam-1073/downloads/detail?name=Microsoft.Research.Kinect.dll&can=2&q=
Go to this website and download the Microsoft.Research.kinect.dll.
Put it in your C:\Program Files\Microsoft SDKs\Kinect\v1.5\Assemblies
Restart your VB application and then you can find the above mentioned reference..
Can anyone help me with the details that I have the data captured(video files and depth data detail files) for the working but I don't have Kinect currently with me. In a nutshell I want to work on the captured data files offline..What should I do to open file in C#???
can any one help me
i cant download microsoft Direct SDK(jun2012) at the end it show
error message that said : there is a problem preventing your installation from continuing , error code s0123
i have tried other computers and the the same error apear each time !