Why "findChessboardCorners" function is returning false

asked 2019-10-23 05:40:15 -0500

saurabh162 gravatar image

updated 2019-10-23 09:31:50 -0500

berak gravatar image

Dear Developers, I am using Opencv "findChessboardCorners" function to find corners of chess board, but I am getting false as a returned value from findChessboardCorners function.

Can you please explain me why ?

Following is my code and I have also attached Chess board picture I am using.

  int main(int argc, char* argv[])
   {
    vector<vector<Point2f>> imagePoints;    
    Mat view;
    bool found; 
    vector<Point2f> pointBuf;
    Size boardSize;            // The size of the board -> Number of items by width and height  
    boardSize.width = 75;
    boardSize.height = 49;

    view = cv::imread("FraunhoferChessBoard.jpeg"); 
    namedWindow("Original Image", WINDOW_NORMAL);// Create a window for display.
    imshow("Original Image", view);

    found = findChessboardCorners(view, boardSize, pointBuf,
             CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE);

    if (found)
    {
        cout << "Corners of chess board detected";
    }
    else
    {
        cout << "Corners of chess board not detected";
    }
    waitKey(0);
    return 0;
}

many thanks :)image description image description

edit retag flag offensive close merge delete

Comments

imho, you need a "quiet zone", like a 1 or 2 square wide white border around the chessboard

berak gravatar imageberak ( 2019-10-23 06:08:33 -0500 )edit
2

Thank you very much @berak for your fast reply. I have put 1.5 square wide white border around the chess board but it has not helped me !! I have also attached photo with white border for your kind consideration.

saurabh162 gravatar imagesaurabh162 ( 2019-10-23 07:34:32 -0500 )edit

also, counting corners: this is a 9x6

(and maybe you should try with that one first..)

berak gravatar imageberak ( 2019-10-23 07:43:58 -0500 )edit
2

@berak I have already tested my code with 9X6 pattern and it is working fine with it and also I reconfirmed number of corners in attached image...but still I am having problem with the picture I have given above.

Additionally in another forum I have got answer that I can get corners of square boxes in above picture if I use function "findChessboardCornersSB" instead of "findChessboardCorners" function.

But when I use findChessboardCornersSB function in my C++ code I get compilation error that "findChessboardCornersSB" is not defined. I am using OpenCV3.4.7. So have you ever used "findChessboardCornersSB" in function in your project. If yes then which version of OpenCV have you used ? ..Thank you :)

saurabh162 gravatar imagesaurabh162 ( 2019-10-23 08:15:55 -0500 )edit
1

use docs: https://docs.opencv.org/master/d9/d0c...

(there's a version bar , too, and as you can see, 3.4.7 does not have it)

((and i think, to use it, youll need the "special" chessboard there, too))

(((and i think, your current board is too small and has too many corners)))

berak gravatar imageberak ( 2019-10-23 09:13:14 -0500 )edit

@berak thank you very much !! I have updated OpenCV to 4.1 version and can find ""findChessboardCornersSB"" function but it did not help me to solve my problem. And I completely agree with you that for good result I need to improve chessboard picture. But unfortunately I do not have authority to change anything related to chess board in my picture. Dont know what to do next :)

saurabh162 gravatar imagesaurabh162 ( 2019-10-23 10:11:26 -0500 )edit

@berak today I am able to find corners of square boxes in above picture using following function. found = findChessboardCornersSB(view, boardSize, pointBuf, 0);

Please note I have changed third input parameter to function "findChessboardCornersSB" = 0. But many thanks for your help :)

saurabh162 gravatar imagesaurabh162 ( 2019-10-25 06:05:14 -0500 )edit