There are too few small programs on the web based on kinect2.0 in C # language.
The links below are some of the basic development of the C # language, and the best way to do nothing is to tap it again.
http://blog.csdn.net/app_12062011/article/details/52665048
Using kinect2.0 requires the following environment:
System Win8 above
USB Interface 3.0
Direct11 or more
1. To create a new WPF application, you must first add an app Microsoft.kinect
2. Add a control to the grid in WPF
<image x:name= "Image"/>
3. The back-end code is as follows
public partial class Mainwindow:window
{
Private kinectsensor kinect = null;
Private Colorframereader colorframe = null;
Private WriteableBitmap colorbitmap = null;
Private framedescription colorframedescription = null;
Private Int32Rect Colorbitmaprect;
private int colorbitmapstride;
byte[] Pixeldata = null;
Public MainWindow ()
{
InitializeComponent ();
This.kinect = Kinectsensor.getdefault ();
This.colorframe = Kinect. Colorframesource.openreader ();
This.colorFrame.FrameArrived + = colorframe_framearrived;
This.colorframedescription = This.kinect.ColorFrameSource.CreateFrameDescription (Colorimageformat.bgra);
Pixeldata = new Byte[colorframedescription.lengthinpixels*4];
Set the data Frame description information (b:blue,g:green,r:red,a:alpha) in Bgra format
1920*1080 Color Image
This.colorbitmap = new WriteableBitmap (Colorframedescription.width, Colorframedescription.height, 96.0, 96.0, Pixelformats.bgr32, NULL);
Create an instance of Colorbitmap based on the width and height of the data frame
This.colorbitmaprect = new Int32Rect (0, 0, this.colorBitmap.PixelWidth, colorbitmap.pixelheight);
This.colorbitmapstride = This.colorFrameDescription.Width * 4;
Image. Source = This.colorbitmap;
This.kinect.Open (); Start the Kinect camera
}
void Colorframe_framearrived (object sender, Colorframearrivedeventargs e)
{
using (Colorframe frame = E.framereference.acquireframe ())
Create an instance of Colorframe frame save the sent frame, through using to ensure that the function to release the corresponding resources in time
{
if (frame! = null)
{
Frame. Copyconvertedframedatatoarray (This.pixeldata, Colorimageformat.bgra);
for (int i = 0; i < pixeldata.length; I +=4)//It seems that Bgra is a 4-bit
{
Pixeldata[i] = 0x00;//Close Blue Channel
Pixeldata[i + 1] = 0x00;//off green channel
Pixeldata[i + 2] = 0x00;//Close red channel
}
This.colorBitmap.WritePixels (This.colorbitmaprect, This.pixeldata, this.colorbitmapstride, 0);
}
}
}
After opening the effect is as follows (leaving only the green channel)
KINECT2.0 Foundation Chapter One channel of a tri-color channel that closes a color image in C # on Visual Studio