What are the internal workings of the OpenCV function findChessboardCorners?
1 Answer
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
cvCheckChessboard
to determine if a chessboard is in the image - Convert to binary (B&W) and dilate to split the corners apart
- Use
icvGenerateQuads
to 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.
-
1$\begingroup$ Thanks 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 :) $\endgroup$– GeertenJul 5, 2012 at 8:35
-
1$\begingroup$ I Found a nicely written paper...that also offers an alternative method that is more stable and faster (according to the author) researchgate.net/publication/… $\endgroup$– philippeApr 13, 2018 at 15:41