我试图在Microsoft Visual Studio 2012中使用OpenCV 2.4.9进行相机校准,但我总是收到此错误:
Assertion failed (i < 0) in cv::_InputArray::getMat, file C:\buildslave64\win64_amdoc1\2_4_PackSlave-win32-vc11-shared\opencv\modules\core\src\matrix.cpp, line 963
这是我的校准部分代码:
m->srcLR.copyTo(webcamImage);
pyrUp(webcamImage, webcamImage);
cvtColor(webcamImage, gray, CV_BGR2GRAY);
bool found = findChessboardCorners(gray, cbSize, imagePoints, CALIB_CB_FAST_CHECK);
if (found)
{
cout << "found";
cornerSubPix(gray, imagePoints, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1));
drawChessboardCorners(webcamImage, Size(boardW, boardH), imagePoints, found);
}
if (waitKey(30) == char('c'))
{
calibrateCamera(boardPoints, imagePoints, cbSize, intrinsics, distortion, rvecs, tvecs);
cout << endl << intrinsics << endl;
cout << endl << distortion << endl;
}
imshow("Calibrate Camera", webcamImage);
waitKey(10);
有关数据类型的详细信息:
boardPoints - &gt; Point3d的矢量
for (int i=0; i<boardW; i++)
{
for (int j=0; j<boardH; j++)
{
boardPoints.push_back(Point3d(double(i), double(j), 0.0));
}
}
boardW = 9且boardH = 6。
我对cornerSubPix
和drawChessboardCorners
进行了评论,因为我打算使用它,但它也会出错,我的主要目标是内在函数和失真矩阵。
其他信息:我在按下“c&#39;”时出现的错误。按钮。另一个错误发生在cornerSubPix和drawChessboardCorners中:
cornersubpix:
OpenCV Error: Assertion failed (ncorners >= 0 && corners.depth() == CV_32F) in cv::cornerSubPix, file C:\buildslave64\win64_amdocl\2_4_PackSlave-win32-vc11-shared\opencv\modules\imgproc\src\cornersubpix.cpp, line 257
drawchessboardcorners:
OpenCV Error: Assertion failed (nelems >= 0) in cv::drawChessboardCorners, file C:\buildslave64\win64_amdocl\2_4_PackSlave-win32-vc11-shared\opencv\modules\calib3d\src\calibinit.cpp, line 1939