GetPerspectiveTransform() публичный статический Метод

calculates matrix of perspective transform such that: (t_i x'_i,t_i y'_i,t_i)^T=map_matrix (x_i,y_i,1)^T where dst(i)=(x'_i,y'_i), src(i)=(x_i,y_i), i=0..3.
public static GetPerspectiveTransform ( PointF src, PointF dest ) : HomographyMatrix
src System.Drawing.PointF Coordinates of 4 quadrangle vertices in the source image
dest System.Drawing.PointF Coordinates of the 4 corresponding quadrangle vertices in the destination image
Результат HomographyMatrix
Пример #1
0
        /// <summary>
        /// Recover the homography matrix using RANDSAC. If the matrix cannot be recovered, null is returned.
        /// </summary>
        /// <param name="matchedFeatures">The Matched Features, only the first ModelFeature will be considered</param>
        /// <returns>The homography matrix, if it cannot be found, null is returned</returns>
        public static HomographyMatrix GetHomographyMatrixFromMatchedFeatures(MatchedSURFFeature[] matchedFeatures)
        {
            if (matchedFeatures.Length < 4)
            {
                return(null);
            }

            HomographyMatrix homography;

            if (matchedFeatures.Length < _randsacRequiredMatch)
            { // Too few points for randsac, use 4 points only
                PointF[] pts1 = new PointF[4];
                PointF[] pts2 = new PointF[4];
                for (int i = 0; i < 4; i++)
                {
                    pts1[i] = matchedFeatures[i].SimilarFeatures[0].Feature.Point.pt;
                    pts2[i] = matchedFeatures[i].ObservedFeature.Point.pt;
                }
                homography = CameraCalibration.GetPerspectiveTransform(pts1, pts2);
            }
            else
            {
                //use randsac to find the Homography Matrix
                PointF[] pts1 = new PointF[matchedFeatures.Length];
                PointF[] pts2 = new PointF[matchedFeatures.Length];
                for (int i = 0; i < matchedFeatures.Length; i++)
                {
                    pts1[i] = matchedFeatures[i].SimilarFeatures[0].Feature.Point.pt;
                    pts2[i] = matchedFeatures[i].ObservedFeature.Point.pt;
                }

                homography = CameraCalibration.FindHomography(
                    pts1, //points on the model image
                    pts2, //points on the observed image
                    CvEnum.HOMOGRAPHY_METHOD.RANSAC,
                    3);
                if (homography == null)
                {
                    return(null);
                }
            }

            if (homography.IsValid(10))
            {
                return(homography);
            }
            else
            {
                homography.Dispose();
                return(null);
            }
        }