Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            Loaded += MainWindow_Loaded;
            InkInputHelper.DisableWPFTabletSupport();


            _appController     = new ApplicationController(baseDirectory);
            _captureController = _appController.CaptureController;

            if (Settings.Default.accessKey == "")
            {
                MessageBox.Show("Please setup keys in the credentials.json in the " + baseDirectory + " directory",
                                "Missing Credentials", MessageBoxButton.OK);
                Environment.Exit(0);
            }

            KinectSensor.GetDefault().Open();

            _cameraImagePresenter            = new SmithersDS4.Visualization.CameraImagePresenter(camera, Settings.Default.useDSAPI);
            _cameraImagePresenter.CameraMode = SmithersDS4.Visualization.CameraMode.Depth;
            _cameraImagePresenter.Enabled    = true;
            //camera.Source = _captureController.ColorBitmap.Bitmap;

            _captureController.SessionManager.ShotBeginning += (sender, e) =>
            {
                if (_captureController.CaptureMode == SmithersDS4.Sessions.CaptureMode.Trigger)
                {
                    _flashAttack.Begin();
                    _cameraImagePresenter.Enabled = false;
                }
                else
                {
                    _cameraImagePresenter.Enabled = true;
                }
            };

            _captureController.SessionManager.ShotCompletedSuccess += (sender, e) =>
            {
                _cameraImagePresenter.Enabled = true;
            };

            _captureController.SessionManager.ShotCompletedError += (sender, e) =>
            {
                this.Dispatcher.InvokeAsync(() =>
                {
                    _flashDecay.Begin();
                    MessageBox.Show(e.ErrorMessage);
                    _cameraImagePresenter.Enabled = true;
                });
            };

            _captureController.SessionManager.FrameCaptured += (sender, e) =>
            {
                this.Dispatcher.InvokeAsync(() =>
                {
                    _flashDecay.Begin();

                    int numFramesInMemory = _captureController.SessionManager.NumFrameInMemory;

                    lblCaptureCount.Content = "Captured Frames: " + numFramesInMemory;
                    tbCapturedSweeps.Text   = _captureController.Session.SweepCounter.ToString();
                    tbCapturedFrames.Text   = numFramesInMemory.ToString();

                    var sensorProperty = _captureController.Session.Metadata.DeviceConfig;

                    inputImageExposure.Text = sensorProperty.DepthExposure.ToString();
                    inputImageGain.Text     = sensorProperty.DepthGain.ToString();

                    colorImageExposure.Text = sensorProperty.ColorExposure.ToString();
                    colorImageGain.Text     = sensorProperty.ColorGain.ToString();
                });
            };


            _captureController.SessionManager.ShotSavedSuccess += (sender, e) =>
            {
                this.Dispatcher.InvokeAsync(() =>
                {
                    SetBtnCaptureContent("Start Recording");
                    btnCapture.IsEnabled               = true;
                    btnEndSessionAndUpload.IsEnabled   = true;
                    btnEndAndStartNewSession.IsEnabled = true;

                    BtnRedoSweep.Visibility = Visibility.Visible;
                });
            };

            _captureController.SessionManager.ShotSavedError += (sender, e) =>
            {
                this.Dispatcher.InvokeAsync(() =>
                {
                    _flashDecay.Begin();
                    if (e.Exception == null)
                    {
                        MessageBox.Show(e.ErrorMessage);
                    }
                    else
                    {
                        MessageBox.Show(e.ErrorMessage + ": " + e.Exception.Message);
                    }
                });
            };

            _appController.UploadManager.UploadFinished += UploadManager_UploadFinished;

            //_captureController.SkeletonPresenter = new SkeletonPresenter(canvas);
            //_captureController.SkeletonPresenter.ShowBody = true;
            //_captureController.SkeletonPresenter.ShowHands = true;
            ////            _captureController.FrameReader.AddResponder(_captureController.SkeletonPresenter);
            //_captureController.SkeletonPresenter.ProjectionMode = ProjectionMode.COLOR_IMAGE;
            //_captureController.SkeletonPresenter.CoordinateMapper = KinectSensor.GetDefault().CoordinateMapper;
            //_captureController.SkeletonPresenter.Underlay = camera;

            //            _captureController.FrameReader.AddResponder(_cameraImagePresenter);

            _captureController.FrameReader.FrameArrived += _cameraImagePresenter.FrameArrived;

            _captureController.FrameRateReporter.FpsChanged += this.FpsChanged;

            _flashAttack = FindResource("FlashAttack") as Storyboard;
            _flashDecay  = FindResource("FlashDecay") as Storyboard;

            buttonBg = (SolidColorBrush)(new BrushConverter().ConvertFrom("#3cdc3c"));
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            _appController     = new ApplicationController();
            _captureController = _appController.CaptureController;

            KinectSensor.GetDefault().Open();

            _cameraImagePresenter            = new CameraImagePresenter(camera, cameraDummpy);
            _cameraImagePresenter.CameraMode = CameraMode.Color;
            _cameraImagePresenter.Enabled    = true;
            //camera.Source = _captureController.ColorBitmap.Bitmap;

            _captureController.SessionManager.ShotBeginning += (sender, e) =>
            {
                _flashAttack.Begin();
                _cameraImagePresenter.Enabled = false;
            };

            _captureController.SessionManager.ShotCompletedSuccess += (sender, e) =>
            {
                _cameraImagePresenter.Enabled = true;
            };

            _captureController.SessionManager.ShotCompletedError += (sender, e) =>
            {
                _flashDecay.Begin();
                MessageBox.Show(e.ErrorMessage);
                _cameraImagePresenter.Enabled = true;
            };

            _captureController.SessionManager.ShotSavedSuccess += (sender, e) =>
            {
                _flashDecay.Begin();
                lblCaptureCount.Content = _captureController.Session.Shots.Where(x => x.Completed).Count();
            };

            _captureController.SessionManager.ShotSavedError += (sender, e) =>
            {
                _flashDecay.Begin();
                if (e.Exception == null)
                {
                    MessageBox.Show(e.ErrorMessage);
                }
                else
                {
                    MessageBox.Show(e.ErrorMessage + ": " + e.Exception.Message);
                }
            };

            _captureController.SkeletonPresenter           = new SkeletonPresenter(canvas);
            _captureController.SkeletonPresenter.ShowBody  = true;
            _captureController.SkeletonPresenter.ShowHands = true;
            _captureController.FrameReader.AddResponder(_captureController.SkeletonPresenter);
            _captureController.SkeletonPresenter.ProjectionMode   = ProjectionMode.COLOR_IMAGE;
            _captureController.SkeletonPresenter.CoordinateMapper = KinectSensor.GetDefault().CoordinateMapper;
            _captureController.SkeletonPresenter.Underlay         = camera;

            _captureController.FrameReader.AddResponder(_cameraImagePresenter);

            _flashAttack = FindResource("FlashAttack") as Storyboard;
            _flashDecay  = FindResource("FlashDecay") as Storyboard;
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            _appController     = new ApplicationController();
            _captureController = _appController.CaptureController;

            _sensor = KinectSensor.GetDefault();
            _sensor.Open();


            _cameraImagePresenter              = new CameraImagePresenter(camera, cameraDummpy);
            _cameraImagePresenter.CameraMode   = CameraMode.Color;
            _cameraImagePresenter.SparseUpdate = false;
            compressButton.IsEnabled           = false;
            //camera.Source = _captureController.ColorBitmap.Bitmap;

            _captureController.SessionManager.ShotBeginning += (sender, e) =>
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    _flashAttack.Begin();
                    _cameraImagePresenter.SparseUpdate = true;
                    captureControlPanel.IsEnabled = false;
                    captureButton.IsEnabled = false;
                    compressButton.IsEnabled = false;
                }));
            };

            _captureController.SessionManager.ShotCompletedSuccess += (sender, e) =>
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    _cameraImagePresenter.SparseUpdate = false;
                    captureControlPanel.IsEnabled = true;
                    captureButton.IsEnabled = true;
                    compressButton.IsEnabled = false;
                }));
            };

            _captureController.SessionManager.ShotCompletedError += (sender, e) =>
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    _flashDecay.Begin();
                    MessageBox.Show(e.ErrorMessage);
                    _cameraImagePresenter.SparseUpdate = false;
                    captureButton.IsEnabled = true;
                    compressButton.IsEnabled = false;// true;
                }));
            };

            _captureController.SessionManager.ShotSavedSuccess += (sender, e) =>
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    _flashDecay.Begin();
                    lblCaptureCount.Content = _captureController.Session.Shots.Where(x => x.Completed).Count();
                }));
            };

            _captureController.SessionManager.ShotSavedError += (sender, e) =>
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    _flashDecay.Begin();
                    if (e.Exception == null)
                    {
                        MessageBox.Show(e.ErrorMessage);
                    }
                    else
                    {
                        MessageBox.Show(e.ErrorMessage + ": " + e.Exception.Message);
                    }
                }));
            };

            _captureController.SessionManager.updateGUI += (sender, e) =>
            {
                // NOTE: This has to be invoked from the Main Thread or you get an access violation
                //       I don´t know why the other events do not seem to need this.
                this.Dispatcher.Invoke((Action)(() =>
                {
                    averageFPSLabel.Content = String.Format("{0:0.#}", e.AverageFPS);
                    minFPSLabel.Content = String.Format("{0:0.#}", e.MinFPS);
                    maxTimeDeltaLabel.Content = String.Format("{0:0.#}", e.MaxTimeDeleta);
                    percentage_buffer.Content = String.Format("{0:0.00}", e.PercentageBuffer);
                    capture_status.Content = String.Format("{0:0.00}", e.Blabla);
                }));
            };

            _captureController.SkeletonPresenter           = new SkeletonPresenter(canvas);
            _captureController.SkeletonPresenter.ShowBody  = true;
            _captureController.SkeletonPresenter.ShowHands = true;
            _captureController.FrameReader.AddResponder(_captureController.SkeletonPresenter);
            _captureController.SkeletonPresenter.ProjectionMode = ProjectionMode.COLOR_IMAGE;

            _captureController.SkeletonPresenter.CoordinateMapper = KinectSensor.GetDefault().CoordinateMapper;
            _captureController.SkeletonPresenter.Underlay         = camera;


            _captureController.FrameReader.AddResponder(_cameraImagePresenter);

            _flashAttack = FindResource("FlashAttack") as Storyboard;
            _flashDecay  = FindResource("FlashDecay") as Storyboard;
        }