OpenCV unable to recognize (any) checkerboard pattern

We have been attempting to calibrate a DSLR camera for several weeks now, using literally every kind of calibration board, scene, lighting, and more. In every, single case, OpenCV fails to find any checkerboard patterns. Here is an example photo:


This checkerboard is completely flat, printed on foam board with matte finish (for minimal reflectivity). Regardless of whether it is shot inside or outside, the corners are never recognized. I have heard that OpenCV’s algorithm for corner recognition is not very robust, but wanted to reach out to the forum before confirming this conclusion for myself.

We have also tried calibration boards with white boarder, dark boarders (of varying sizes). Literally nothing works. Here is the code used for the photo above:

img = cv.imread(os.path.join(imgDir,fname), cv.IMREAD_UNCHANGED)

scale_percent = .25
width = int(img.shape[1] * scale_percent)
height = int(img.shape[0] * scale_percent)
dsize = (width, height)    
dimg = cv.resize(img, dsize)     

gray = cv.cvtColor(dimg, cv.COLOR_RGB2GRAY)
ret, corners = cv.findChessboardCorners(gray, (7, 5), None)

ret is always false, and corners is always empty. No exceptions. Is there a limit on the size of the image or some other constraint that has not been published in the documentation? No other programs trialed have been able to calibrate this camera, including MATLAB.

you need a constant ~1 block sized border around it, see here

(else it cannot detect the outer blocks)

((also, you sure, that this is absolutely flat ? looks like some sine wave going over it, from here…))

i’m getting kinda seasick, staring at this image.
where does this “wobble” come from ?
look at top/bottom of the door, and where the color changes on the wall.

It works with a border, to a greater degree, but our LiDAR calibration tool (ACSC) will not work if a border is present. In fact, the author of that project discouraged us from using one (ACSC uses the findChessBoardSB method).

The sine wave is a distortion resulting from re-sizing the original image. Here is a close-up:

I suggest you round the outer corners of every outer black (or white) square.

oh and opencv’s imread reads color as BGR, so your cvtColor is getting the wrong argument, but that doesn’t matter much here.

I get a result for these pictures:

why is this a problem? because you don’t have a border!

if there was a border, the outer corners wouldn’t be saddle points (where four squares meet), and the algorithm could properly ignore them.

curiously… this manually preprocessed image also gives me a (5,7) result. it’s merely a threshold (but not at 50% gray) plus removing part of the tripod on the bottom edge:

1 Like

These are all reasonable suggestions, except for the fact that this calibration board is coming straight from the LiDAR-camera calibration repo that I have been using to successfully sync other laser-camera pairs in our workflow. In fact, the board is a printout of the image specifically recommended for that project, and it has worked with other cameras before – just not this particular one.

That particular algorithm requires a borderless checkerboard for the purpose of correlating its corners with the actual 3D corners of the point cloud after multiple RANSAC passes. I have tried images with borders, as you have proposed, and OpenCV is capable of recognizing the corners in 99% of trials. It is specifically this borderless variant that is giving us trouble, and again … only with this DSLR camera we are trying to calibrate, which is producing UHD images.

I have a word into the ACSC developer, since he has made it very clear in past interactions that we need to avoid borders. This happens to be the only solution that has been able to successfully calibrate extrinsics for solid-state LiDARs and other cameras. There are targetless methods we are working with, but they have their own peculiar issues, mostly with intrinsics at very high resolution (which is a hard requirement).

Looks like I may be forced to re-write the LiDAR calibration to allow borders of fixed width. That seems to be the only logical solution here.

I see.

you could consider writing a custom checkerboard detection. take OpenCV’s algorithm apart. I think the first steps (finding corners) already exist as separate functions in OpenCV.

tricky situation…