示例#1
0
        private StereoImage <Bgr, byte> RemapImage(StereoImage <Bgr, byte> stereoImage)
        {
            StereoImage <Bgr, byte> copy = stereoImage.Copy();

            StereoCalibration.RemapStereoImage(copy, _viewModel.CalibrationResult);
            return(copy);
        }
示例#2
0
        public StereoImage <Bgr, byte> GetCalibratedStereoImage()
        {
            var stereoImage = Model.StereoCamera.GetStereoImage();

            if (Model.Calibrated)
            {
                StereoCalibration.RemapStereoImage(stereoImage, Model.CalibrationModel.CalibrationResult);
            }
            return(stereoImage);
        }
示例#3
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;
     }
 }
示例#4
0
        private void Calibrate()
        {
            CalibrationCorners[] samples =
                _viewModel.Samples.Where(_ => _.IsCornersInitialized).Select(_ => _.Corners).ToArray();
            var settings = new CalibrationSettings
            {
                ChessboardHeight = _viewModel.ChessboardHeight,
                ChessboardWidth  = _viewModel.ChessboardWidth,
                CellHeight       = _viewModel.CellHeight,
                CellWidth        = _viewModel.CellWidth,
                Count            = _viewModel.Samples.Count(_ => _.IsCornersInitialized),
                ImageSize        = _viewModel.Samples[0].StereoImage.LeftImage.Size
            };

            _viewModel.CalibrationResult = StereoCalibration.Calibrate(settings, samples);
        }
        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);
                }
            }
        }