示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="img"></param>
        /// <param name="templ"></param>
        /// <param name="results"></param>
        /// <param name="cost"></param>
        /// <param name="templScale"></param>
        /// <param name="maxMatches"></param>
        /// <param name="minMatchDistance"></param>
        /// <param name="padX"></param>
        /// <param name="padY"></param>
        /// <param name="scales"></param>
        /// <param name="minScale"></param>
        /// <param name="maxScale"></param>
        /// <param name="orientationWeight"></param>
        /// <param name="truncate"></param>
        /// <returns></returns>
        public static int ChamferMatching(
            Mat img, Mat templ,
            out Point[][] results, out float[] cost,
            double templScale       = 1, int maxMatches = 20,
            double minMatchDistance = 1.0, int padX     = 3,
            int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
            double orientationWeight = 0.5, double truncate = 20)
        {
            if (img == null)
            {
                throw new ArgumentNullException(nameof(img));
            }
            if (templ == null)
            {
                throw new ArgumentNullException(nameof(templ));
            }
            img.ThrowIfDisposed();
            templ.ThrowIfDisposed();

            using (var resultsVec = new VectorOfVectorPoint())
                using (var costVec = new VectorOfFloat())
                {
                    int ret = NativeMethods.contrib_chamerMatching(
                        img.CvPtr, templ.CvPtr, resultsVec.CvPtr, costVec.CvPtr,
                        templScale, maxMatches, minMatchDistance,
                        padX, padY, scales, minScale, maxScale, orientationWeight, truncate);
                    GC.KeepAlive(img);
                    GC.KeepAlive(templ);

                    results = resultsVec.ToArray();
                    cost    = costVec.ToArray();

                    return(ret);
                }
        }
示例#2
0
        /// <summary>
        /// MSERのすべての輪郭情報を抽出する
        /// </summary>
        /// <param name="image"></param>
        /// <param name="mask"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// Extracts the contours of Maximally Stable Extremal Regions
        /// </summary>
        /// <param name="image"></param>
        /// <param name="mask"></param>
        /// <returns></returns>
#endif
        public Point[][] Run(Mat image, Mat mask)
        {
            ThrowIfDisposed();
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }
            image.ThrowIfDisposed();

            IntPtr msers;

            NativeMethods.features2d_MSER_detect(ptr, image.CvPtr, out msers, Cv2.ToPtr(mask));

            using (VectorOfVectorPoint msersVec = new VectorOfVectorPoint(msers))
            {
                return(msersVec.ToArray());
            }
        }