c++ - Aruco 函数 estimatePoseSingleMarkers() 错误

标签 c++ opencv aruco

我在运行以下代码时遇到问题:

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)

我需要一些帮助来找出问题所在。谢谢。

最佳答案

请试试 distCoeffs = (Mat1f(5, 1) << 0.133013, -0.322199, -0.001524, 0.004866, 0.0);

关于c++ - Aruco 函数 estimatePoseSingleMarkers() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42412357/

相关文章:

android - 在 CMakeLists 中设置 ANDROID_STL

c++ - 提升程序选项 : does custom validator require overloading operator>>?

python - 仅径向变形即可校准摄像机

opencv - Aruco 期望什么图像编码?

C++合并两个链表段错误和核心转储错误

c++ - Ceres 求解器 C++ : Segmentation fault: 11

python - VideoCapture 在 Python OPENCV [Linux] 中始终返回 False

android - 如何在后台使用 Android 相机?

python - cv2.aruco.detectMarkers 不检测 python 中的标记

c++ - OpenCV 3 和 ArUco lib - 序列化字典