Example #1
0
        public void Test_Triangulation_NoNoise()
        {
            // 1) We have P, P', F, e, e'
            CreateCameraMatrices();
            CreateEpiGeometry();
            // 2) Create set of 3d points in sensible range
            // 3) Project them onto 2 images using P and P'
            GeneratePoints_Random(_seed);
            // 4) Using pairs of corresponding points find their 3D back-projection with Triangulation
            TwoPointsTriangulation trangulation = new TwoPointsTriangulation();
            trangulation.CameraLeft = _CM_L;
            trangulation.CameraRight = _CM_R;
            trangulation.EpipoleLeft = _epi_L;
            trangulation.EpipoleRight = _epi_R;
            trangulation.Fundamental = _F;
            trangulation.PointsLeft = _imagePointsLeft;
            trangulation.PointsRight = _imagePointsRight;

            trangulation.Estimate3DPoints();
            var ePoints3D = trangulation.Points3D;

            for(int i = 0; i < _pointsCount; ++i)
            {
                var errVec = ePoints3D[i].PointwiseDivide_NoNaN(_realPoints[i]);
                double err = (errVec - DenseVector.Create(4, 1.0)).L2Norm();
                Assert.IsTrue(
                    err < 0.2 || // max 2% diffrence
                    (ePoints3D[i] - _realPoints[i]).L2Norm() < 10);
            }

            // 5) Repeat adding some noise to image coords (matching error)
            // 6) Repeat adding some noise to camera matrix (calibration error)
            // 7) Repeat adding some noise to camera matrix and matched image coords (theoreticaly this is case close to real one)
        }
Example #2
0
        public void Test_Triangulation_NoiseImageOnly()
        {
            // 1) We have P, P', F, e, e'
            CreateCameraMatrices();
            GeneratePoints_Random(_seed);
            NormalisePoints();

            CreateEpiGeometry_Normalized();
            // 2) Create set of 3d points in sensible range
            // 3) Project them onto 2 images using P and P'
            var noisedLeft = AddNoise(_imgPointsNormLeft, 1e-6);
            var noisedRight = AddNoise(_imgPointsNormRight, 1e-6);
            // 4) Using pairs of corresponding points find their 3D back-projection with Triangulation
            TwoPointsTriangulation trangulation = new TwoPointsTriangulation();
            trangulation.CameraLeft = _CMN_L;
            trangulation.CameraRight = _CMN_R;
            trangulation.EpipoleLeft = _epi_L;
            trangulation.EpipoleRight = _epi_R;
            trangulation.Fundamental = _F;
            trangulation.PointsLeft = noisedLeft;
            trangulation.PointsRight = noisedRight;

            trangulation.Estimate3DPoints();
            var ePoints3D = trangulation.Points3D;

            for(int i = 0; i < _pointsCount; ++i)
            {
                trangulation._pL = noisedLeft[i];
                trangulation._pR = noisedRight[i];
               // trangulation.ComputeBackprojected3DPoint();
                var point3d = trangulation._p3D; // To compare with linear
                var realPoint = _realPointsNorm[i];
                var ep3d = ePoints3D[i];
                var elin = (point3d - realPoint);

                var errVec = ePoints3D[i].PointwiseDivide_NoNaN(_realPointsNorm[i]);
                double err = (errVec - DenseVector.Create(4, 1.0)).L2Norm();
                double err2 = (ePoints3D[i] - _realPointsNorm[i]).L2Norm();
                double errlin = (point3d - realPoint).L2Norm();
                //   Assert.IsTrue(
                //       err < 0.2 || // max 2% diffrence
                //       (ePoints3D[i] - _realPoints[i]).L2Norm() < 10);
            }
        }
Example #3
0
        public void Test_Triangulation_LinearFullNoise()
        {
            // 1) We have P, P', F, e, e'
            CreateCameraMatrices();
            GeneratePoints_Random(_seed);
            NormalisePoints();

            // 2) Create set of 3d points in sensible range
            // 3) Project them onto 2 images using P and P'

            var noisedLeft = AddNoise(_imgPointsNormLeft, 1e-12);
            var noisedRight = AddNoise(_imgPointsNormRight, 1e-12);

            //_CMN_L = AddNoise(_CMN_L);
            //_CMN_R = AddNoise(_CMN_R);
            CreateEpiGeometry_Normalized();

            // 4) Using pairs of corresponding points find their 3D back-projection with Triangulation
            TwoPointsTriangulation trangulation = new TwoPointsTriangulation();
            trangulation.CameraLeft = _CMN_L;
            trangulation.CameraRight = _CMN_R;
            trangulation.EpipoleLeft = _epi_L;
            trangulation.EpipoleRight = _epi_R;
            trangulation.Fundamental = _F;
            for(int i = 0; i < _pointsCount; ++i)
            {
                trangulation._pL = noisedLeft[i];
                trangulation._pR = noisedRight[i];
              //  trangulation.ComputeBackprojected3DPoint();
                var point3d = trangulation._p3D;
                var rpoint = _realPointsNorm[i];

                double error = (point3d - rpoint).L2Norm();
            }
               //     Assert.IsTrue(error < 1);
        }
Example #4
0
        public void Test_Triangulation_LinearNoNoise()
        {
            // 1) We have P, P', F, e, e'
            // 2) Create set of 3d points in sensible range
            // 3) Project them onto 2 images using P and P'
            CreateCameraMatrices();
            GeneratePoints_Random(_seed);
            NormalisePoints();
            CreateEpiGeometry_Normalized();
            // 4) Using pairs of corresponding points find their 3D back-projection with Triangulation
            TwoPointsTriangulation trangulation = new TwoPointsTriangulation();
            trangulation.CameraLeft = _CM_L;
            trangulation.CameraRight = _CM_R;
            trangulation.EpipoleLeft = _epi_L;
            trangulation.EpipoleRight = _epi_R;
            trangulation.Fundamental = _F;

            trangulation._pL = _imagePointsLeft[0];
            trangulation._pR = _imagePointsRight[0];
             //   trangulation.ComputeBackprojected3DPoint();
            var point3d = trangulation._p3D;

            Assert.IsTrue((point3d - _realPoints[0]).L2Norm() < 1e-6);
        }
Example #5
0
        public void Test_Triangulation_EpilineFitCost()
        {
            CreateCameraMatrices();
            GeneratePoints_Random(_seed);
            NormalisePoints();
            CreateEpiGeometry_Normalized();

            TwoPointsTriangulation trangulation = new TwoPointsTriangulation();
            trangulation.CameraLeft = _CMN_L;
            trangulation.CameraRight = _CMN_R;
            trangulation.EpipoleLeft = _epi_L;
            trangulation.EpipoleRight = _epi_R;
            trangulation.Fundamental = _F;

              //  trangulation.ComputeEpilineFitCost(10.0);
        }