Pergunta

I am using solvePnP to find camera pose estimate. I get this assertion error:

    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

Here is my code:

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);

Here p3d is a vector(Vec3d), points2d is a vector(Point2d) and camera is a Matx33f. What am I doing wrong?

Foi útil?

Solução

Looked at the source. The "rvec" and "tvec" are "created" in the code. Initializing "rvec" and "tvec" as Mat instead got the job done.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top