Information on upgrading Kinect Applications to MS SDK Beta 2.
Posted
by mbcrump
on Geeks with Blogs
See other posts from Geeks with Blogs
or by mbcrump
Published on Mon, 14 Nov 2011 13:33:14 GMT
Indexed on
2011/11/14
17:52 UTC
Read the original article
Hit count: 333
Introduction
Microsoft recently released the Kinect for Windows SDK Beta 2. It contains many enhancements and fixes that can be found here. The only problem with it is that a lot of current demo applications no longer function properly. Today, I’m going to walk you through a typical scenario of upgrading a Kinect application built with Beta 1 to Beta 2.
Note: This tutorial covers WPF, but you can use the same techniques for WinForms.
1) Fix the references
Let’s start with a fairly popular Kinect demo called Kinect User Interface Demo.
This project uses the beta 1 version of Microsoft.Research.Kinect.dll and version 1.0.0.0 of Coding4Fun’s Kinect library.
After you download the source code and extract the zip you will see the following references in Visual Studio 2010:
Pay attention to the following references as these are the .dlls that you will have to update:
- Coding4Fun.Kinect.Wpf
- Microsoft.Research.Kinect
If you click on Coding4Fun.Kinect.Wpf file you will see the following version information (v1.0.0.0):
This needs to be upgraded to the Coding4Fun Kinect library built against Beta 2. So head over to http://c4fkinect.codeplex.com/ and hit download and you will have the following files.
Go ahead and hit the delete key on your keyboard to remove the Coding4Fun.Kinect.Wpf.dll file from your project. Select “Add Reference” and navigate out to the folder where you extracted the files and select Coding4Fun.Kinect.Wpf.dll.
If you click on the Coding4Fun.Kinect.Wpf.dll file and check properties it should be listed at 1.1.0.0:
Fix Microsoft.Research.Kinect.dll
The official SDK Beta 2 released a new .dll that you will need to reference in your application. Go ahead and select Microsoft.Research.Kinect.dll in your application and hit the Delete key on your keyboard. Go ahead and select Add Reference again and select Microsoft.Research.Kinect.dll from the .NET tab. Double check and make sure the version number is 1.0.0.45 as shown below.
References fixed – Runtime needs to be updated.
So we have fixed the references in a typical Kinect application that uses Microsoft’s SDK and C4F Kinect libraries. Now, we will need to update the runtime. All Beta 1 Kinect applications will instantiate the Runtime with the following code:
Can you see that it is now marked with [Depreciated]? That means we need to update it before Microsoft decides to remove it from future versions of the SDK.
We can fix this very easily by replacing this code:
readonly Runtime _runtime = new Runtime();
with
Microsoft.Research.Kinect.Nui.Runtime _nui;
and adding similar code to our Loaded event as shown below
public MainWindow() { InitializeComponent(); Loaded += new RoutedEventHandler(MainWindow_Loaded); } void MainWindow_Loaded(object sender, RoutedEventArgs e) { if (Runtime.Kinects.Count == 0) { txtInfo.Text = "Missing Kinect"; } else { _nui = Runtime.Kinects[0]; _nui.Initialize(RuntimeOptions.UseColor); // Video Frame Ready Event can happen now!!! //_nui.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(_nui_VideoFrameReady); _nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); } }
In this sample, I am testing to see if a Kinect is detected and if it is then I initialize the runtime with my first Kinect by using the Runtime.Kinects[0]. You can also specify other Kinect devices here. The rest of the code is standard code that you simply modify however you wish (ie Skeletal, Depth, etc) depending on what type of video feed you want.
Conclusion
As you can see it really wasn’t that painful to upgrade your project to Beta 2. I would recommend that you go ahead and upgrade to Beta 2 as future versions of the SDK will use these methods.
Thanks for reading.
© Geeks with Blogs or respective owner