当前位置: 首页>>代码示例>>C#>>正文


C# Point.GetValueOrDefault方法代码示例

本文整理汇总了C#中System.Point.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Point.GetValueOrDefault方法的具体用法?C# Point.GetValueOrDefault怎么用?C# Point.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Point的用法示例。


在下文中一共展示了Point.GetValueOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindContoursAsMat

        /// <summary>
        /// 2値画像中の輪郭を検出します.
        /// </summary>
        /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます.
        /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param>
        /// <param name="mode">輪郭抽出モード</param>
        /// <param name="method">輪郭の近似手法</param>
        /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param>
        /// <return>検出された輪郭.各輪郭は,点のベクトルとして格納されます.</return>
#else
        /// <summary>
        /// Finds contours in a binary image.
        /// </summary>
        /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. 
        /// Zero pixels remain 0’s, so the image is treated as binary.
        /// The function modifies the image while extracting the contours.</param> 
        /// <param name="mode">Contour retrieval mode</param>
        /// <param name="method">Contour approximation method</param>
        /// <param name="offset"> Optional offset by which every contour point is shifted. 
        /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param>
        /// <returns>Detected contours. Each contour is stored as a vector of points.</returns>
#endif
        public static MatOfPoint[] FindContoursAsMat(InputOutputArray image, 
            ContourRetrieval mode, ContourChain method, Point? offset = null)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            image.ThrowIfNotReady();

            CvPoint offset0 = offset.GetValueOrDefault(new Point());
            IntPtr contoursPtr;
            NativeMethods.imgproc_findContours2_OutputArray(image.CvPtr, out contoursPtr, (int)mode, (int)method, offset0);
            image.Fix();

            using (var contoursVec = new VectorOfMat(contoursPtr))
            {
                return contoursVec.ToArray<MatOfPoint>();
            }
        }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:39,代码来源:Cv2_imgproc.cs

示例2: FindContours

        /// <summary>
        /// 2値画像中の輪郭を検出します.
        /// </summary>
        /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます.
        /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param>
        /// <param name="contours">検出された輪郭.各輪郭は,点のベクトルとして格納されます.</param>
        /// <param name="hierarchy">画像のトポロジーに関する情報を含む出力ベクトル.これは,輪郭数と同じ数の要素を持ちます.各輪郭 contours[i] に対して,
        /// 要素 hierarchy[i]のメンバにはそれぞれ,同じ階層レベルに存在する前後の輪郭,最初の子輪郭,および親輪郭の 
        /// contours インデックス(0 基準)がセットされます.また,輪郭 i において,前後,親,子の輪郭が存在しない場合,
        /// それに対応する hierarchy[i] の要素は,負の値になります.</param>
        /// <param name="mode">輪郭抽出モード</param>
        /// <param name="method">輪郭の近似手法</param>
        /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param>
#else
        /// <summary>
        /// Finds contours in a binary image.
        /// </summary>
        /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. 
        /// Zero pixels remain 0’s, so the image is treated as binary.
        /// The function modifies the image while extracting the contours.</param> 
        /// <param name="contours">Detected contours. Each contour is stored as a vector of points.</param>
        /// <param name="hierarchy">Optional output vector, containing information about the image topology. 
        /// It has as many elements as the number of contours. For each i-th contour contours[i], 
        /// the members of the elements hierarchy[i] are set to 0-based indices in contours of the next 
        /// and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. 
        /// If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.</param>
        /// <param name="mode">Contour retrieval mode</param>
        /// <param name="method">Contour approximation method</param>
        /// <param name="offset"> Optional offset by which every contour point is shifted. 
        /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param>
#endif
        public static void FindContours(InputOutputArray image, out Point[][] contours,
            out HierarchyIndex[] hierarchy, ContourRetrieval mode, ContourChain method, Point? offset = null)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            image.ThrowIfNotReady();

            CvPoint offset0 = offset.GetValueOrDefault(new Point());
            IntPtr contoursPtr, hierarchyPtr;
            NativeMethods.imgproc_findContours1_vector(image.CvPtr, out contoursPtr, out hierarchyPtr, (int)mode, (int)method, offset0);

            using (var contoursVec = new VectorOfVectorPoint(contoursPtr))
            using (var hierarchyVec = new VectorOfVec4i(hierarchyPtr))
            {
                contours = contoursVec.ToArray();
                Vec4i[] hierarchyOrg = hierarchyVec.ToArray();
                hierarchy = EnumerableEx.SelectToArray(hierarchyOrg, HierarchyIndex.FromVec4i);
            }
            image.Fix();
        }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:51,代码来源:Cv2_imgproc.cs

示例3: Dilate

        /// <summary>
        /// Dilates an image by using a specific structuring element.
        /// </summary>
        /// <param name="src">Source image. Only CV_8UC1 and CV_8UC4 types are supported.</param>
        /// <param name="dst">Destination image with the same size and type as src.</param>
        /// <param name="kernel">Structuring element used for erosion. If kernel=Mat(), 
        /// a 3x3 rectangular structuring element is used.</param>
        /// <param name="anchor">Position of an anchor within the element. 
        /// The default value (-1, -1) means that the anchor is at the element center.</param>
        /// <param name="iterations">Number of times erosion to be applied.</param>
        public static void Dilate(
            GpuMat src, GpuMat dst, Mat kernel, Point? anchor = null, int iterations = 1)
        {
            ThrowIfGpuNotAvailable();
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (kernel == null)
                throw new ArgumentNullException("kernel");
            src.ThrowIfDisposed();
            dst.ThrowIfDisposed();
            kernel.ThrowIfDisposed();

            Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
            NativeMethods.gpu_dilate1(src.CvPtr, dst.CvPtr, kernel.CvPtr, anchor0, iterations);
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:27,代码来源:Cv2_gpu.cs

示例4: Blur

 /// <summary>
 /// Smoothes image using normalized box filter
 /// </summary>
 /// <param name="src">The source image</param>
 /// <param name="dst">The destination image; will have the same size and the same type as src</param>
 /// <param name="ksize">The smoothing kernel size</param>
 /// <param name="anchor">The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center</param>
 /// <param name="borderType">The border mode used to extrapolate pixels outside of the image</param>
 public static void Blur(InputArray src, OutputArray dst, Size ksize, 
     Point? anchor = null, BorderType borderType = BorderType.Default)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
     NativeMethods.imgproc_blur(src.CvPtr, dst.CvPtr, ksize, anchor0, (int)borderType);
     dst.Fix();
 }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:21,代码来源:Cv2_imgproc.cs

示例5: SepFilter2D

 /// <summary>
 /// Applies separable linear filter to an image
 /// </summary>
 /// <param name="src">The source image</param>
 /// <param name="dst">The destination image; will have the same size and the same number of channels as src</param>
 /// <param name="ddepth">The destination image depth</param>
 /// <param name="kernelX">The coefficients for filtering each row</param>
 /// <param name="kernelY">The coefficients for filtering each column</param>
 /// <param name="anchor">The anchor position within the kernel; The default value (-1, 1) means that the anchor is at the kernel center</param>
 /// <param name="delta">The value added to the filtered results before storing them</param>
 /// <param name="borderType">The pixel extrapolation method</param>
 public static void SepFilter2D(InputArray src, OutputArray dst, MatType ddepth, InputArray kernelX, InputArray kernelY,
     Point? anchor = null, double delta = 0, BorderType borderType = BorderType.Default)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     if (kernelX == null)
         throw new ArgumentNullException("kernelX");
     if (kernelY == null)
         throw new ArgumentNullException("kernelY");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     kernelX.ThrowIfDisposed();
     kernelY.ThrowIfDisposed();
     Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
     NativeMethods.imgproc_sepFilter2D(src.CvPtr, dst.CvPtr, ddepth, 
         kernelX.CvPtr, kernelY.CvPtr, anchor0, delta, (int)borderType);
     dst.Fix();
 }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:31,代码来源:Cv2_imgproc.cs

示例6: SetTemplate

        /// <summary>
        /// set template to search
        /// </summary>
        /// <param name="templ"></param>
        /// <param name="templCenter"></param>
        public void SetTemplate(InputArray templ, Point? templCenter = null)
        {
            if (ptr == IntPtr.Zero)
                throw new ObjectDisposedException(GetType().Name);
            if (templ == null)
                throw new ArgumentNullException(nameof(templ));
            templ.ThrowIfDisposed();
            var templCenterValue = templCenter.GetValueOrDefault(new Point(-1, -1));

            NativeMethods.imgproc_GeneralizedHough_setTemplate1(ptr, templ.CvPtr, templCenterValue);

            GC.KeepAlive(templ);
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:18,代码来源:GeneralizedHough.cs

示例7: FindContoursAsArray

        /// <summary>
        /// 2値画像中の輪郭を検出します.
        /// </summary>
        /// <param name="image">入力画像,8ビット,シングルチャンネル.0以外のピクセルは 1として,0のピクセルは0のまま扱われます.
        /// また,この関数は,輪郭抽出処理中に入力画像 image の中身を書き換えます.</param>
        /// <param name="mode">輪郭抽出モード</param>
        /// <param name="method">輪郭の近似手法</param>
        /// <param name="offset">オプションのオフセット.各輪郭点はこの値の分だけシフトします.これは,ROIの中で抽出された輪郭を,画像全体に対して位置づけて解析する場合に役立ちます.</param>
        /// <return>検出された輪郭.各輪郭は,点のベクトルとして格納されます.</return>
#else
        /// <summary>
        /// Finds contours in a binary image.
        /// </summary>
        /// <param name="image">Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. 
        /// Zero pixels remain 0’s, so the image is treated as binary.
        /// The function modifies the image while extracting the contours.</param> 
        /// <param name="mode">Contour retrieval mode</param>
        /// <param name="method">Contour approximation method</param>
        /// <param name="offset"> Optional offset by which every contour point is shifted. 
        /// This is useful if the contours are extracted from the image ROI and then they should be analyzed in the whole image context.</param>
        /// <returns>Detected contours. Each contour is stored as a vector of points.</returns>
#endif
        public static Point[][] FindContoursAsArray(InputOutputArray image,
            RetrievalModes mode, ContourApproximationModes method, Point? offset = null)
        {
            if (image == null)
                throw new ArgumentNullException(nameof(image));
            image.ThrowIfNotReady();

            Point offset0 = offset.GetValueOrDefault(new Point());
            IntPtr contoursPtr;
            NativeMethods.imgproc_findContours2_vector(image.CvPtr, out contoursPtr, (int)mode, (int)method, offset0);
            image.Fix();

            using (var contoursVec = new VectorOfVectorPoint(contoursPtr))
            {
                return contoursVec.ToArray();
            }
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:39,代码来源:Cv2_imgproc.cs

示例8: Filter2D

        /// <summary>
        /// Convolves an image with the kernel
        /// </summary>
        /// <param name="src">The source image</param>
        /// <param name="dst">The destination image. It will have the same size and the same number of channels as src</param>
        /// <param name="ddepth">The desired depth of the destination image. If it is negative, it will be the same as src.depth()</param>
        /// <param name="kernel">Convolution kernel (or rather a correlation kernel), 
        /// a single-channel floating point matrix. If you want to apply different kernels to 
        /// different channels, split the image into separate color planes using split() and process them individually</param>
        /// <param name="anchor">The anchor of the kernel that indicates the relative position of 
        /// a filtered point within the kernel. The anchor should lie within the kernel. 
        /// The special default value (-1,-1) means that the anchor is at the kernel center</param>
        /// <param name="delta">The optional value added to the filtered pixels before storing them in dst</param>
        /// <param name="borderType">The pixel extrapolation method</param>
        public static void Filter2D(
            InputArray src, OutputArray dst, MatType ddepth,
	        InputArray kernel, Point? anchor = null, double delta = 0, 
            BorderTypes borderType = BorderTypes.Default)
        {
            if (src == null)
                throw new ArgumentNullException(nameof(src));
            if (dst == null)
                throw new ArgumentNullException(nameof(dst));
            if (kernel == null)
                throw new ArgumentNullException(nameof(kernel));
            src.ThrowIfDisposed();
            dst.ThrowIfNotReady();
            kernel.ThrowIfDisposed();
            Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
            NativeMethods.imgproc_filter2D(src.CvPtr, dst.CvPtr, ddepth, kernel.CvPtr, 
                anchor0, delta, (int)borderType);
            GC.KeepAlive(src);
            dst.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:34,代码来源:Cv2_imgproc.cs

示例9: SepFilter2D

        /// <summary>
        /// Applies a separable 2D linear filter to an image.
        /// </summary>
        /// <param name="src">Source image. 
        /// CV_8UC1, CV_8UC4, CV_16SC1, CV_16SC2, CV_32SC1, CV_32FC1 source types are supported.</param>
        /// <param name="dst">Destination image with the same size and number of channels as src.</param>
        /// <param name="ddepth">Destination image depth. CV_8U, CV_16S, CV_32S, and CV_32F are supported.</param>
        /// <param name="kernelX">Horizontal filter coefficients.</param>
        /// <param name="kernelY">Vertical filter coefficients.</param>
        /// <param name="buf"></param>
        /// <param name="anchor">Anchor position within the kernel. 
        /// The default value (-1, 1) means that the anchor is at the kernel center.</param>
        /// <param name="rowBorderType">Pixel extrapolation method in the vertical direction.</param>
        /// <param name="columnBorderType">Pixel extrapolation method in the horizontal direction.</param>
        /// <param name="stream">Stream for the asynchronous version.</param>
        public static void SepFilter2D(
            GpuMat src, GpuMat dst, int ddepth, Mat kernelX, Mat kernelY, GpuMat buf,
            Point? anchor = null, BorderType rowBorderType = BorderType.Default, 
            BorderType columnBorderType = BorderType.Auto, Stream stream = null)
        {
            ThrowIfGpuNotAvailable();
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (kernelX == null)
                throw new ArgumentNullException("kernelX");
            if (kernelY == null)
                throw new ArgumentNullException("kernelY");
            if (buf == null)
                throw new ArgumentNullException("buf");
            src.ThrowIfDisposed();
            dst.ThrowIfDisposed();
            kernelX.ThrowIfDisposed();
            kernelY.ThrowIfDisposed();
            buf.ThrowIfDisposed();

            Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
            NativeMethods.gpu_sepFilter2D2(
                src.CvPtr, dst.CvPtr, ddepth, kernelX.CvPtr, kernelY.CvPtr, buf.CvPtr, 
                anchor0, (int)rowBorderType, (int)columnBorderType, Cv2.ToPtr(stream));
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:42,代码来源:Cv2_gpu.cs

示例10: AdaptiveBilateralFilter

 /*
 /// <summary>
 /// Applies the adaptive bilateral filter to an image.
 /// </summary>
 /// <param name="src">The source image</param>
 /// <param name="dst">The destination image; will have the same size and the same type as src</param>
 /// <param name="ksize">The kernel size. This is the neighborhood where the local variance will be calculated, 
 /// and where pixels will contribute (in a weighted manner).</param>
 /// <param name="sigmaSpace">Filter sigma in the coordinate space. 
 /// Larger value of the parameter means that farther pixels will influence each other 
 /// (as long as their colors are close enough; see sigmaColor). Then d>0, it specifies the neighborhood 
 /// size regardless of sigmaSpace, otherwise d is proportional to sigmaSpace.</param>
 /// <param name="maxSigmaColor">Maximum allowed sigma color (will clamp the value calculated in the 
 /// ksize neighborhood. Larger value of the parameter means that more dissimilar pixels will 
 /// influence each other (as long as their colors are close enough; see sigmaColor). 
 /// Then d>0, it specifies the neighborhood size regardless of sigmaSpace, otherwise d is proportional to sigmaSpace.</param>
 /// <param name="anchor">The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center</param>
 /// <param name="borderType">Pixel extrapolation method.</param>
 public static void AdaptiveBilateralFilter(InputArray src, OutputArray dst, Size ksize,
     double sigmaSpace, double maxSigmaColor = 20.0, Point? anchor = null, BorderType borderType = BorderType.Default)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
     NativeMethods.imgproc_adaptiveBilateralFilter(src.CvPtr, dst.CvPtr, ksize, 
         sigmaSpace, maxSigmaColor, anchor0, (int)borderType);
     dst.Fix();
 }
 */
 #endregion
 #region BoxFilter
 /// <summary>
 /// Smoothes image using box filter
 /// </summary>
 /// <param name="src">The source image</param>
 /// <param name="dst">The destination image; will have the same size and the same type as src</param>
 /// <param name="ddepth"></param>
 /// <param name="ksize">The smoothing kernel size</param>
 /// <param name="anchor">The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center</param>
 /// <param name="normalize">Indicates, whether the kernel is normalized by its area or not</param>
 /// <param name="borderType">The border mode used to extrapolate pixels outside of the image</param>
 public static void BoxFilter(
     InputArray src, OutputArray dst, MatType ddepth, 
     Size ksize, Point? anchor = null, bool normalize = true,
     BorderTypes borderType = BorderTypes.Default)
 {
     if (src == null)
         throw new ArgumentNullException(nameof(src));
     if (dst == null)
         throw new ArgumentNullException(nameof(dst));
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
     NativeMethods.imgproc_boxFilter(src.CvPtr, dst.CvPtr, ddepth, ksize, anchor0, normalize ? 1 : 0, (int)borderType);
     GC.KeepAlive(src);
     dst.Fix();
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:61,代码来源:Cv2_imgproc.cs

示例11: Filter2D

        /// <summary>
        /// Applies the non-separable 2D linear filter to an image.
        /// </summary>
        /// <param name="src">Source image. Supports CV_8U, CV_16U and CV_32F one and four channel image.</param>
        /// <param name="dst">Destination image. The size and the number of channels is the same as src.</param>
        /// <param name="ddepth">Desired depth of the destination image. If it is negative, it is the same as src.depth(). 
        /// It supports only the same depth as the source image depth.</param>
        /// <param name="kernel">2D array of filter coefficients.</param>
        /// <param name="anchor">Anchor of the kernel that indicates the relative position of 
        /// a filtered point within the kernel. The anchor resides within the kernel. 
        /// The special default value (-1,-1) means that the anchor is at the kernel center.</param>
        /// <param name="borderType">Pixel extrapolation method.</param>
        /// <param name="stream">Stream for the asynchronous version.</param>
        public static void Filter2D(
            GpuMat src, GpuMat dst, int ddepth, Mat kernel, Point? anchor,
            BorderType borderType = BorderType.Default, Stream stream = null)
        {
            ThrowIfGpuNotAvailable();
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (kernel == null)
                throw new ArgumentNullException("kernel");
            src.ThrowIfDisposed();
            dst.ThrowIfDisposed();
            kernel.ThrowIfDisposed();

            Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
            NativeMethods.gpu_filter2D(src.CvPtr, dst.CvPtr, ddepth, kernel.CvPtr,
                anchor0, (int)borderType, Cv2.ToPtr(stream));
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:32,代码来源:Cv2_gpu.cs

示例12: MorphologyEx

        /// <summary>
        /// Applies an advanced morphological operation to an image.
        /// </summary>
        /// <param name="src">Source image. CV_8UC1 and CV_8UC4 source types are supported.</param>
        /// <param name="dst">Destination image with the same size and type as src.</param>
        /// <param name="op">Type of morphological operation</param>
        /// <param name="kernel">Structuring element.</param>
        /// <param name="buf1"></param>
        /// <param name="buf2"></param>
        /// <param name="anchor">Position of an anchor within the element. 
        /// The default value Point(-1, -1) means that the anchor is at the element center.</param>
        /// <param name="iterations">Number of times erosion and dilation to be applied.</param>
        /// <param name="stream">Stream for the asynchronous version.</param>
        public static void MorphologyEx(
            GpuMat src, GpuMat dst, MorphologyOperation op, Mat kernel, GpuMat buf1, GpuMat buf2,
            Point? anchor = null, int iterations = 1, Stream stream = null)
        {
            ThrowIfGpuNotAvailable();
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (kernel == null)
                throw new ArgumentNullException("kernel");
            if (buf1 == null)
                throw new ArgumentNullException("buf1");
            if (buf2 == null)
                throw new ArgumentNullException("buf2");
            src.ThrowIfDisposed();
            dst.ThrowIfDisposed();
            kernel.ThrowIfDisposed();
            buf1.ThrowIfDisposed();
            buf2.ThrowIfDisposed();

            Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
            NativeMethods.gpu_morphologyEx2(src.CvPtr, dst.CvPtr, (int)op, kernel.CvPtr,
                buf1.CvPtr, buf2.CvPtr, anchor0, iterations, Cv2.ToPtr(stream));
        }
开发者ID:0sv,项目名称:opencvsharp,代码行数:38,代码来源:Cv2_gpu.cs

示例13: DrawContours

        /// <summary>
        /// 輪郭線,または内側が塗りつぶされた輪郭を描きます.
        /// </summary>
        /// <param name="image">出力画像</param>
        /// <param name="contours"> 入力される全輪郭.各輪郭は,点のベクトルとして格納されています.</param>
        /// <param name="contourIdx">描かれる輪郭を示します.これが負値の場合,すべての輪郭が描画されます.</param>
        /// <param name="color">輪郭の色.</param>
        /// <param name="thickness">輪郭線の太さ.これが負値の場合(例えば thickness=CV_FILLED ),輪郭の内側が塗りつぶされます.</param>
        /// <param name="lineType">線の連結性</param>
        /// <param name="hierarchy">階層に関するオプションの情報.これは,特定の輪郭だけを描画したい場合にのみ必要になります.</param>
        /// <param name="maxLevel">描画される輪郭の最大レベル.0ならば,指定された輪郭のみが描画されます.
        /// 1ならば,指定された輪郭と,それに入れ子になったすべての輪郭が描画されます.2ならば,指定された輪郭と,
        /// それに入れ子になったすべての輪郭,さらにそれに入れ子になったすべての輪郭が描画されます.このパラメータは, 
        /// hierarchy が有効な場合のみ考慮されます.</param>
        /// <param name="offset">輪郭をシフトするオプションパラメータ.指定された offset = (dx,dy) だけ,すべての描画輪郭がシフトされます.</param>
#else
        /// <summary>
        /// draws contours in the image
        /// </summary>
        /// <param name="image">Destination image.</param>
        /// <param name="contours">All the input contours. Each contour is stored as a point vector.</param>
        /// <param name="contourIdx">Parameter indicating a contour to draw. If it is negative, all the contours are drawn.</param>
        /// <param name="color">Color of the contours.</param>
        /// <param name="thickness">Thickness of lines the contours are drawn with. If it is negative (for example, thickness=CV_FILLED ), 
        /// the contour interiors are drawn.</param>
        /// <param name="lineType">Line connectivity. </param>
        /// <param name="hierarchy">Optional information about hierarchy. It is only needed if you want to draw only some of the contours</param>
        /// <param name="maxLevel">Maximal level for drawn contours. If it is 0, only the specified contour is drawn. 
        /// If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function draws the contours, 
        /// all the nested contours, all the nested-to-nested contours, and so on. This parameter is only taken into account 
        /// when there is hierarchy available.</param>
        /// <param name="offset">Optional contour shift parameter. Shift all the drawn contours by the specified offset = (dx, dy)</param>
#endif
        public static void DrawContours(
            InputOutputArray image,
            IEnumerable<IEnumerable<Point>> contours,
            int contourIdx,
            Scalar color,
            int thickness = 1,
            LineType lineType = LineType.Link8,
            IEnumerable<HierarchyIndex> hierarchy = null,
            int maxLevel = Int32.MaxValue,
            Point? offset = null)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            if (contours == null)
                throw new ArgumentNullException("contours");
            image.ThrowIfNotReady();

            CvPoint offset0 = offset.GetValueOrDefault(new Point());
            Point[][] contoursArray = EnumerableEx.SelectToArray(contours, EnumerableEx.ToArray);
            int[] contourSize2 = EnumerableEx.SelectToArray(contoursArray, pts => pts.Length);
            using (var contoursPtr = new ArrayAddress2<Point>(contoursArray))
            {
                if (hierarchy == null)
                {
                    NativeMethods.imgproc_drawContours_vector(image.CvPtr, contoursPtr.Pointer, contoursArray.Length, contourSize2,
                        contourIdx, color, thickness, (int)lineType, IntPtr.Zero, 0, maxLevel, offset0);
                }
                else
                {
                    Vec4i[] hiearchyVecs = EnumerableEx.SelectToArray(hierarchy, hi => hi.ToVec4i());
                    NativeMethods.imgproc_drawContours_vector(image.CvPtr, contoursPtr.Pointer, contoursArray.Length, contourSize2,
                        contourIdx, color, thickness, (int)lineType, hiearchyVecs, hiearchyVecs.Length, maxLevel, offset0);
                }
            }

            image.Fix();
        }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:70,代码来源:Cv2_imgproc.cs

示例14: FillPoly

        /// <summary>
        /// 1つ,または複数のポリゴンで区切られた領域を塗りつぶします.
        /// </summary>
        /// <param name="img">画像</param>
        /// <param name="pts">ポリゴンの配列.各要素は,点の配列で表現されます.</param>
        /// <param name="color">ポリゴンの色.</param>
        /// <param name="lineType">ポリゴンの枠線の種類,</param>
        /// <param name="shift">ポリゴンの頂点座標において,小数点以下の桁を表すビット数.</param>
        /// <param name="offset"></param>
#else
        /// <summary>
        /// Fills the area bounded by one or more polygons
        /// </summary>
        /// <param name="img">Image</param>
        /// <param name="pts">Array of polygons, each represented as an array of points</param>
        /// <param name="color">Polygon color</param>
        /// <param name="lineType">Type of the polygon boundaries</param>
        /// <param name="shift">The number of fractional bits in the vertex coordinates</param>
        /// <param name="offset"></param>
#endif
        public static void FillPoly(
            InputOutputArray img, InputArray pts, Scalar color,
            LineTypes lineType = LineTypes.Link8, int shift = 0, Point? offset = null)
        {
            if (img == null)
                throw new ArgumentNullException(nameof(img));
            if (pts == null) 
                throw new ArgumentNullException(nameof(pts));
            img.ThrowIfDisposed();
            pts.ThrowIfDisposed();
            Point offset0 = offset.GetValueOrDefault(new Point());

            NativeMethods.imgproc_fillPoly_InputOutputArray(
                img.CvPtr, pts.CvPtr, color, (int)lineType, shift, offset0);

            GC.KeepAlive(pts);
            img.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:38,代码来源:Cv2_imgproc.cs

示例15: FillPoly

        /// <summary>
        /// 1つ,または複数のポリゴンで区切られた領域を塗りつぶします.
        /// </summary>
        /// <param name="img">画像</param>
        /// <param name="pts">ポリゴンの配列.各要素は,点の配列で表現されます.</param>
        /// <param name="color">ポリゴンの色.</param>
        /// <param name="lineType">ポリゴンの枠線の種類,</param>
        /// <param name="shift">ポリゴンの頂点座標において,小数点以下の桁を表すビット数.</param>
        /// <param name="offset"></param>
#else
        /// <summary>
        /// Fills the area bounded by one or more polygons
        /// </summary>
        /// <param name="img">Image</param>
        /// <param name="pts">Array of polygons, each represented as an array of points</param>
        /// <param name="color">Polygon color</param>
        /// <param name="lineType">Type of the polygon boundaries</param>
        /// <param name="shift">The number of fractional bits in the vertex coordinates</param>
        /// <param name="offset"></param>
#endif
        public static void FillPoly(Mat img, IEnumerable<IEnumerable<Point>> pts, Scalar color, 
            LineType lineType = LineType.Link8, int shift = 0, Point? offset = null)
        {
            if (img == null)
                throw new ArgumentNullException("img");
            img.ThrowIfDisposed();
            Point offset0 = offset.GetValueOrDefault(new Point());

            List<Point[]> ptsList = new List<Point[]>();
            List<int> nptsList = new List<int>();
            foreach (IEnumerable<Point> pts1 in pts)
            {
                Point[] pts1Arr = Util.ToArray(pts1);
                ptsList.Add(pts1Arr);
                nptsList.Add(pts1Arr.Length);
            }
            Point[][] ptsArr = ptsList.ToArray();
            int[] npts = nptsList.ToArray();
            int ncontours = ptsArr.Length;
            using (ArrayAddress2<Point> ptsPtr = new ArrayAddress2<Point>(ptsArr))
            {
                NativeMethods.core_fillPoly(img.CvPtr, ptsPtr.Pointer, npts, ncontours, color, (int)lineType, shift, offset0);
            }
        }
开发者ID:kaorun55,项目名称:opencvsharp,代码行数:44,代码来源:Cv2_core.cs


注:本文中的System.Point.GetValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。