Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        public PictureRecorder()
        {
            InitializeComponent();

            this.kinect = Device.Open();

            this.kinect.StartCameras(new DeviceConfiguration
            {
                ColorFormat            = Microsoft.Azure.Kinect.Sensor.ImageFormat.ColorBGRA32,
                ColorResolution        = ColorResolution.R720p,
                DepthMode              = DepthMode.NFOV_2x2Binned,
                SynchronizedImagesOnly = true
            });

            this.transform = this.kinect.GetCalibration().CreateTransformation();

            this.colorWidth  = this.kinect.GetCalibration().ColorCameraCalibration.ResolutionWidth;
            this.colorHeight = this.kinect.GetCalibration().ColorCameraCalibration.ResolutionHeight;

            this.bitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
            //change PixelFormat BGR£" for no depth
            //this.bitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null);

            this.DataContext = this;

            this.Loaded += PictureRecorder_Loaded;
        }
        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_Unbinned,
                SynchronizedImagesOnly = true
            });

            // Create Transformation
            transformation = device.GetCalibration().CreateTransformation();

            // Create Buffer
            #if TO_COLOR
            int width  = device.GetCalibration().ColorCameraCalibration.ResolutionWidth;
            int height = device.GetCalibration().ColorCameraCalibration.ResolutionHeight;
            #else
            int width  = device.GetCalibration().DepthCameraCalibration.ResolutionWidth;
            int height = device.GetCalibration().DepthCameraCalibration.ResolutionHeight;
            #endif

            const int color_channles = 4;
            color_stride = width * sizeof(byte) * color_channles;
            color_rect   = new Int32Rect(0, 0, width, height);
            color_bitmap = new WriteableBitmap(width, height, 96.0, 96.0, PixelFormats.Bgra32, null);

            const int depth_channles = 1;
            depth_stride = width * sizeof(byte) * depth_channles;
            depth_rect   = new Int32Rect(0, 0, width, height);
            depth_bitmap = new WriteableBitmap(width, height, 96.0, 96.0, PixelFormats.Gray8, null);

            // Bined Image Control
            Color_Image.Source = color_bitmap;
            Color_Image.Width  = width;
            Color_Image.Height = height;

            Depth_Image.Source = depth_bitmap;
            Depth_Image.Width  = width;
            Depth_Image.Height = height;
        }
        private void Window_Unloaded(object sender, RoutedEventArgs e)
        {
            // Destroy Transformation
            if (transformation != null)
            {
                transformation.Dispose();
                transformation = null;
            }

            // Stop and Close Camera
            if (device != null)
            {
                device.StopCameras();
                device.Dispose();
                device = null;
            }
        }
Beispiel #5
0
        public Recorder()
        {
            // Open the default device
            this.kinect = Device.Open();

            // Configure camera modes
            this.kinect.StartCameras(new DeviceConfiguration
            {
                ColorFormat            = Microsoft.Azure.Kinect.Sensor.ImageFormat.ColorBGRA32,
                ColorResolution        = ColorResolution.R720p,
                DepthMode              = DepthMode.NFOV_2x2Binned,
                SynchronizedImagesOnly = true
            });

            this.transform = this.kinect.GetCalibration().CreateTransformation();

            this.colorWidth  = this.kinect.GetCalibration().ColorCameraCalibration.ResolutionWidth;
            this.colorHeight = this.kinect.GetCalibration().ColorCameraCalibration.ResolutionHeight;

            this.bitmapColorCamera = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null);

            // this.bitmapCrop =  new Bitmap(300, 300);

            this.DataContext = this;

            InitializeComponent();
            this.Loaded   += Recorder_Loaded;
            this.Unloaded += Recorder_Unloaded;


            box.ItemsSource = Enum.GetValues(typeof(HandGestures));


            graph = new TFGraph();
            graph.Import(File.ReadAllBytes(@"C:\Users\Public\TestFolder\my_model.pb"));
            session = new TFSession(graph);
            runner  = session.GetRunner();
        }
Beispiel #6
0
        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 Transformation
            transformation = calibration.CreateTransformation();

            // 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);

            const int body_index_map_channles = 4;

            body_index_map_stride           = color_width * sizeof(byte) * body_index_map_channles;
            body_index_map_rect             = new Int32Rect(0, 0, color_width, color_height);
            body_index_map_bitmap           = new WriteableBitmap(color_width, color_height, 96.0, 96.0, PixelFormats.Bgra32, null);
            colorized_body_index_map_buffer = new byte[color_width * color_height * color_channles];

            // 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;

            Index_Map.Source = body_index_map_bitmap;
            Index_Map.Width  = color_width;
            Index_Map.Height = color_height;
        }