I am currently working on a project where I need to indentify a chessboard pattern like this:
https://preview.ibb.co/g7Dnka/cow.jpg
I searched for some code that could do this and found the OpenCV function findChessboardCorners
. I could test it successfully with some images. That's the code in C++:
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2\calib3d\calib3d.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
// read the file
Mat image = imread("cow.jpg", IMREAD_COLOR);
// check for valid image
if (!image.data)
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
// grid size (cols, rows)
Size size(7, 7);
// store detected centers
vector <Point2f> centers;
bool sucess = findChessboardCorners(image, size, centers);
cout << "find: " << sucess;
// draw the chessboard
drawChessboardCorners(image, size, Mat(centers), sucess);
// display the result
namedWindow("Display window", WINDOW_AUTOSIZE);
imshow("Display window", image);
waitKey(0);
return 0;
}
My problem is that it only accepts chessboards with height and width bigger than 2 (counting only inner corners), but I'm working with 8 x 2 size.
Is there any way to bypass that or even writing my own function? Thanks for any help.