something weird about `findChessboardCorners()`
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(fileList.at(i).toStdString(), 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 | \
CV_CALIB_CB_NORMALIZE_IMAGE);
int p = pointBuf.size();
if(found)
{
cv::cornerSubPix(viewGray, pointBuf, cv::Size(11, 11), cv::Size(-1, -1), \
cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
imagePoints.push_back(pointBuf);
}
}
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,
and the image for calibration is as follow,
update:
I set the debugger point at imagePoints.push_back(pointBuf);
, as you can see in the following picture.
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?
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 initializingp
(it contains garbage value)I initialize boardSize as follow,
and I set the stop point at the line
imagePoints.push_back(pointBuf);
which after initializingp
I changed the variables type to
size_t
,but still get a very ridiculous result. whichp = 4287838401