Ask Your Question

minoken's profile - activity

2020-11-17 13:42:20 -0600 received badge  Student (source)
2016-04-27 06:53:57 -0600 asked a question "_rvec" and "_tvec" for solvePnPRansac() are wrong.

Environment:
OpenCV 3.1.0
OS X 10.11.4

I am using "solvePnPRansac()" to get "_rvec" and "_tvec".
However, I thought values are wrong.
Because when I tried same step with "OpenCV 2.4.12", there is the difference between both.

call "solvePnP" with arg "rvec", but set "_local_model.col" as "_rvec". ("tvec" also)

Code:

opencv-3.1.0/modules/calib3d/src/solvepnp.cpp (https://github.com/Itseez/opencv/blob...)

result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix, distCoeffs, rvec, tvec, false, flags == SOLVEPNP_P3P ? SOLVEPNP_EPNP : flags) ? 1 : -1;
_rvec.assign(_local_model.col(0));    // output rotation vector
_tvec.assign(_local_model.col(1));    // output translation vector

I think this is right.

Code:

result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix, distCoeffs, _local_model.col(0), _local_model.col(1), false, flags == SOLVEPNP_P3P ? SOLVEPNP_EPNP : flags) ? 1 : -1;

What do you think?