11
$\begingroup$

What are the internal workings of the OpenCV function findChessboardCorners?

$\endgroup$

1 Answer 1

13
$\begingroup$

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:

calib3d/src/calibinit.cpp

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

  1. Use cvCheckChessboard to determine if a chessboard is in the image
  2. Convert to binary (B&W) and dilate to split the corners apart
  3. 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.

$\endgroup$
2
  • 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$
    – Geerten
    Jul 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$
    – philippe
    Apr 13, 2018 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.