Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

camera calibration - unable to detect chessboard

I am using openCV's function to detect a chessboard, yet no chessboard is being detected.

The image I am using:

enter image description here

const Size chessboardDimensions = Size(4,8);
int main (int argv, char ** argc)
{
        frame = imread("/home/Georges/Desktop/a.jpg");
        cvtColor(frame, frame, CV_BGR2GRAY);
        int found = findChessboardCorners(frame, chessboardDimensions, foundPoints, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE);

}

found always equals 0. Could someone explain me why?

like image 359
LandonZeKepitelOfGreytBritn Avatar asked Oct 18 '25 18:10

LandonZeKepitelOfGreytBritn


1 Answers

const Size chessboardDimensions = Size(4,8);

In this expression size should be

Size(5,8)

Because you should count inner squares's corners.

Edit:

As mentioned in comments, int found should be bool. Because the function returns if corners are found or not.

And as suggestion add fast checking option to your function otherwise the function may work laggy:

bool found = findChessboardCorners(frame, chessboardDimensions, foundPoints, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE | CALIB_CB_FAST_CHECK);

And it is good idea to check if all points found correctly. In some cases all points cannot be detected and in further applications this situation gives an error. Because the output of this function will be input of another one. So add an continue expression to your loop:

if(found == 0 || foundPoints.size() != chessboardDimensions.area())
    continue;