Example #1
0
 /// <summary>
 /// Creates instance from raw T*
 /// </summary>
 /// <param name="ptr"></param>
 internal static FeatureDetector FromRawPtr(IntPtr ptr)
 {
     if (ptr == IntPtr.Zero)
         throw new OpenCvSharpException("Invalid FeatureDetector pointer");
     var detector = new FeatureDetector
         {
             detectorPtr = null,
             ptr = ptr
         };
     return detector;
 }
Example #2
0
        /// <summary>
        /// Creates instance from raw T*
        /// </summary>
        /// <param name="ptr"></param>
        internal static FeatureDetector FromRawPtr(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException("Invalid FeatureDetector pointer");
            }
            var detector = new FeatureDetector
            {
                detectorPtr = null,
                ptr         = ptr
            };

            return(detector);
        }
Example #3
0
        /// <summary>
        /// Create feature detector by detector name.
        /// </summary>
        /// <param name="detectorType">
        /// "FAST" – FastFeatureDetector,
        /// "STAR" – StarFeatureDetector,
        /// "SIFT" – SIFT (nonfree module),
        /// "SURF" – SURF (nonfree module),
        /// "ORB" – ORB,
        /// "BRISK" – BRISK,
        /// "MSER" – MSER,
        /// "GFTT" – GoodFeaturesToTrackDetector,
        /// "HARRIS" – GoodFeaturesToTrackDetector with Harris detector enabled,
        /// "Dense" – DenseFeatureDetector,
        /// "SimpleBlob" – SimpleBlobDetector
        /// </param>
        /// <returns></returns>
        public static FeatureDetector Create(string detectorType)
        {
            if (String.IsNullOrEmpty(detectorType))
            {
                throw new ArgumentNullException("detectorType");
            }

            // gets cv::Ptr<FeatureDetector>
            try
            {
                IntPtr          ptr      = NativeMethods.features2d_FeatureDetector_create(detectorType);
                FeatureDetector detector = FromPtr(ptr);
                return(detector);
            }
            catch (OpenCvSharpException)
            {
                throw new OpenCvSharpException("Detector name '{0}' is not valid.", detectorType);
            }
        }
Example #4
0
        /// <summary>
        /// Finds centers in the grid of circles.
        /// </summary>
        /// <param name="image">grid view of input circles; it must be an 8-bit grayscale or color image.</param>
        /// <param name="patternSize">number of circles per row and column ( patternSize = Size(points_per_row, points_per_colum) ).</param>
        /// <param name="centers">output array of detected centers.</param>
        /// <param name="flags">various operation flags that can be one of the FindCirclesGridFlag values</param>
        /// <param name="blobDetector">feature detector that finds blobs like dark circles on light background.</param>
        /// <returns></returns>
        public static bool FindCirclesGrid(
            InputArray image,
            Size patternSize,
            out Point2f[] centers,
            FindCirclesGridFlag flags = FindCirclesGridFlag.SymmetricGrid,
            FeatureDetector blobDetector = null)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            image.ThrowIfDisposed();

            using (var centersVec = new VectorOfPoint2f())
            {
                int ret = NativeMethods.calib3d_findCirclesGrid_InputArray(
                image.CvPtr, patternSize, centersVec.CvPtr, (int)flags, ToPtr(blobDetector));
                centers = centersVec.ToArray();
                return ret != 0;
            }
        }
Example #5
0
        /// <summary>
        /// Finds centers in the grid of circles.
        /// </summary>
        /// <param name="image">grid view of input circles; it must be an 8-bit grayscale or color image.</param>
        /// <param name="patternSize">number of circles per row and column ( patternSize = Size(points_per_row, points_per_colum) ).</param>
        /// <param name="centers">output array of detected centers.</param>
        /// <param name="flags">various operation flags that can be one of the FindCirclesGridFlag values</param>
        /// <param name="blobDetector">feature detector that finds blobs like dark circles on light background.</param>
        /// <returns></returns>
        public static bool FindCirclesGrid(
            InputArray image, 
            Size patternSize,
            OutputArray centers, 
            FindCirclesGridFlag flags = FindCirclesGridFlag.SymmetricGrid,
            FeatureDetector blobDetector = null)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            if (centers == null)
                throw new ArgumentNullException("centers");
            image.ThrowIfDisposed();
            centers.ThrowIfNotReady();

            int ret = NativeMethods.calib3d_findCirclesGrid_InputArray(
                image.CvPtr, patternSize, centers.CvPtr, (int)flags, ToPtr(blobDetector));
            centers.Fix();
            return ret != 0;
        }