1
votes

I'm recently using the Matlab Single Camera Calibration App algorithm to calibrate the camera intrinsics and extrinsics. On finding corners of the chessboard, many times detectCheckerboardPoints function of Matlab out performs (accuracy) the opencv api cv::findChessboardCorners, yet on some pictures, Matlab behaves strange.

E.g., in the following image, corners between board squares are clear to see, while matlab finds redundant ones on strange places:

  1. original image: //there should be 5*8=40 inner corner points enter image description here

  2. corner points found on the undistorted image: //6*9=54 found enter image description here

  3. points found on the original image: //6*10=60... enter image description here

The matlab code snippet is simple as below:

img=imread(fn);
[imUndist, newOrig]=undistortImage(img, cameraParams);
[pxs, bdsize]=detectCheckerboardPoints(imUndist); %or detect on 'img' directly
imMarked=insertMarker(imUndist, pxs);
imshow(imMarked);
  1. corners detected with opencv (code below) on this image is much precise:

//opencv code:

Mat img = imread(fpath);
int ww = 8, hh = 15;
cv::Size bsz(ww, hh);
vector<Point2f> ptvec;
bool found = cv::findChessboardCorners(img, bsz, ptvec, CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE);
cv::drawChessboardCorners(img, bsz, ptvec, found);
imshow("img", img);
waitKey();

enter image description here

3

3 Answers

5
votes

Make the checkerboard bigger! This can happen, and it does happen. Generally, you want a the checkerboard to be part of most of the screen. You solve two problems with this:

  1. There are more pixels per checkerboard square, thus the corner detecting algorithm can find it better
  2. You correct for distortion better. The camera distortion is stronger in the corners of the image, thus if the checkerboard has points all around the image, it will detect the distortion considerably better then if its just a small thing in the middle of the image.
2
votes

You'd better make a bigger checkerboard with a white margin bigger than the size of the squares, but if you persist to use this images, edit them with Paint and whiten half of the outermost black squares and some of the area around the checkerboard. It helps to have a better detection with no bad effect on the further calculations. I hope it works.

0
votes

Maybe you should consider removing outliers in the calibration to have a better results (I mean what was the Error percentage while you were calibrating? was it acceptable?). Also try sharpening the Image after getting rid of distortion. because it seems that the resolution of the undistorted image has been dropped significantly and that may cause error.