Kinecting with WinForms
- Posted: Aug 28, 2012 at 6:00 AM
- 5,005 Views
Today's project by Walt Smith provides a tutorial (and code) for getting started with the Kinect and WinForms (yes, WinForms).
Hi everyone, this sample will show you the basics of how to use the Kinect for Windows device within a Winforms application. While there are many examples in the Kinect SDK for WPF and XNA, there are not many good examples of doing a WinForms application. I hope you enjoy this
To begin this tutorial, open a new Windows Forms project in Visual Studio. You can name it whatever you wish. This should automatically create a form, usually called Form1 unless you rename it.
This sample uses the KinectSensorChooser classes from the Microsoft.Kinect.Toolkit source code. Before you build the sample, be sure to bring the following source code files into your project:
You can find these files in the toolkit samples directory. Mine was at
C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.5.0\Samples\C#\Microsoft.Kinect.Toolkit
but your mileage may vary. Also be sure to add a reference into your project for the Microsoft.Kinect namespace. It should have been installed into your .NET namespaces when you installed the Kinect SDK and Toolkit.
Now open up Form1.cs in the design view and add a Load event to the Form by selecting the Form properties window and double clicking the Load event. This action should switch you automatically to the Form1.cs code view. If it does not, do this manually.
In the code file, add a using clause for Microsoft.Kinect. Then add an instance variable for the KinectSensorChooser in the Form1 class. In the Form1_Load method and instantiate the KinectSensorChooser instance that you just created. Also, add a delegate to the KinectChanged event on the KinectSensorChooser and then call the Start method on the chooser. Your Form1_Load event should now look something like this:
Project Information URL: http://code.msdn.microsoft.com/Beginning-Kinect-for-a198d400
Project Download URL: http://code.msdn.microsoft.com/Beginning-Kinect-for-a198d400
Project Source URL: http://code.msdn.microsoft.com/Beginning-Kinect-for-a198d400