private string GetExtraDataText(long currentTimestamp) { if (trackExtraData == TrackExtraData.None) { return(""); } string displayText = "###"; switch (trackExtraData) { case TrackExtraData.Name: displayText = name; break; case TrackExtraData.TotalDistance: PointF o = CalibrationHelper.GetOrigin(); displayText = CalibrationHelper.GetLengthText(o, points["0"], true, true); break; case TrackExtraData.Position: default: displayText = CalibrationHelper.GetPointText(points["0"], true, true, currentTimestamp); break; } return(displayText); }
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); }