public MainForm() { InitializeComponent(); m_CameraParameters = CameraParameters.Load(@"..\..\..\..\CalibrationFiles\MicrosoftCinema\Focus14\1280x720\MicrosoftCinemaFocus14_1280x720.txt"); m_RawImage = new Image<Bgr, byte>(@"..\..\..\..\CalibrationFiles\MicrosoftCinema\Focus14\1280x720\GroundProjectionCalibration.jpg"); this.CurrentImage = m_RawImage.Clone(); this.BirdsEyeImage = m_RawImage.Clone(); InitializeUndistortMap(m_RawImage); Undistort(m_RawImage, this.CurrentImage); this.ChessBoard = new ChessBoard(8, 10); PointF[] foundCorners = CollectImageCorners(); DrawFoundCorners(this.CurrentImage, foundCorners); // We pick four corners for perspective transform PointF[] outerCorners = new PointF[4]; outerCorners[0] = foundCorners[0]; outerCorners[1] = foundCorners[this.ChessBoard.PatternSize.Width - 1]; outerCorners[2] = foundCorners[this.ChessBoard.PatternSize.Width * this.ChessBoard.PatternSize.Height - this.ChessBoard.PatternSize.Width]; outerCorners[3] = foundCorners[this.ChessBoard.PatternSize.Width * this.ChessBoard.PatternSize.Height - 1]; DrawOuterCorners(this.CurrentImage, outerCorners); float side; float bottom; float centerX; side = 25.0f; bottom = 310.0f; PointF[] physicalPointsForCalculation = new PointF[4]; physicalPointsForCalculation[0] = new PointF(-3 * side, bottom + 8 * side); physicalPointsForCalculation[1] = new PointF(+3 * side, bottom + 8 * side); physicalPointsForCalculation[2] = new PointF(-3 * side, bottom); physicalPointsForCalculation[3] = new PointF(+3 * side, bottom); m_BirdsEyeViewTransformationForCalculation = CameraCalibration.GetPerspectiveTransform(outerCorners, physicalPointsForCalculation); HomographyMatrixSupport.Save(m_BirdsEyeViewTransformationForCalculation, "BirdsEyeViewTransformationForCalculation.txt"); side = 8f; bottom = 700.0f; centerX = (float)m_CameraParameters.Intrinsic.Cx; PointF[] physicalPointsForUI = new PointF[4]; physicalPointsForUI[0] = new PointF(-3 * side + centerX, bottom - 8 * side); physicalPointsForUI[1] = new PointF(+3 * side + centerX, bottom - 8 * side); physicalPointsForUI[2] = new PointF(-3 * side + centerX, bottom); physicalPointsForUI[3] = new PointF(+3 * side + centerX, bottom); m_BirdsEyeViewTransformationForUI = CameraCalibration.GetPerspectiveTransform(outerCorners, physicalPointsForUI); HomographyMatrixSupport.Save(m_BirdsEyeViewTransformationForUI, "BirdsEyeViewTransformationForUI.txt"); //m_BirdsEyeViewTransformationForCalculation.ProjectPoints(outerCorners); CreateAndDrawBirdsEyeView(); }
public VisualOdometer(Capture capture, CameraParameters cameraParameters, HomographyMatrix birdsEyeViewTransformation, OpticalFlow opticalFlow) { m_Capture = capture; m_CameraParameters = cameraParameters; this.GroundRegionTop = OdometerSettings.Default.GroundRegionTop; this.SkyRegionBottom = OdometerSettings.Default.SkyRegionBottom; this.OpticalFlow = opticalFlow; m_RotationAnalyzer = new RotationAnalyzer(this); m_TranslationAnalyzer = new TranslationAnalyzer(this, birdsEyeViewTransformation); }