0

I would like to find the camera position based on the marker and use it as a ground truth. I use the following code to find the pose with solvepnp.

  retval, rvec, tvec, inliers = cv2.solvePnPRansac(objPoints, imgPoints, K, None, None, None, False ,method)

K is the camera matrix , imgpoints is the corners, objpoints is the model points. Based on these values, I calculated the camera position using the following code,

    gt_camPos = np.dot(-np.transpose(rot_mat), tvec)

I have used the above camera position as the ground truth. I have a QR code which is attached next to the marker. I computed the camera position using the QR Code as well as using the same method. However, both camera positions deviate a lot. why is that so? Is there a way to create proper ground truth for camera position?

Mr. Randy Tom
  • 311
  • 5
  • 13
  • solvePnp computes the OBJECG pose with standard camera. You'll have to invert the trandformation to get the camera pose with standard objecf reference (you've inverted rotation by transposing, but you didn't invert the translation??). Make sure to check the opencv coordinate system as well (y going downwards, etc.) – Micka Nov 24 '20 at 06:07
  • @Micka `gt_camPos = np.dot(-np.transpose(rot_mat), -np.transpose(tvec))` something like this? – Mr. Randy Tom Nov 24 '20 at 06:29
  • no, transposing is only inversion for rotation matrices. If you would work with 4x4 transformation matrices you could just invert the whole matrix. Just inverting a translation is the negative of the non-inverted transformation. – Micka Nov 24 '20 at 07:57
  • could you please add an example? :) – Mr. Randy Tom Nov 24 '20 at 12:26

0 Answers0