Ask Your Question

Revision history [back]

i think patternsize is the key.

Size patternsize(19, 3); //interior number of corners

you can test the code below

#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"


using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    Mat img = imread("15323725004322727.png");
    imshow("image", img);

    Size patternsize(19, 3); //interior number of corners
    Mat gray;
    cvtColor(img, gray, COLOR_BGR2GRAY);//source image
    vector<Point2f> corners; //this will be filled by the detected corners

                             //CALIB_CB_FAST_CHECK saves a lot of time on images
                             //that do not contain any chessboard corners
    bool patternfound = findChessboardCorners(gray, patternsize, corners,
        CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
        + CALIB_CB_FAST_CHECK);

    drawChessboardCorners(img, patternsize, Mat(corners), patternfound);

    imshow("result", img);
    waitKey(0);
}