Why "findChessboardCorners" function is returning false
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 :)
imho, you need a "quiet zone", like a 1 or 2 square wide white border around the chessboard
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.
also, counting corners: this is a 9x6
(and maybe you should try with that one first..)
@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 :)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 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 :)
@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 :)