使用solvePnP时的断言错误

时间:2014-05-10 21:24:16

标签: opencv

我正在使用solvePnP来查找相机姿势估计。我得到这个断言错误:

    OpenCV Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0)) in virtual void cv::_OutputArray::create(int, int const*, int, int, bool, int) const, file /home/reports/ci/slave/50-SDK/opencv/modules/core/src/matrix.cpp, line 1438 terminate called after throwing an instance of 'cv::Exception'
    what():  /home/reports/ci/slave/50-SDK/opencv/modules/core/src/matrix.cpp:1438: error: (-215) mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) in function virtual void cv::_OutputArray::create(int, int const*, int, int, bool, int) const

这是我的代码:

Vec4f noArray;
Vec3f rvec,tvec;
std::vector<cv::Vec3f> p3f;
Mat(p3d).copyTo(p3f);
std::vector<cv::Point2f> points2f;
Mat(points2d).copyTo(points2f);
solvePnP(p3f,points2f,camera,noArray,rvec,tvec,true,CV_ITERATIVE);

这里p3d是矢量(Vec3d),points2d是矢量(Point2d),相机是Matx33f。我做错了什么?

1 个答案:

答案 0 :(得分:1)

看着来源。 “rvec”和“tvec”在代码中“创建”。将“rvec”和“tvec”初始化为Mat而不是完成工作。