Ask Your Question
0

Return both solutions from solvePnp cv::SOLVEPNP_IPPE_SQUARE?

asked 2020-02-06 07:37:30 -0500

antithing gravatar image

updated 2020-02-06 07:41:24 -0500

I have a PnP function that uses solvePnP with the cv::SOLVEPNP_IPPE_SQUARE type.

 std::vector<cv::Mat> rvecsVec, tvecsVec;
solvePnP(markerObjPoints, marker.corners2d, K, D, rvecsVec, tvecsVec, false, cv::SOLVEPNP_IPPE_SQUARE);

This should return multiple solutions, as I understand it, but passing a std::vector<cv::Vec3d> rvecsVec into the rvec output as above crashes my application.

OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.1.1-dev) Error: Assertion failed ((flags & FIXED_TYPE) != 0) in cv::_InputArray::type, file d:\thirdparty\opencv_4.0\opencv_4.1\opencv-master\modules\core\src\matrix_wrap.cpp, line 801

How can I return all possible solutions from this function?

thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-02-06 08:03:04 -0500

antithing gravatar image

Ah, this will do it. solvePnPGeneric instead of regular solvePnP.

std::vector<cv::Vec3d> rvecsVec, tvecsVec;
        solvePnPGeneric(markerObjPoints, marker.corners2d, K, D, rvecsVec, tvecsVec, false, cv::SOLVEPNP_IPPE_SQUARE);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-02-06 07:37:30 -0500

Seen: 25 times

Last updated: Feb 06