我在运行以下代码时遇到问题:
Mat cameraMatrix, distCoeffs;
cameraMatrix = (Mat1f(3, 3) << 462.71, 0, 338.630, 0, 465.97, 177.780, 0, 0, 1);
distCoeffs = (Mat1f(4, 1) << 0.133013, -0.322199, -0.001524, 0.004866);
//skip
Mat color(Size(color_information.width, color_information.height), CV_8UC3, (void*)color_data.planes[0], color_data.pitches[0] / sizeof(uchar));
Mat imageCopy;
double tick = (double)getTickCount();
vector<int>ids;
vector<vector<Point2f>>corners, rejected;
vector<Mat>rvecs, tvecs;
aruco::detectMarkers(color, dictionary, corners, ids, detectorParams, rejected);
double currentTime = ((double)getTickCount() - tick) / getTickFrequency();
// draw results
color.copyTo(imageCopy);
if (ids.size() > 0)
{
aruco::drawDetectedMarkers(imageCopy, corners, ids);
vector<Mat>rvecs, tvecs;
estimatePoseSingleMarkers(corners, 20, cameraMatrix, distCoeffs, rvecs, tvecs);
for (int i = 0; i<ids.size(); i++)
drawAxis(imageCopy, cameraMatrix, distCoeffs, rvecs[i], tvecs[i],0.1);
}
问题是当程序执行到estimatePoseSingleMarkers(corners, 20, cameraMatrix, distCoeffs, rvecs, tvecs);
我收到这样的错误消息:
OpenCV Error: Assertion failed (0 <= i && i < (int)v.size()) in cv::_InputArray::getMat_, file C:\opencv-3.0\source\opencv\modules\core\src\matrix.cpp, line 1253
它是由错误的变量格式引起的吗?(cameraMartix & distCoeffs)
我需要一些帮助来弄清楚出了什么问题。谢谢你。