For First Project I Work On Project A Video Camera display
I bought XBox Kinect + Adapter ($117)
1 Download KinectSDK-v1.8 And Install It.
2 - Install Microsoft Visual Studio 2012
3 - I connect the Kinect to the PC And Drivers installed without problem.
4 - Run Virtual Studio 2012 And Create a Windows Presentation Foundation (WPF) application Project (C#)
5 - add the Kinect SDK assemblies to project.(C:\Program Files\Microsoft SDKs\Kinect\v1.8\Assemblies\Microsoft.Kinect.dll)
6 - add The following code top of the program Codes that This makes it easier to use the Kinect classes in programs.
7 - add The following code top of the program Codes that The program can then use this variable every time it wants to control the Kinect.
public partial class MainWindow : Window
{
KinectSensor myKinect;
public MainWindow()
{
InitializeComponent();
}
}
}
8 - add Window_Loaded event handler in MainWindow.
9 - add the statement below to the Window_Loaded that set the value of Kinect to refer to the KinectSensor class that the program will be using.
Now that the program has an object that can be used to control a Kinect sensor
myKinect = KinectSensor.KinectSensors[0];
10 - The first thing it must do is initialize the sensor and tell the sensor what kind of data to produce. We can ask the sensor for several different kinds of data. Your Enable method as follows. This version of the Enable method has no parameters and asks the Kinect sensor to generate video frames that are 640 pixels wide and 480 pixels high at the rate of 30 frames a second. You can add a parameter to the Enable method if you want different resolutions.
myKinect.ColorStream.Enable();
[/b]
11 - The next thing the program must do is to tell the sensor what to do when it has captured some new video data to be displayed. The program will use an event handler to do this. Effectively it will say to myKinect, “When you get a new frame to display, call this method, which will draw it on the screen.” You can get Visual Studio to generate the event handler method for you. Start by typing the following into the Window_Loaded method just underneath the call of Initialize:
myKinect.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(myKinect_ColorFrameReady);
12 - add The following code For Start The Kinect
13 - add The following code End Of private void Window_Loaded(object sender, RoutedEventArgs e)
void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
throw new NotImplementedException();
}
14 - Next, you have to add the code that takes the video frame and displays it on the screen , there are two stages to this. the first stage is to create an image display element in the WPF window on the screen, and the second stage is to create the code that will take the video data from the Kinect data stream and put it on the image
on the screen.
15 - Adding an Image Display element to the WPF Window , Go to MainWindow.xaml And add The following code , You have created an Image element and given it the name kinectVideo. The program can use this name to refer to the image in the window on the screen.
16 - add The following codes in void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) //get the color image frame out of the parameters supplied to the event handler.
{
if (colorFrame == null) return; // The program must test to make sure that it has a genuine frame to work on.
byte[] colorData = new byte[colorFrame.PixelDataLength]; //It must now create a buffer to hold all the video data that has been received from the camera.
colorFrame.CopyPixelDataTo(colorData); //extract the color data from the frame and put it in the array.
kinectVideo.Source = BitmapSource.Create(
colorFrame.Width, colorFrame.Height, // image dimensions
96, 96, // resolution - 96 dpi for video frames
PixelFormats.Bgr32, // video format
null, // palette - none
colorData, // video data
colorFrame.Width * colorFrame.BytesPerPixel // stride
);
}
At this point all the links in the chain should be complete, and you have a program that should use
the video camera in the Kinect sensor.
Refrence : Start Here! Learn The Kinect API
Regards