當前位置: 首頁>>代碼示例>>C#>>正文


C# Mat.ToCvMat方法代碼示例

本文整理匯總了C#中OpenCvSharp.CPlusPlus.Mat.ToCvMat方法的典型用法代碼示例。如果您正苦於以下問題:C# Mat.ToCvMat方法的具體用法?C# Mat.ToCvMat怎麽用?C# Mat.ToCvMat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenCvSharp.CPlusPlus.Mat的用法示例。


在下文中一共展示了Mat.ToCvMat方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Extract

        /// <summary>
        /// 高速なマルチスケール Hesian 検出器を用いて keypoint を検出します.
        /// </summary>
        /// <param name="img"></param>
        /// <param name="mask"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// detects keypoints using fast multi-scale Hessian detector
        /// </summary>
        /// <param name="img"></param>
        /// <param name="mask"></param>
        /// <returns></returns>
#endif
        public KeyPoint[] Extract(Mat img, Mat mask)
        {
            if (img == null)
                throw new ArgumentNullException("img");

            CvMat imgMat = img.ToCvMat();
            CvMat maskMat = (mask == null) ? null : mask.ToCvMat();

            CvSURFPoint[] keypoints;
            float[][] descriptors;
            Cv.ExtractSURF(imgMat, maskMat, out keypoints, out descriptors, this);

            KeyPoint[] result = new KeyPoint[keypoints.Length];
            for (int i = 0; i < result.Length; i++)
            {
                CvSURFPoint kpt = keypoints[i];
                result[i] = new KeyPoint(kpt.Pt, (float) kpt.Size, kpt.Dir, kpt.Hessian, GetPointOctave(kpt, this));
            }
            return result;
        }
開發者ID:neoxeo,項目名稱:opencvsharp,代碼行數:34,代碼來源:SURF.cs

示例2: Transform

        private void Transform(double[] srcPoints)
        {
            const int POINT_COUNT = 8;
            System.Diagnostics.Debug.Assert(srcPoints.Length == POINT_COUNT);
            double leftOffset = (srcGrid.Width - imgRaw.Source.Width) / 2;
            double topOffset = (srcGrid.Height - imgRaw.Source.Height) / 2;

            CvMat srcPointsMat = new CvMat(4, 2, MatrixType.F64C1, srcPoints);
            CvMat dstPointsMat = new CvMat(4, 2, MatrixType.F64C1,
                new double[POINT_COUNT] {
                    dstGrid.Width * 1 / 4, dstGrid.Height * 1 / 4, dstGrid.Width * 3 / 4, dstGrid.Height * 1 / 4,
                    dstGrid.Width * 3 / 4, dstGrid.Height * 3 / 4, dstGrid.Width * 1 / 4, dstGrid.Height * 3 / 4 });
            CvMat viewerHomographyMatrix = new CvMat(3, 3, MatrixType.F64C1, new double[9]);
            Cv.FindHomography(srcPointsMat, dstPointsMat, viewerHomographyMatrix);

            CV.Mat src = WriteableBitmapConverter.ToMat((WriteableBitmap)imgRaw.Source);
            CV.Mat dst = new CV.Mat((int)srcGrid.Height, (int)srcGrid.Width, src.Type());
            Cv.WarpPerspective(src.ToCvMat(), dst.ToCvMat(), viewerHomographyMatrix);
            imgTransformed.Source = WriteableBitmapConverter.ToWriteableBitmap(dst);

            srcPointsMat.Dispose();
            dstPointsMat.Dispose();
            src.Dispose();
            dst.Dispose();
        }
開發者ID:cryspharos,項目名稱:HomographyMatrix,代碼行數:25,代碼來源:MainWindow.xaml.cs

示例3: Extract

        /// <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 CvPoint[][] Extract(Mat image, Mat mask)
        {
            if(image == null)
                throw new ArgumentNullException("image");

            CvMat _image = image.ToCvMat();
            IntPtr pmask = (mask == null) ? IntPtr.Zero : mask.ToCvMat().CvPtr;
            IntPtr pcontours = IntPtr.Zero;

            using(CvMemStorage storage = new CvMemStorage(0))
	        {
        	    CvInvoke.cvExtractMSER(_image.CvPtr, pmask, ref pcontours, storage.CvPtr, Struct);
                if (pcontours == IntPtr.Zero)
                {
                    return new CvPoint[0][];
                }
                CvSeq<IntPtr> seq = new CvSeq<IntPtr>(pcontours);
                CvContour[] contours = Array.ConvertAll<IntPtr, CvContour>(seq.ToArray(), delegate(IntPtr p) { return new CvContour(p); });
                CvPoint[][] result = new CvPoint[contours.Length][];
                for (int i = 0; i < contours.Length; i++)
                {
                    result[i] = contours[i].ToArray();
                }
                return result;
	        }
        }
開發者ID:neoxeo,項目名稱:opencvsharp,代碼行數:40,代碼來源:MSER.cs


注:本文中的OpenCvSharp.CPlusPlus.Mat.ToCvMat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。