Kinect “Where to start?”
Let’s get directly Into the Core of this Blog post,
1st Get a Kinect For windows unit.
2nd Download the SDK and the Toolkit which you will find here.
3rd Play Around with the toolkit where you will find a lot of helpful resources and demo`s.
Then let’s make a simple application to display the data from the RGB camera.
Create a new WPF Project.
add “using Microsoft.Kinect; “
initialize sensor :
KinectSensor Kinect;
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
if (KinectSensor.KinectSensors.Count < 1)
{
MessageBox.Show("No Kinect Sensor Attached");
}
else
{
startkinect();
}
}
private void startkinect()
{
//Link The 1st Kinect
Kinect = KinectSensor.KinectSensors.FirstOrDefault();
//Enable Color Stream
Kinect.ColorStream.Enable();
//Start Sensor
Kinect.Start();
Kinect.AllFramesReady += Kinect_AllFramesReady;
}
At MainWindows.xaml add Image with width=320 Height=240 and Name = RGB .
Now lets link the RGB Data To the Image frame.
void Kinect_AllFramesReady(object sender, AllFramesReadyEventArgs e) { colorFrame(e); } private void colorFrame(AllFramesReadyEventArgs e) { using (ColorImageFrame ColorFrame = e.OpenColorImageFrame()) { if (ColorFrame == null) { return; } byte [] Pixels = new byte[ColorFrame.PixelDataLength] ; ColorFrame.CopyPixelDataTo(Pixels); int stride = ColorFrame.Width*4; RGB.Source = BitmapSource.Create(ColorFrame.Width ,ColorFrame.Height,96,96,PixelFormats.Bgr32,null,Pixels ,stride); } }
One last thing don’t forget to close the Kinect When You are Done :)
private void Window_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
{
Kinect.Stop();
Kinect = null;
}
Now You are all done,lets run It.
You should be seeing a Video for what ever in front of the Kinect.
And that’s all you are Done with your 1st application , If you have any questions don’t hesitate To ask me
Comments
- Anonymous
February 24, 2013
Hey dude, just a idea am working on with a team: you've probably seen Jonny Lee's Wii enabled interactive whiteboard (www.google.com/url)We are attempting to make the same happen even better with a Kinect: We'd appreciate any resources you can share for such a project.