コード例 #1
0
ファイル: Cv2_calib3d.cs プロジェクト: kaorun55/opencvsharp
        /// <summary>
        /// computes the best-fit perspective transformation mapping srcPoints to dstPoints.
        /// </summary>
        /// <param name="srcPoints">Coordinates of the points in the original plane</param>
        /// <param name="dstPoints">Coordinates of the points in the target plane</param>
        /// <param name="method">Method used to computed a homography matrix.</param>
        /// <param name="ransacReprojThreshold">Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only)</param>
        /// <param name="mask"> Optional output mask set by a robust method ( CV_RANSAC or CV_LMEDS ). Note that the input mask values are ignored.</param>
        /// <returns></returns>
        public static Mat FindHomography(IEnumerable<Point2d> srcPoints, IEnumerable<Point2d> dstPoints,
            HomographyMethod method = HomographyMethod.Zero, double ransacReprojThreshold = 3,
            OutputArray mask = null)
        {
            if (srcPoints == null)
                throw new ArgumentNullException("srcPoints");
            if (dstPoints == null)
                throw new ArgumentNullException("dstPoints");

            Point2d[] srcPointsArray = EnumerableEx.ToArray(srcPoints);
            Point2d[] dstPointsArray = EnumerableEx.ToArray(dstPoints);

            IntPtr mat = NativeMethods.calib3d_findHomography_vector(srcPointsArray, srcPointsArray.Length,
                dstPointsArray, dstPointsArray.Length, (int)method, ransacReprojThreshold, ToPtr(mask));

            if (mask != null)
                mask.Fix();
            return new Mat(mat);
        }
コード例 #2
0
ファイル: Cv2_calib3d.cs プロジェクト: kaorun55/opencvsharp
        /// <summary>
        /// computes the best-fit perspective transformation mapping srcPoints to dstPoints.
        /// </summary>
        /// <param name="srcPoints">Coordinates of the points in the original plane, a matrix of the type CV_32FC2</param>
        /// <param name="dstPoints">Coordinates of the points in the target plane, a matrix of the type CV_32FC2</param>
        /// <param name="method">Method used to computed a homography matrix.</param>
        /// <param name="ransacReprojThreshold">Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only)</param>
        /// <param name="mask"> Optional output mask set by a robust method ( CV_RANSAC or CV_LMEDS ). Note that the input mask values are ignored.</param>
        /// <returns></returns>
        public static Mat FindHomography(InputArray srcPoints, InputArray dstPoints,
            HomographyMethod method = HomographyMethod.Zero, double ransacReprojThreshold = 3,
            OutputArray mask = null)
        {
            if (srcPoints == null)
                throw new ArgumentNullException("srcPoints");
            if (dstPoints == null)
                throw new ArgumentNullException("dstPoints");
            srcPoints.ThrowIfDisposed();
            dstPoints.ThrowIfDisposed();

            IntPtr mat = NativeMethods.calib3d_findHomography_InputArray(srcPoints.CvPtr, dstPoints.CvPtr, (int)method,
                ransacReprojThreshold, ToPtr(mask));

            if (mask != null)
                mask.Fix();
            return new Mat(mat);
        }
コード例 #3
0
ファイル: Cv_F.cs プロジェクト: jorik041/opencvsharp
        /// <summary>
        /// 2枚の画像間の射影変換を求める
        /// </summary>
        /// <param name="srcPoints">1枚目の画像上の座標. 2xN,Nx2,3xN または Nx3の配列 (後ろ二つは同次座標系表記である).ここで N は点の数.</param>
        /// <param name="dstPoints">2枚目の画像上の座標. 2xN,Nx2,3xN または Nx3の配列 (後ろ二つは同次座標系表記である).</param>
        /// <param name="homography">出力される3x3ホモグラフィ行列(平面射影変換行列). </param>
        /// <param name="method">ホモグラフィ行列を計算するための手法</param>
        /// <param name="ransacReprojThreshold">点のペアをインライア値として扱うために許容される,逆投影誤差の最大値.このパラメータは,CV_RANSAC が指定された場合にのみ利用される.例えば,dst_points がピクセル精度のピクセル座標である場合,このパラメータは,おおよそ 1〜3 にセットされるのが正しい. </param>
        /// <returns></returns>
#else
        /// <summary>
        /// Finds perspective transformation between two planes
        /// </summary>
        /// <param name="srcPoints">Point coordinates in the original plane, 2xN, Nx2, 3xN or Nx3 array (the latter two are for representation in homogenious coordinates), where N is the number of points. </param>
        /// <param name="dstPoints">Point coordinates in the destination plane, 2xN, Nx2, 3xN or Nx3 array (the latter two are for representation in homogenious coordinates) </param>
        /// <param name="homography">Output 3x3 homography matrix. </param>
        /// <param name="method"></param>
        /// <param name="ransacReprojThreshold"></param>
        /// <returns></returns>
#endif
        public static int FindHomography(CvMat srcPoints, CvMat dstPoints, CvMat homography, HomographyMethod method, double ransacReprojThreshold)
        {
            return FindHomography(srcPoints, dstPoints, homography, method, ransacReprojThreshold, null);
        }
コード例 #4
0
ファイル: Cv_F.cs プロジェクト: jorik041/opencvsharp
        /// <summary>
        /// 2枚の画像間の射影変換を求める
        /// </summary>
        /// <param name="srcPoints">1枚目の画像上の座標. 2xN,Nx2,3xN または Nx3の配列 (後ろ二つは同次座標系表記である).ここで N は点の数.</param>
        /// <param name="dstPoints">2枚目の画像上の座標. 2xN,Nx2,3xN または Nx3の配列 (後ろ二つは同次座標系表記である).</param>
        /// <param name="homography">出力される3x3ホモグラフィ行列(平面射影変換行列). </param>
        /// <param name="method">ホモグラフィ行列を計算するための手法</param>
        /// <param name="ransacReprojThreshold">点のペアをインライア値として扱うために許容される,逆投影誤差の最大値.このパラメータは,CV_RANSAC が指定された場合にのみ利用される.例えば,dst_points がピクセル精度のピクセル座標である場合,このパラメータは,おおよそ 1〜3 にセットされるのが正しい. </param>
        /// <param name="mask">オプション:ロバスト推定(CV_RANSAC, CV_LMEDS)で利用される出力マスク. </param>
        /// <returns></returns>
#else
        /// <summary>
        /// Finds perspective transformation between two planes
        /// </summary>
        /// <param name="srcPoints">Point coordinates in the original plane, 2xN, Nx2, 3xN or Nx3 array (the latter two are for representation in homogenious coordinates), where N is the number of points. </param>
        /// <param name="dstPoints">Point coordinates in the destination plane, 2xN, Nx2, 3xN or Nx3 array (the latter two are for representation in homogenious coordinates) </param>
        /// <param name="homography">Output 3x3 homography matrix. </param>
        /// <param name="method"></param>
        /// <param name="ransacReprojThreshold"></param>
        /// <param name="mask"></param>
        /// <returns></returns>
#endif
        public static int FindHomography(CvMat srcPoints, CvMat dstPoints, CvMat homography, HomographyMethod method, double ransacReprojThreshold, CvMat mask)
        {
            if (srcPoints == null)
                throw new ArgumentNullException("srcPoints");
            if (dstPoints == null)
                throw new ArgumentNullException("dstPoints");
            if (homography == null)
                throw new ArgumentNullException("homography");
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;
            return NativeMethods.cvFindHomography(srcPoints.CvPtr, dstPoints.CvPtr, homography.CvPtr, method, ransacReprojThreshold, maskPtr);
        }
コード例 #5
0
ファイル: Cv_F.cs プロジェクト: jorik041/opencvsharp
        /// <summary>
        /// 2枚の画像間の射影変換を求める
        /// </summary>
        /// <param name="srcPoints">1枚目の画像上の座標. 2xN,Nx2,3xN または Nx3の配列 (後ろ二つは同次座標系表記である).ここで N は点の数.</param>
        /// <param name="dstPoints">2枚目の画像上の座標. 2xN,Nx2,3xN または Nx3の配列 (後ろ二つは同次座標系表記である).</param>
        /// <param name="homography">出力される3x3ホモグラフィ行列(平面射影変換行列). </param>
        /// <param name="method">ホモグラフィ行列を計算するための手法</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Finds perspective transformation between two planes
        /// </summary>
        /// <param name="srcPoints">Point coordinates in the original plane, 2xN, Nx2, 3xN or Nx3 array (the latter two are for representation in homogenious coordinates), where N is the number of points. </param>
        /// <param name="dstPoints">Point coordinates in the destination plane, 2xN, Nx2, 3xN or Nx3 array (the latter two are for representation in homogenious coordinates) </param>
        /// <param name="homography">Output 3x3 homography matrix. </param>
        /// <param name="method"></param>
        /// <returns></returns>
#endif
        public static int FindHomography(CvMat srcPoints, CvMat dstPoints, CvMat homography, HomographyMethod method)
        {
            return FindHomography(srcPoints, dstPoints, homography, method, 0, null);
        }