Accord.Imaging.Tools.Fundamental C# (CSharp) Method

Fundamental() public static method

Creates the fundamental matrix between two images from a set of points from each image.
public static Fundamental ( PointF points1, PointF points2 ) : ].float[
points1 System.Drawing.PointF
points2 System.Drawing.PointF
return ].float[
        public static float[,] Fundamental(PointF[] points1, PointF[] points2)
        {
            int N = points1.Length;

            float[,] T1, T2; // Normalize input points
            points1 = Tools.Normalize(points1, out T1);
            points2 = Tools.Normalize(points2, out T2);


            float[,] A = new float[N, 9];
            for (int i = 0; i < N; i++)
            {
                float x1 = points1[i].X;
                float y1 = points1[i].Y;

                float x2 = points2[i].X;
                float y2 = points2[i].Y;

                A[i, 0] = x2 * x1;
                A[i, 1] = x2 * y1;
                A[i, 2] = x2;

                A[i, 3] = y2 * x1;
                A[i, 4] = y2 * y2;
                A[i, 5] = y2;

                A[i, 6] = x1;
                A[i, 7] = y1;
                A[i, 8] = 1;
            }

            float[,] F = createFundamentalMatrix(A);

            // Denormalize
            F = T2.TransposeAndDot(F.Dot(T1));

            return F;
        }

Same methods

Tools::Fundamental ( Accord.Imaging.PointH points1, Accord.Imaging.PointH points2 ) : ].float[
Tools::Fundamental ( Accord.Imaging.PointH points1, Accord.Imaging.PointH points2, Accord.Imaging.PointH &epipoles ) : ].float[

Usage Example

        /// <summary>
        ///   Estimates a fundamental matrix with the given points.
        /// </summary>
        ///
        private float[,] fundamental(int[] points)
        {
            // Retrieve the original points
            PointF[] x1 = this.pointSet1.Submatrix(points);
            PointF[] x2 = this.pointSet2.Submatrix(points);

            // Compute the homography
            return(Tools.Fundamental(x1, x2));
        }