public void CalibrationByLine_Initialize(Guid id, float length, PointF a, PointF b)
        {
            calibrationDrawingId = id;
            PointF aRectif = distortionHelper.Undistort(a);
            PointF bRectif = distortionHelper.Undistort(b);

            calibrationPlane.Initialize(length, aRectif, bRectif);
            AfterCalibrationChanged();
        }
Example #2
0
        public void CalibrationByPlane_Initialize(SizeF size, QuadrilateralF quadImage)
        {
            QuadrilateralF undistorted = new QuadrilateralF(
                distortionHelper.Undistort(quadImage.A),
                distortionHelper.Undistort(quadImage.B),
                distortionHelper.Undistort(quadImage.C),
                distortionHelper.Undistort(quadImage.D));

            calibrationPlane.Initialize(size, undistorted);
            AfterCalibrationChanged();
        }
Example #3
0
        public void Reset()
        {
            calibratorType   = CalibratorType.Line;
            calibrationPlane = new CalibrationPlane();

            PointF center = imageSize.Center();

            calibrationPlane.Initialize(100, center, new PointF(center.X + 100, center.Y), CalibrationAxis.LineHorizontal);

            calibrator = calibrationPlane;

            distortionHelper = new DistortionHelper();

            lengthUnit = LengthUnit.Pixels;

            ComputeCoordinateSystemGrid();
        }
Example #4
0
        private static CoordinateSystemGrid FindForLineCalibration(CalibrationHelper calibrationHelper)
        {
            CoordinateSystemGrid grid        = new CoordinateSystemGrid();
            RectangleF           imageBounds = new RectangleF(PointF.Empty, calibrationHelper.ImageSize);

            // The clip window is an inflated version of the image to account for distortion.
            RectangleF clipWindow = imageBounds.CenteredScale(1.3f);

            // Create a fake plane to act as the user-defined projected plane.
            QuadrilateralF quadImage = new QuadrilateralF(imageBounds.Deflate(2.0f));
            PointF         a         = calibrationHelper.GetPointFromRectified(quadImage.A);
            PointF         b         = calibrationHelper.GetPointFromRectified(quadImage.B);
            PointF         d         = calibrationHelper.GetPointFromRectified(quadImage.D);
            RectangleF     plane     = new RectangleF(0, 0, b.X - a.X, a.Y - d.Y);

            // Define the extended plane (for vanishing point replacement and drawing stop condition) as the reprojection of the whole image.
            QuadrilateralF extendedPlane = ReprojectImageBounds(calibrationHelper, new QuadrilateralF(imageBounds));

            CalibrationPlane calibrator = new CalibrationPlane();

            calibrator.Initialize(plane.Size, quadImage);
            PointF originImage     = calibrationHelper.GetOrigin();
            PointF originRectified = originImage;

            if (calibrationHelper.DistortionHelper != null && calibrationHelper.DistortionHelper.Initialized)
            {
                originRectified = calibrationHelper.DistortionHelper.Undistort(originImage);
            }

            calibrator.SetOrigin(originRectified);

            // From this point on we are mostly in the same situation as for plane calibration.

            // stepping size is the same in both directions.
            int   targetSteps = 15;
            float width       = extendedPlane.B.X - extendedPlane.A.X;
            float step        = RangeHelper.FindUsableStepSize(width, targetSteps);

            CreateVerticalGridLines(grid, 0, -step, calibrator, clipWindow, plane, extendedPlane, true, false, PointF.Empty);
            CreateVerticalGridLines(grid, step, step, calibrator, clipWindow, plane, extendedPlane, true, false, PointF.Empty);
            CreateHorizontalGridLines(grid, 0, -step, calibrator, clipWindow, plane, extendedPlane, true, false, PointF.Empty);
            CreateHorizontalGridLines(grid, step, step, calibrator, clipWindow, plane, extendedPlane, true, false, PointF.Empty);

            return(grid);
        }
        public void Reset()
        {
            calibratorType   = CalibratorType.Line;
            calibrationPlane = new CalibrationPlane();

            PointF center = imageSize.Center();

            calibrationPlane.Initialize(100, center, new PointF(center.X + 100, center.Y));

            //SetOrigin(imageSize.Center());
            calibrator = calibrationPlane;

            distortionHelper = new DistortionHelper();

            lengthUnit       = LengthUnit.Pixels;
            speedUnit        = SpeedUnit.PixelsPerSecond;
            accelerationUnit = AccelerationUnit.PixelsPerSecondSquared;

            ComputeCoordinateSystemGrid();
        }