1

I am trying to undersatand how solvepnp works. I tried giving 8 corner points of an object (its 2D - 3D correspondence) and intrinsics of camera. I get the result as

rvec

-1.59 -1.6 -0.89

Tvec

-18 3000 1400

When i tried reprojecting using output of solvepnp rvec and tvec, the points get properly overlayed on the input image. When I increment value of one of my image points by one(say (400,300) earlier and now I just changed to (401,300)). My rvec changes sign and tvec value drastically varies . Now it is

rvec

1.6 1.6 -0.8

Tvec

9 -900 5000

Reprojection also fails. I am curious on how this change occurs with the minor change. How can it be solved?

Namrit
  • 11
  • 2
  • you have a lot of solvePnP algorithms in OpenCV. The default one is the iterative method. It iterates the minimization algorithm until convergence. Some of the other methods uses direct solutions. The noisier the points the higher the error and sometimes it may not converge. Also, 8 points is quite a small sample, try to use 30 or more and the noise will be smaller. or you can try to use RANSAC one – api55 Aug 21 '18 at 13:20
  • Thank you for the response!! yes, currently i am using iterative method. I have doubt like is there any chance of axis rotation with one pixel change that moves the points to negative coordinate. Also when i tried using python opencv solvepnp function, it works perfectly fine which shows very lesser reprojection error which is obivious with one pixel error. Will solvepnp result of CPP and python varies? (i use opencv 3.3.0 for both) – Namrit Aug 22 '18 at 04:06
  • it could change direction if the object is ambiguous (a square for instance) and that it may have more than one unique solution. However this are NOT euler angles, this is in Rodrigues.... and not neccesarily means that it is 1.6 degrees one way or the other. The iterative mode depends on the initial result and on the stopping criteria. It would be advisable to post the code, to be able to see if there is something different from the two codes (c++ and python), but it should not, the python interface normally uses the c++ functions – api55 Aug 22 '18 at 07:43
  • Thanks for the help.. I have sorted the issue and that was because i was trying to use p3p for estimating pose in cpp and iterative in python, the flag number got mismatched. It works perfectly fine – Namrit Aug 27 '18 at 09:59

0 Answers0