public MainWindow() { InitializeComponent(); Closing += new System.ComponentModel.CancelEventHandler(OnClosing); if (CLNUIDevice.GetDeviceCount() < 1) { MessageBox.Show("Is the Kinect plugged in?"); Environment.Exit(0); } string serialString = CLNUIDevice.GetDeviceSerial(0); camera = CLNUIDevice.CreateCamera(serialString); colorImage = new NUIImage(640, 480); depthImage = new NUIImage(640, 480); rawImage = new NUIImage(640, 480); color.Source = colorImage.BitmapSource; depth.Source = depthImage.BitmapSource; running = true; captureThread = new Thread(delegate() { if (CLNUIDevice.StartCamera(camera)) { while (running) { CLNUIDevice.GetCameraColorFrameRGB32(camera, colorImage.ImageData, 0); CLNUIDevice.GetCameraDepthFrameRGB32(camera, depthImage.ImageData, 0); CLNUIDevice.GetCameraDepthFrameRAW(camera, rawImage.ImageData, 0); Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) delegate() { colorImage.Invalidate(); depthImage.Invalidate(); }); } } }); captureThread.IsBackground = true; captureThread.Start(); }
public MainWindow() { InitializeComponent(); Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); try { _devCount = CLNUIDevice.GetDeviceCount(); if (_devCount == 0) { Environment.Exit(0); } for (int i = 0; i < _devCount; i++) { string devSerial = CLNUIDevice.GetDeviceSerial(i); cameras.Items.Add(string.Format("Kinect Serial: {0}", devSerial)); cameraWindows[i] = new CameraWindow(devSerial); cameraWindows[i].Show(); } } catch { } }