Windows 7 Setting Up Your Development Environment

News

Extraordinary Robot
Robot
Joined
Jun 27, 2006
Location
Chicago, IL
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.
  • [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
[h=1]Task: Download Sample Requirements[/h]Some samples use DirectX and the Microsoft Speech APIs. For these demos to work, you must download the correct pre-requisite software.
Visual Studio:
DirectX Samples:
Speech Samples:
Note: If you have a 64-bit PC, you must still download the x86 versions of the Speech Runtime and SDK (below)
[h=1]Task: Setting up a new Visual Studio 2010 Project[/h]
  • 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%5B5%5D.png
[h=3]Add a reference[/h]
  • C# – From the Solution Explorer, right click on References and select Add Reference as shown below
image%5B8%5D.png


  • Visual Basic – From the Solution Explorer, right click on the project name and select Add Reference as shown below
image%5B8%5D-1.png

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
image%5B17%5D.png


[h=2]Add a using statement[/h]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.NuiImports Microsoft.Research.Kinect.Audio[h=3]Optional: Using the Coding4Fun Kinect Toolkit[/h]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 WPFusing Coding4Fun.Kinect.WPF;// if you're using WinFormsusing Coding4Fun.Kinect.WinForm;Visual Basic


' if you're using WPFImports Coding4Fun.Kinect.WPF' if you're using WinFormsImports Coding4Fun.Kinect.WinForm[h=1]Initializing and Uninitializing the runtime[/h]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.
[h=3]Create the Window_Loaded event[/h]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%5B5%5D-1.png

[h=3][/h][h=3]Initializing the runtime[/h]Create a new variable outside of the Window_Loaded event to reference the Kinect runtime:

C#

Runtime nui = new Runtime();
Visual Basic

Private nui As New RuntimeIn 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)[h=3]Uninitializing the Runtime[/h]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()
njs.gif


More...
 
Back
Top Bottom