示例#1
0
        /// <summary>
        /// Attempts to determine whether the input image is a view of the chessboard pattern and locate internal chessboard corners
        /// </summary>
        /// <param name="image">Source chessboard view</param>
        /// <param name="patternSize">The number of inner corners per chessboard row and column</param>
        /// <param name="flags">Various operation flags</param>
        /// <returns>The corners detected if the chess board pattern is found, otherwise null is returned</returns>
        public static PointF[] FindChessboardCorners(
            Image <Gray, Byte> image,
            Size patternSize,
            CvEnum.CALIB_CB_TYPE flags)
        {
            int cornerCount = 0;

            PointF[] corners = new PointF[patternSize.Width * patternSize.Height];
            GCHandle handle  = GCHandle.Alloc(corners, GCHandleType.Pinned);

            bool patternFound =
                CvInvoke.cvFindChessboardCorners(
                    image.Ptr,
                    patternSize,
                    handle.AddrOfPinnedObject(),
                    ref cornerCount,
                    flags) != 0;

            handle.Free();

            if (cornerCount != corners.Length)
            {
                Array.Resize(ref corners, cornerCount);
            }

            return(patternFound ? corners : null);
        }
示例#2
0
 public static extern int cvFindChessboardCorners(
     IntPtr image,
     Size patternSize,
     IntPtr corners,
     ref int cornerCount,
     CvEnum.CALIB_CB_TYPE flags);