Пример #1
0
        public MainForm()
        {
            InitializeComponent();
            m_UnitsComboBox.SelectedIndex = 0;
            bool useCamera = false;

            if (useCamera)
            {
                m_Capture = new Capture();
            }
            else
            {
                m_Capture        = new Capture(@"C:\svnDev\oss\Google\drh-visual-odometry\TestVideos\2010-07-18 11-10-22.853.wmv");
                m_Timer.Interval = 33;
                m_Timer.Enabled  = true;
            }

            CameraParameters cameraParameters = CameraParameters.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus12\1280x720\MicrosoftCinemaFocus12_1280x720.txt");

            HomographyMatrix GroundProjectionTransformation = HomographyMatrixSupport.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus12\1280x720\BirdsEyeViewTransformationForCalculation.txt");

            m_GroundProjectionTransformationForUI = HomographyMatrixSupport.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus12\1280x720\BirdsEyeViewTransformationForUI.txt");

            m_VisualOdometer = new VisualOdometer(m_Capture, cameraParameters, GroundProjectionTransformation, new OpticalFlow());

            UpdateFromModel();

            m_VisualOdometer.Changed += new EventHandler(OnVisualOdometerChanged);
            Application.Idle         += OnApplicationIdle;
        }
Пример #2
0
        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();
        }
Пример #3
0
        public MainForm()
        {
            InitializeComponent();

            CameraParameters cameraParameters = null;
            HomographyMatrix groundProjectionTransformation = null;

            bool useCamera = false;


            _CamIP = Prompt.ShowDialog("OK para testes", "Conexão Camara");
            if (_CamIP != "")
            {
                useCamera = true;
            }

            if (useCamera)
            {
                //Emgu.CV.CvInvoke.cvCreateFileCapture("http://*****:*****@cam_address/axis-cgi/mjpg/video.cgi?resolution=1280x720&req_fps=30&.mjpg");
                m_Capture = new Capture(0);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);

                cameraParameters = CameraParameters.Load(@"..\..\CalibrationFiles\MicrosoftCinemaFocus12.txt");

                groundProjectionTransformation = HomographyMatrixSupport.Load(@"..\..\CalibrationFiles\BirdsEyeViewTransformationForCalculation.txt");
            }
            else
            {
                m_Capture        = new Capture(@"..\..\CalibrationFiles\2010-07-18 11-10-22.853.wmv");
                m_Timer.Interval = 33;
                m_Timer.Enabled  = true;

                cameraParameters = CameraParameters.Load(@"..\..\CalibrationFiles\MicrosoftCinemaFocus12.txt");

                groundProjectionTransformation = HomographyMatrixSupport.Load(@"..\..\CalibrationFiles\BirdsEyeViewTransformationForCalculation.txt");
            }

            m_VisualOdometer = new VisualOdometer(m_Capture, cameraParameters, groundProjectionTransformation, new OpticalFlow());

            UpdateFromModel();

            m_VisualOdometer.Changed += new EventHandler(OnVisualOdometerChanged);
            Application.Idle         += OnApplicationIdle;

            if (m_MapForm == null || m_MapForm.IsDisposed)
            {
                m_MapForm = new MapForm(m_RobotPath);
            }

            m_MapForm.Show();
        }
Пример #4
0
        public MainForm()
        {
            InitializeComponent();
            m_UnitsComboBox.SelectedIndex = 0;

            CameraParameters cameraParameters = null;
            HomographyMatrix groundProjectionTransformation = null;

            bool useCamera = false;

            if (useCamera)
            {
                m_Capture = new Capture();
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);

                cameraParameters = CameraParameters.Load(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"CalibrationFiles\MicrosoftCinema\Focus14\1280x720\MicrosoftCinemaFocus14_1280x720.txt");

                groundProjectionTransformation        = HomographyMatrixSupport.Load(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"CalibrationFiles\MicrosoftCinema\Focus14\1280x720\BirdsEyeViewTransformationForCalculation.txt");
                m_GroundProjectionTransformationForUI = HomographyMatrixSupport.Load(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"CalibrationFiles\MicrosoftCinema\Focus14\1280x720\BirdsEyeViewTransformationForUI.txt");
            }
            else
            {
                m_Capture = new Capture(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"TestVideos\testvideo.wmv");


                m_Timer.Interval = 33;
                m_Timer.Enabled  = true;

                cameraParameters = CameraParameters.Load(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"CalibrationFiles\MicrosoftCinema\Focus12\1280x720\MicrosoftCinemaFocus12_1280x720.txt");

                groundProjectionTransformation        = HomographyMatrixSupport.Load(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"CalibrationFiles\MicrosoftCinema\Focus12\1280x720\BirdsEyeViewTransformationForCalculation.txt");
                m_GroundProjectionTransformationForUI = HomographyMatrixSupport.Load(ConfigurationSettings.AppSettings["RootFilePath"].ToString() + @"CalibrationFiles\MicrosoftCinema\Focus12\1280x720\BirdsEyeViewTransformationForUI.txt");
            }

            m_VisualOdometer = new VisualOdometer(m_Capture, cameraParameters, groundProjectionTransformation, new OpticalFlow());

            UpdateFromModel();

            m_VisualOdometer.Changed += new EventHandler(OnVisualOdometerChanged);
            Application.Idle         += OnApplicationIdle;
        }