something weird about `findChessboardCorners()`

asked 2016-04-21 23:13:20 -0600

german_iris gravatar image

updated 2016-04-22 03:21:58 -0600

these days I was re-writing my opencv code on qt framework. the code runs well on the virtual studio 2013, but when I run it on the qt, something weird happened. the code is as follow

cv::Mat view, viewGray;
for(int i = 0; i < nImages; i++)
    vector<cv::Point2f> pointBuf;
    int q = pointBuf.size();
    view = cv::imread(, 1);
    cv::cvtColor(view, viewGray, cv::COLOR_BGR2GRAY);
    bool found = cv::findChessboardCorners(view, boardSize, pointBuf, \
                                           CV_CALIB_CB_ADAPTIVE_THRESH | \
                                           CV_CALIB_CB_FAST_CHECK | \
    int p =  pointBuf.size();

        cv::cornerSubPix(viewGray, pointBuf, cv::Size(11, 11), cv::Size(-1, -1), \
                         cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));

I set two variables p and q to see the size change of pointBuf. which I get q = 0, p = -10728254, but with the findChessboardCorners() return value is true.

my debegger infomation is as follow,

image description

and the image for calibration is as follow,

image description

update: I set the debugger point at imagePoints.push_back(pointBuf); , as you can see in the following picture.

image description

edit retag flag offensive close merge delete


strange thing. .size() returns a size_t instead of int, but that should be handled by your IDE. Do your points look ok? How do you initialize boardSize?

FooBar gravatar imageFooBar ( 2016-04-22 02:44:39 -0600 )edit

What's the exact problem here? Where did you place the debug stop point? The debug output that you're showing is perfectly fine if you put the stop point after findChessboardCorners but before initializing p (it contains garbage value)

LorenaGdL gravatar imageLorenaGdL ( 2016-04-22 02:48:31 -0600 )edit

I initialize boardSize as follow,

int w = 7, h = 9;
boardSize.width = w; boardSize.height = h;

and I set the stop point at the line imagePoints.push_back(pointBuf); which after initializing p

german_iris gravatar imagegerman_iris ( 2016-04-22 03:03:23 -0600 )edit

I changed the variables type to size_t,but still get a very ridiculous result. which p = 4287838401

german_iris gravatar imagegerman_iris ( 2016-04-22 03:11:28 -0600 )edit