若是要進行Kinect for windows的開發,首先要下載它的SDK和ToolKit,下載地址爲:http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx。windows
- KinectSensor kinectsensor = null; //定義一個Kinect對象
- private void Form1_Shown(object sender, EventArgs e)
- {
- //從Kinect集合中找到鏈接上的Kinect
- foreach (KinectSensor ks in KinectSensor.KinectSensors)
- {
- //找到鏈接的Kinect
- if (ks.Status == KinectStatus.Connected)
- {
- kinectsensor = ks; //把找到鏈接的Kinect對象賦給全局Kinect對象
- kinectsensor.Start();//開始工做,便可以採集攝像頭和紅外攝像頭信息
- this.Text = "Kinect開始工做……";//提示信息
- return;
- }
- }
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (kinectsensor.Status == KinectStatus.Connected)
- {
- kinectsensor.Stop();//結束Kinect採集工做
- MessageBox.Show ( "Kinect結束工做!");
- }
- }
- }
通常狀況下,咱們在系統啓動的時候啓動Kinect,在系統關閉時關閉Kinect,固然要根據本身的項目狀況而定。ide