Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Content Obsolete

This content is no longer current. We recommend you try the following url for more up to date content: http://channel9.msdn.com/Series/KinectQuickstart/Setting-up-your-Development-Environment

Setting Up Your Development Environment (Beta 2 SDK)

Download

Right click “Save as…”

Update: Kinect for Window SDK v1 Quickstart Series now Available (Feb 1st)

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).

  • [00:35] Sample Requirements
  • [01:50] Starting the Demo
  • [02:13] Adding References
  • [02:45] Coding4Fun Kinect Library
  • [03:23] Initializing the Kinect Runtime
  • [05:41] Uninitializing the Kinect Runtime

Updates for Kinect for Windows SDK Beta 2 (Nov, 2011)

The video in the Kinect for Windows SDK has not been updated, but the tutorial below has the following changes:

  • The Microsoft.Research.Kinect DLL version is now 1.0.0.45.
  • The requirements for DirectX samples have been clarified to say that they are only required for C++.
  • The speech sample requirements have been updated for Beta 2. If you are using an x64 PC, note that you should install both the x86 and x64 Speech Platform Runtime (see Speech samples below).
  • The source code for shipping examples is now in "\Program Files\Microsoft SDKs\Kinect\v1.0 Beta2\Samples\KinectSDKSamples.zip"
  • The Kinect runtime now provides a StatusChanged event that will fire if a Kinect is connected, disconnected, and so forth. See below for a code snippet for how to subscribe and handle the StatusChanged event.
  • For an example on setting up and handling Kinect connect/disconnect events, refer to the ShapeGame sample.
  • For an example  on how to show two Kinects at the same time, refer to the SkeletalViewer sample.

 

Task: Download Sample Requirements

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:

 

Task: Setting up a new Visual Studio 2010 Project

  • In this task, you’ll create a new Visual Studio 2010 project and add references to the correct libraries
  • Start Visual Studio 2010 (Express Editions or higher)
  • Select File –> New Project –> Windows Presentation Foundation and set the name for your project
    image

 

Add a reference

  • C# – From the Solution Explorer, right click on References and select Add Reference as shown below

image

 

  • Visual Basic – From the Solution Explorer, right click on the project name and select Add Reference as shown below

 

image

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.

image

 

Add a using statement

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

Optional: Using the Coding4Fun Kinect Toolkit

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:

  • WPF Applications: use the Coding4Fun.Kinect.Wpf.dll
  • Windows Form Applications: use the Coding4Fun.Kinect.WinForm.dll

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

Initializing and Uninitializing the runtime

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.

Create the Window_Loaded event

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

image

 

Initializing the runtime

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

 

Handling multiple Kinects

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]

 

Handling Kinect Status Change events

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]

 

Setting Runtime Options

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)

Uninitializing the Runtime

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()

Follow the Discussion

  • AaronAaron

    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.

  • alexalex

    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.

  • BasBas It finds lightbulbs.

    Does the speech recognition platform work if your system locale and UI language are not US/English?

  • PeterPeter

    Uninitialize does not stop the IR projector.
    How can I stop the IR - projector? Thanks

  • MixMix

    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.'

  • Dan FernandezDan

    @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.

  • Dan FernandezDan

    @Mix: Can you send the inner exception? See if you have an option to "Copy Exception details to clipboard" and respond with them!

  • MixMix

    I installed SP1 for VS 2010, restarted my system, created a new solution from scratch and no longer receive this error. Thanks.

  • Dan FernandezDan

    @Mix: Great to hear Smiley

  • BasBas It finds lightbulbs.

    @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.

  • JigglesJiggles

    Hi there,

    Coding4Fun Kinect Toolkit. Where do i place the Extracted files to bring them up in the reference list?

    Thankyou in advance

  • alexalex

    @Jiggles : Use the browse option tab in the add reference window to find them! et voila. That's what I did and worked fine!

  • Dan FernandezDan

    @BasMadPeter: I sent your question to the product team and this is unfortunately a known issue with the driver at beta where the IR projector doesn't turn off. 

  • AustinAustin

    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.

  • AustinAustin

    I got it. Needed SP1, If any errors occur Install SP1 from http://www.microsoft.com/download/en/details.aspx?id=23691

  • Clint RutkasClint I'm a "developer"

    @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.

  • Clint RutkasClint I'm a "developer"

    @Tom_Anderson: fixed

  • Clint RutkasClint I'm a "developer"

    @Austin:  Checked with the kinect team, it is a known issue. http://social.msdn.microsoft.com/Forums/en-US/kinectsdk/thread/927a8e6f-ce08-4fe8-9819-e5e05dd0d9d6

  • FlashFlash

    Hi,
    Could you post the tutorial for C/C++?
    Thanks.

  • Kiira33Kiira33

    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 Sad

     

    any help or ideas as to why this may be happening would be very much appreciated!

     

    David

  • OMARFUZZERomarfuzzer KINECTEANDO

    ...

  • RafaelRafael

    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

  • FaithFaith

    That was really helpful.
    thank u so much.

  • DanDan

    Could not find the closed event... why is it not available to me? Found the loaded event no problem.

  • inhak kiminhak kim

    Is there any other language pack for this which is not american version ??

  • FernandoFernando

    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

  • agusbeanagusbean

    can i have 1 of the finished source code and the design of kinect application for my computer..???

  • ctrectre

    you should try making a video we can actually see. Its so distorted, i cant see what is on your screen.

  • ctrectre

    *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....

  • Angelo GrahamAngelo Graham

    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).

  • jefferyjeffery

    I got kinect working on 64-bit computer also on a laptop. Open ni drivers definitely cause conflict.

  • mattmatt

    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

  • JohnJohn

    I have the same problem as Matt. No definition for Kinects

  • JohnJohn

    Matt,

    You have to download beta2 from kinectforwindows.org

  • PsyokJPsyokJ

    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.

  • ChoiyChoiy

    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?

  • Amizzy55Amizzy55

    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.  

  • StevenSteven

    my kinect is already connected but when i run the program only shows a white window. Help me.

  • stevensteven

    @Nozue do you find a solution? i got the same window.

  • Ryan GabrieleRyan Gabriele

    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?

  • JazzCoderJazzCoder

    I've installed the kinect sdk correctly but I can't find the refference "Windows.Reaserch.Kinect"? Please help me.

  • hommhomm

    i have teh same problem. I can't find the microsoft.research.kinect. pls help

  • DigiDigi

    Same can't find microsoft.research anywhere, please help

  • amiemamiem

    Hello,
    I have the same pb, cannot find microsoft.research anywhere...
    Thanks for any help :)

  • amiemamiem

    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

  • DerekDerek

    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: http://channel9.msdn.com/Series/KinectQuickstart.

  • Hican any one help me.... I cannot find the Microsoft.Research.Kinect reference

    Thanks in advance !

  • KatKat

    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..

  • KatKat

    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#???

  • evaeva

    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 !

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.