/// <summary> /// Finds the positions of internal corners of the chessboard. /// </summary> /// <param name="image">Source chessboard view. It must be an 8-bit grayscale or color image.</param> /// <param name="patternSize">Number of inner corners per a chessboard row and column /// ( patternSize = Size(points_per_row,points_per_colum) = Size(columns, rows) ).</param> /// <param name="corners">Output array of detected corners.</param> /// <param name="flags">Various operation flags that can be zero or a combination of the ChessboardFlag values</param> /// <returns>The function returns true if all of the corners are found and they are placed in a certain order (row by row, left to right in every row). /// Otherwise, if the function fails to find all the corners or reorder them, it returns false.</returns> public static bool FindChessboardCorners( InputArray image, Size patternSize, out Point2f[] corners, ChessboardFlags flags = ChessboardFlags.AdaptiveThresh | ChessboardFlags.NormalizeImage) { if (image == null) throw new ArgumentNullException("image"); image.ThrowIfDisposed(); using (var cornersVec = new VectorOfPoint2f()) { int ret = NativeMethods.calib3d_findChessboardCorners_vector( image.CvPtr, patternSize, cornersVec.CvPtr, (int)flags); corners = cornersVec.ToArray(); return ret != 0; } }
/// <summary> /// Finds the positions of internal corners of the chessboard. /// </summary> /// <param name="image">Source chessboard view. It must be an 8-bit grayscale or color image.</param> /// <param name="patternSize">Number of inner corners per a chessboard row and column /// ( patternSize = Size(points_per_row,points_per_colum) = Size(columns, rows) ).</param> /// <param name="corners">Output array of detected corners.</param> /// <param name="flags">Various operation flags that can be zero or a combination of the ChessboardFlag values</param> /// <returns>The function returns true if all of the corners are found and they are placed in a certain order (row by row, left to right in every row). /// Otherwise, if the function fails to find all the corners or reorder them, it returns false.</returns> public static bool FindChessboardCorners( InputArray image, Size patternSize, OutputArray corners, ChessboardFlags flags = ChessboardFlags.AdaptiveThresh | ChessboardFlags.NormalizeImage) { if (image == null) throw new ArgumentNullException("image"); if (corners == null) throw new ArgumentNullException("corners"); image.ThrowIfDisposed(); corners.ThrowIfNotReady(); int ret = NativeMethods.calib3d_findChessboardCorners_InputArray( image.CvPtr, patternSize, corners.CvPtr, (int)flags); corners.Fix(); return ret != 0; }