/// <summary> /// Driver /// </summary> /// <param name="args"> /// A <see cref="System.String[]"/> /// </param> public static void Main (string[] args) { Console.WriteLine("----------------------------------------"); Console.WriteLine("| Kinect.NET Wrapper Test |"); Console.WriteLine("----------------------------------------\n"); // Try to get number of devices connected Console.WriteLine(" - Device Count: " + Kinect.DeviceCount); // Do more tests if there are devices present if(Kinect.DeviceCount > 0) { // Try to open a device Kinect k = new Kinect(0); Console.Write(" - Opening device 0..."); k.Open(); Console.WriteLine("Done."); // Try to set LED colors Console.WriteLine(" - LED Testing"); string[] colors = Enum.GetNames(typeof(LEDColor)); foreach(string color in colors) { var c = (LEDColor)Enum.Parse(typeof(LEDColor), color); Console.WriteLine("\t - Setting LED to Color: " + color); k.LED.Color = c; Thread.Sleep(3000); } // Try to control motor Console.WriteLine(" - Motor Testing"); Console.WriteLine("\t - Setting tilt to 1 (should face all the way up)"); k.Motor.Tilt = 1; Thread.Sleep(3000); Console.WriteLine("\t - Setting tilt to -1 (should face all the way down)"); k.Motor.Tilt = -1; Thread.Sleep(3000); Console.WriteLine("\t - Setting tilt to 0 (should be back level)"); k.Motor.Tilt = 0; Thread.Sleep(3000); // Close device Console.Write(" - Closing device 0..."); k.Close(); Console.WriteLine("Done."); } // Shutdown the Kinect context Kinect.Shutdown(); // Pause... Console.ReadKey(true); }
public MainWindow() { this.worker = new BackgroundWorker(); this.worker.DoWork += new DoWorkEventHandler(worker_DoWork); string fileName = String.Format("{0}_{1}_{2}_{3}_{4}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,DateTime.Now.Minute); this.kinectWriter = new KinectWriter(@"C:\Temp\" + fileName + ".kinect"); this.positionWriter = new PositiontWriter(@"C:\Temp\" + fileName + ".location"); this.positionSensor = new TcpGpsSensor("127.0.0.1", 4352); this.positionSensor.PositionReceived += new EventHandler<PositionEventArgs>(positionSensor_PositionReceived); InitializeComponent(); //startup logic from C# wrapper example if (Kinect.DeviceCount > 0) { kinect = new Kinect(0); kinect.Open(); kinect.VideoCamera.DataBuffer = IntPtr.Zero; kinect.DepthCamera.DataBuffer = IntPtr.Zero; kinect.VideoCamera.DataReceived += VideoCamera_DataReceived; kinect.DepthCamera.DataReceived += DepthCamera_DataReceived; kinect.VideoCamera.Start(); kinect.DepthCamera.Start(); worker.RunWorkerAsync(); this.positionSensor.Connect(); this.positionSensor.Start(); ThreadPool.QueueUserWorkItem( delegate { while (!_closed) { kinect.UpdateStatus(); Kinect.ProcessEvents(); Thread.Sleep(30); } }); } }