EDN Admin
Well-known member
This video covers how to set up your development environment. You may find it easier to follow along by downloading the http://files.ch9.ms/coding4fun/KinectForWindowsSDKQuickstarts.zip Kinect for Windows SDK Quickstarts samples and slides . [ http://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started#time=5m6s 00:35 ] Sample Requirements [ http://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started#time=1m50s 01:50 ] Starting the Demo [ http://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started#time=2m13s 02:13 ] Adding References [ http://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started#time=2m45s 02:45 ] Coding4Fun Kinect Library [ http://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started#time=3m23s 03:23 ] Initializing the Kinect Runtime [ http://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started#time=5m41s 05:41 ] Uninitializing the Kinect Runtime <h1>Task: Download Sample Requirements</h1> Some samples use DirectX and the Microsoft Speech APIs. For these demos to work, you must download the correct pre-requisite software. Visual Studio: http://www.microsoft.com/express/ Visual Studio Express edition of the demo in the appropriate programming language or http://www.microsoft.com/downloads/en/details.aspx?FamilyID=26bae65f-b0df-4081-ae6e-1d828993d4d0&displaylang=en Visual Studio Professional or higher DirectX Samples: http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba Microsoft DirectX® SDK - June 2010 or later version http://www.microsoft.com/downloads/en/details.aspx?familyid=2DA43D38-DB71-4C1B-BC6A-9B6652CD92A3&displaylang=en Current runtime for Microsoft DirectX® 9 Speech Samples : <blockquote> Note: If you have a 64-bit PC, you must still download the x86 versions of the Speech Runtime and SDK (below) </blockquote> http://www.microsoft.com/downloads/en/details.aspx?FamilyID=bb0f72cb-b86b-46d1-bf06-665895a313c7 Microsoft Speech Platform Runtime, version 10.2 (x86 edition) <a>Microsoft Kinect Speech Platform (US-English version) http://www.microsoft.com/downloads/en/details.aspx?FamilyID=1b1604d3-4f66-4241-9a21-90a294a5c9a4&displaylang=en Microsoft Speech Platform - Software Development Kit, version 10.2 (x86 edition) <h1>Task: Setting up a new Visual Studio 2010 Project</h1>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
<img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B5%5D.png" alt="image" width="640" height="368" border="0 <h3>Add a reference</h3> C# – From the Solution Explorer, right click on References and select Add Reference as shown below <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B8%5D.png" alt="image" width="418" height="174" border="0 Visual Basic – From the Solution Explorer, right click on the project name and select Add Reference as shown below <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B8%5D-1.png" alt="image" width="420" height="417" border="0 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 <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B17%5D.png" alt="image" width="603" height="424" border="0 Add a using statement Within your project, you can now add a using statement to reference the Kinect namespaces: C# <pre class="brush: csharp using Microsoft.Research.Kinect.Nui;
using Microsoft.Research.Kinect.Audio;[/code] Visual Basic <pre class="brush: vb Imports Microsoft.Research.Kinect.Nui
Imports Microsoft.Research.Kinect.Audio[/code] <h3>Optional: Using the Coding4Fun Kinect Toolkit</h3> Go to http://c4fkinect.codeplex.com 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# <pre class="brush: csharp // if youre using WPF
using Coding4Fun.Kinect.WPF;
// if youre using WinForms
using Coding4Fun.Kinect.WinForm;[/code] Visual Basic <pre class="brush: vb if youre using WPF
Imports Coding4Fun.Kinect.WPF
if youre using WinForms
Imports Coding4Fun.Kinect.WinForm[/code] <h1>Initializing and Uninitializing the runtime</h1> 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 well 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. <h3>Create the Window_Loaded event</h3> 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 <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B5%5D-1.png" alt="image" width="377" height="251" border="0 <h3> </h3><h3>Initializing the runtime</h3> Create a new variable <u>outside</u> of the Window_Loaded event to reference the Kinect runtime: C#
<pre class="brush: csharp Runtime nui = new Runtime();[/code] Visual Basic
<pre class="brush: vb Private nui As New Runtime[/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#
<pre class="brush: csharp nui.Initialize(RuntimeOptions.UseColor);[/code] Visual Basic
<pre class="brush: vb nui.Initialize(RuntimeOptions.UseColor)[/code] 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#
<pre class="brush: csharp nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking );[/code] Visual Basic
<pre class="brush: vb nui.Initialize(RuntimeOptions.UseColor Or RuntimeOptions.UseDepthAndPlayerIndex Or RuntimeOptions.UseSkeletalTracking)[/code] <h3>Uninitializing the Runtime</h3> 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#
<pre class="brush: csharp nui.Uninitialize();[/code] Visual Basic
<pre class="brush: vb nui.Uninitialize()[/code] <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Feeds/RSS&WT.dl=0&WT.entryid=Entry:RSSView:8b0685ac5f5543cc87649efe00713a32
View the full article
<img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B5%5D.png" alt="image" width="640" height="368" border="0 <h3>Add a reference</h3> C# – From the Solution Explorer, right click on References and select Add Reference as shown below <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B8%5D.png" alt="image" width="418" height="174" border="0 Visual Basic – From the Solution Explorer, right click on the project name and select Add Reference as shown below <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B8%5D-1.png" alt="image" width="420" height="417" border="0 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 <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B17%5D.png" alt="image" width="603" height="424" border="0 Add a using statement Within your project, you can now add a using statement to reference the Kinect namespaces: C# <pre class="brush: csharp using Microsoft.Research.Kinect.Nui;
using Microsoft.Research.Kinect.Audio;[/code] Visual Basic <pre class="brush: vb Imports Microsoft.Research.Kinect.Nui
Imports Microsoft.Research.Kinect.Audio[/code] <h3>Optional: Using the Coding4Fun Kinect Toolkit</h3> Go to http://c4fkinect.codeplex.com 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# <pre class="brush: csharp // if youre using WPF
using Coding4Fun.Kinect.WPF;
// if youre using WinForms
using Coding4Fun.Kinect.WinForm;[/code] Visual Basic <pre class="brush: vb if youre using WPF
Imports Coding4Fun.Kinect.WPF
if youre using WinForms
Imports Coding4Fun.Kinect.WinForm[/code] <h1>Initializing and Uninitializing the runtime</h1> 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 well 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. <h3>Create the Window_Loaded event</h3> 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 <img title="image" src="http://files.channel9.msdn.com/wlwimages/9c00b398b405423b99d19efa016fae96/image%5B5%5D-1.png" alt="image" width="377" height="251" border="0 <h3> </h3><h3>Initializing the runtime</h3> Create a new variable <u>outside</u> of the Window_Loaded event to reference the Kinect runtime: C#
<pre class="brush: csharp Runtime nui = new Runtime();[/code] Visual Basic
<pre class="brush: vb Private nui As New Runtime[/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#
<pre class="brush: csharp nui.Initialize(RuntimeOptions.UseColor);[/code] Visual Basic
<pre class="brush: vb nui.Initialize(RuntimeOptions.UseColor)[/code] 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#
<pre class="brush: csharp nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking );[/code] Visual Basic
<pre class="brush: vb nui.Initialize(RuntimeOptions.UseColor Or RuntimeOptions.UseDepthAndPlayerIndex Or RuntimeOptions.UseSkeletalTracking)[/code] <h3>Uninitializing the Runtime</h3> 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#
<pre class="brush: csharp nui.Uninitialize();[/code] Visual Basic
<pre class="brush: vb nui.Uninitialize()[/code] <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Feeds/RSS&WT.dl=0&WT.entryid=Entry:RSSView:8b0685ac5f5543cc87649efe00713a32
View the full article