private void Window_Closing(object sender, CancelEventArgs e) { // Shutdown Tracker if (tracker != null) { tracker.Shutdown(); tracker.Dispose(); tracker = null; } // Destroy Transformation if (transformation != null) { transformation.Dispose(); transformation = null; } // Stop and Close Camera if (device != null) { device.StopCameras(); device.Dispose(); device = null; } }
private void Window_Unloaded(object sender, RoutedEventArgs e) { // Shutdown Tracker if (tracker != null) { tracker.Shutdown(); tracker.Dispose(); tracker = null; } // Stop and Close Camera if (device != null) { device.StopCameras(); device.Dispose(); device = null; } }
public MainWindow() { InitializeComponent(); // Open Device device = K4A.Device.Open(); // Start Cameras device.StartCameras(new K4A.DeviceConfiguration { ColorFormat = K4A.ImageFormat.ColorBGRA32, ColorResolution = K4A.ColorResolution.R720p, DepthMode = K4A.DepthMode.NFOV_2x2Binned, SynchronizedImagesOnly = true }); // Get Calibration calibration = device.GetCalibration(K4A.DepthMode.NFOV_2x2Binned, K4A.ColorResolution.R720p); // Create Tracker tracker = K4ABT.Tracker.Create( calibration, new K4ABT.TrackerConfiguration { SensorOrientation = K4ABT.SensorOrientation.Default, ProcessingMode = K4ABT.TrackerProcessingMode.Gpu } ); // Create Buffer int color_width = calibration.ColorCameraCalibration.ResolutionWidth; int color_height = calibration.ColorCameraCalibration.ResolutionHeight; const int color_channles = 4; color_stride = color_width * sizeof(byte) * color_channles; color_rect = new Int32Rect(0, 0, color_width, color_height); color_bitmap = new WriteableBitmap(color_width, color_height, 96.0, 96.0, PixelFormats.Bgra32, null); // Generate Color LUT colors = new Color[6]; colors[0] = new Color() { B = 255, G = 0, R = 0, A = 128 }; colors[1] = new Color() { B = 0, G = 255, R = 0, A = 128 }; colors[2] = new Color() { B = 0, G = 0, R = 255, A = 128 }; colors[3] = new Color() { B = 255, G = 255, R = 0, A = 128 }; colors[4] = new Color() { B = 0, G = 255, R = 255, A = 128 }; colors[5] = new Color() { B = 255, G = 0, R = 255, A = 128 }; // Bined Image Control Color_Image.Source = color_bitmap; Color_Image.Width = color_width; Color_Image.Height = color_height; // Set Cnvas Size Canvas_Body.Width = color_width; Canvas_Body.Height = color_height; }