Skip to content Skip to sidebar Skip to footer

Opencv Findchessboardcorners Function Is Failing In A (apparently) Simple Scenario

I'm trying to find the corners of a chessboard using OpenCV. The image I'm using contains two chessboards, but I'm interested only in a sub-region of one of those. The following im

Solution 1:

There are two changes needed to make that image acceptable to the very finicky cv2.findChessboardCorners function. First, the chess board needs a white background. I obtained this simply by adjusting the contrast on your image. Second, I also had to white-out the dark horizontal line that connects the black squares at the top and bottom of your chess board. This is the resulting image: enter image description here

With these enhancements, cv2.findChessboardCorners can successfully analyze the image. The results were:

camera matrix =
    [[  1.67e+04   0.00e+00   1.02e+03]
    [  0.00e+00   1.70e+04   5.45e+02]
    [  0.00e+00   0.00e+00   1.00e+00]]

distortion coefficients = [ -4.28e+001.38e+03-8.59e-03-1.49e-026.93e+00]

(Small changes to how the image is enhanced can change the above results greatly. With only one image of a small chess board, these results are not to be trusted.)

As you noted, cv2.findChessboardCorners accepts flags (adaptive threshold, filter_quads, and normalization) that are intended to help with chess board recognition. I tried all but they made no difference here.

Solution 2:

I bet you $5 that the image thresholding inside findChessboardCorners is producing garbage because of the background in the masked image.

I recommend doing a crop, extracting the chessboard, then offsetting the coordinates of the found corners by the crop window position.

Solution 3:

Add white space around the chess pattern. "Note: The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails. "

Solution 4:

I'm working on almost the same problem, but in c++. The function findChessboardCorners doesn't always recognized the chessboard with the given size, and seeing as your image's lighting isn't spread on the chessboard, I think this makes a difference. My suggestion is to decreasethe size of your chessboard until you find something. !!

Solution 5:

The detectCheckerboardPoints function in the Computer Vision System Toolbox for Matlab detects it, but it gives you an extra column:

Result of detectCheckerboardPoints from Matlab

You should be able to get rid of the extra column on the right but moving the right edge of the selected region a little to the left.

Post a Comment for "Opencv Findchessboardcorners Function Is Failing In A (apparently) Simple Scenario"