I am using openCV's function to detect a chessboard, yet no chessboard is being detected.
The image I am using:
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?
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With