문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top