Esempio n. 1
0
 private void FindChessboardCornersOnSamples()
 {
     foreach (var sample in _viewModel.Samples)
     {
         var corners = StereoCalibration.FindChessboardCorners(sample.StereoImage, _viewModel.PatternSize);
         if (corners == null)
         {
             continue;
         }
         StereoCalibration.DrawChessboardCorners(sample.StereoImage, corners);
         sample.Corners = corners;
         sample.IsCornersInitialized = true;
     }
 }
        private void ProcessImages(object sender, EventArgs e)
        {
            if (Controller.CameraIsEnabled())
            {
                StereoImage <Bgr, byte> stereoImage = Model.StereoCamera.GetStereoImage();

                if (_viewModel.Mode != CalibrationMode.ShowNotCalibrated)
                {
                    CalibrationCorners corners = StereoCalibration.FindChessboardCorners(stereoImage,
                                                                                         _viewModel.PatternSize);
                    if (corners != null)
                    {
                        StereoCalibration.DrawChessboardCorners(stereoImage, corners);
                    }

                    DrawImage(stereoImage);

                    if (_viewModel.Mode == CalibrationMode.CollectingSamples && corners != null)
                    {
                        CollectedCount.Content = string.Format("Collected: {0}/{1}", _viewModel.Samples.Count,
                                                               _viewModel.Count);
                        if (_viewModel.AllowSaveCorners)
                        {
                            _viewModel.Samples.Add(new CalibrationSample(stereoImage, corners));
                            _viewModel.InvalidateSamples = true;
                            if (_viewModel.Count == _viewModel.Samples.Count)
                            {
                                CollectedCount.Content = string.Empty;
                                SetCameraWindowMode(CalibrationMode.ReadyCalibrating);
                            }
                            SampleList.Items.Refresh();
                        }
                    }
                }
                else
                {
                    DrawImage(stereoImage);
                }
            }
        }