What are the internal workings of the OpenCV function findChessboardCorners?
1 Answers
The source code of OpenCV is available, so I'd recommend just taking some time going through the code. The relevant file for this particular function is:
I've not looked into it in detail, but it looks like
CV_IMPL
int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
CvPoint2D32f* out_corners, int* out_corner_count,
int flags )
is the main implementation of this method. In here they
- Use
cvCheckChessboardto determine if a chessboard is in the image - Convert to binary (B&W) and dilate to split the corners apart
- Use
icvGenerateQuadsto find the squares.
The code then seems to go though a set of checks to condense these quads to chessboard corners, including icvFindConnectedQuads, icvCleanFoundConnectedQuads to remove extra corners, icvCheckQuadGroup, and icvCheckBoardMonotony.
All of these functions are implemented in the same file, apart from cvCheckChessboard which is in calib3d/src/checkchessboard.cpp. Depending how well you wanted to understand the code, there seem to be a number of debugging lines, which can be included if you #define DEBUG_CHESSBOARD, that may help you see what's going on.
- 115
- 5
- 368
- 3
- 13
-
1Thanks for your answer. I know I could look it up, but I was just curious, but not curious enough to go through the source code. I hoped someone figured this out some time, and could explain the principles :) – Geerten Jul 05 '12 at 08:35
-
1I Found a nicely written paper...that also offers an alternative method that is more stable and faster (according to the author) https://www.researchgate.net/publication/282446068_Automatic_chessboard_corner_detection_method – philippe Apr 13 '18 at 15:41