Example #1
0
 /// <summary>
 /// Finds centers in the grid of circles
 /// </summary>
 /// <param name="image">Source chessboard view</param>
 /// <param name="patternSize">The number of inner circle per chessboard row and column</param>
 /// <param name="flags">Various operation flags</param>
 /// <param name="featureDetector">The feature detector. Use a SimpleBlobDetector for default</param>
 /// <param name="centers">output array of detected centers.</param>
 /// <returns>True if grid found.</returns>
 public static bool FindCirclesGrid(IInputArray image, Size patternSize, IOutputArray centers, CvEnum.CalibCgType flags, Feature2D featureDetector)
 {
     using (InputArray iaImage = image.GetInputArray())
         using (OutputArray oaCenters = centers.GetOutputArray())
             return(cveFindCirclesGrid(iaImage, ref patternSize, oaCenters, flags, featureDetector.Feature2DPtr));
 }
Example #2
0
 private static extern bool cveFindCirclesGrid(IntPtr image, ref Size patternSize, IntPtr centers, CvEnum.CalibCgType flags, IntPtr blobDetector);
Example #3
0
        /*
         * public static void TestDrawLine(IntPtr img, int startX, int startY, int endX, int endY, MCvScalar color)
         * {
         * TestDrawLine(img, startX, startY, endX, endY, color.v0, color.v1, color.v2, color.v3);
         * }
         *
         * [DllImport(CvInvoke.ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention, EntryPoint="testDrawLine")]
         * private static extern void TestDrawLine(IntPtr img, int startX, int startY, int endX, int endY, double v0, double v1, double v2, double v3);
         *
         * /// <summary>
         * /// Implements the chamfer matching algorithm on images taking into account both distance from
         * /// the template pixels to the nearest pixels and orientation alignment between template and image
         * /// contours.
         * /// </summary>
         * /// <param name="img">The edge image where search is performed</param>
         * /// <param name="templ">The template (an edge image)</param>
         * /// <param name="contours">The output contours</param>
         * /// <param name="cost">The cost associated with the matching</param>
         * /// <param name="templScale">The template scale</param>
         * /// <param name="maxMatches">The maximum number of matches</param>
         * /// <param name="minMatchDistance">The minimum match distance</param>
         * /// <param name="padX">PadX</param>
         * /// <param name="padY">PadY</param>
         * /// <param name="scales">Scales</param>
         * /// <param name="minScale">Minimum scale</param>
         * /// <param name="maxScale">Maximum scale</param>
         * /// <param name="orientationWeight">Orientation weight</param>
         * /// <param name="truncate">Truncate</param>
         * /// <returns>The number of matches</returns>
         * public static int ChamferMatching(Mat img, Mat templ,
         * out Point[][] contours, 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)
         * {
         * using (Emgu.CV.Util.VectorOfVectorOfPoint vecOfVecOfPoint = new Util.VectorOfVectorOfPoint())
         * using (Emgu.CV.Util.VectorOfFloat vecOfFloat = new Util.VectorOfFloat())
         * {
         *    int count = cveChamferMatching(img, templ, vecOfVecOfPoint, vecOfFloat, templScale, maxMatches, minMatchDistance, padX, padY, scales, minScale, maxScale, orientationWeight, truncate);
         *    contours = vecOfVecOfPoint.ToArrayOfArray();
         *    cost = vecOfFloat.ToArray();
         *    return count;
         * }
         * }
         * [DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
         * private static extern int cveChamferMatching(
         * IntPtr img, IntPtr templ,
         * IntPtr results, IntPtr cost,
         * double templScale, int maxMatches,
         * double minMatchDistance, int padX,
         * int padY, int scales, double minScale, double maxScale,
         * double orientationWeight, double truncate);
         */

        /// <summary>
        /// Finds centers in the grid of circles
        /// </summary>
        /// <param name="image">Source chessboard view</param>
        /// <param name="patternSize">The number of inner circle per chessboard row and column</param>
        /// <param name="flags">Various operation flags</param>
        /// <param name="featureDetector">The feature detector. Use a SimpleBlobDetector for default</param>
        /// <returns>The center of circles detected if the chess board pattern is found, otherwise null is returned</returns>
        public static PointF[] FindCirclesGrid(Image <Gray, Byte> image, Size patternSize, CvEnum.CalibCgType flags, Feature2D featureDetector)
        {
            using (Util.VectorOfPointF vec = new Util.VectorOfPointF())
            {
                bool patternFound =
                    FindCirclesGrid(
                        image,
                        patternSize,
                        vec,
                        flags,
                        featureDetector
                        );
                return(patternFound ? vec.ToArray() : null);
            }
        }