我想用以下代码校准鱼眼镜头:
bool found = findChessboardCorners( view, s.boardSize, pointBuf, CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FAST_CHECK | CALIB_CB_NORMALIZE_IMAGE);
vector<vector<Point2f> > imagePoints;
imagePoints.push_back(pointBuf);
Mat cameraMatrix, distCoeffs;
vector<Mat> rvecs, tvecs;
vector<float> reprojErrs;
vector<vector<Point3f> > objectPoints(1);
s.flag = fisheye::CALIB_RECOMPUTE_EXTRINSIC|fisheye::CALIB_FIX_SKEW|fisheye::CALIB_FIX_K1;
calcBoardCornerPositions(s.boardSize, s.squareSize, objectPoints[0], s.calibrationPattern);
double rms = fisheye::calibrate(objectPoints, imagePoints, view.size(), cameraMatrix, distCoeffs, rvecs, tvecs, s.flag);
我找到棋盘没有问题,但在校准过程中出现断言错误:
cv::_InputArray::type 中的断言失败 ((flags & FIXED_TYPE) != 0),文件 ......\sources\modules\core\src\matrix.cpp,第 1792 行
所以我尝试这样初始化rvecs
:
for(int i = 0 ; i < imagePoints.size() ; ++i)
{
rvecs.push_back(Mat::zeros(3, 3, CV_64FC3));
}
但有了这个我得到另一个断言:
OpenCV 错误: cv::_InputArray::getMat 中的断言失败 (0 <= i && i < (int)v.size()),文件 ......\sources\modules\core\src\matrix.cpp ,第 1170 行
如何rvecs
并且tvecs
必须声明和初始化?