当前位置: 首页>>代码示例>>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;未经允许,请勿转载。