Ask Your Question
0

projectPoints tvec and rvec

asked 2017-11-22 06:48:31 -0600

gareins gravatar image

I have a problem understanding the two parameters of this function. I thought they are the translation and rotation of the camera in global coordinate system and object points are also given in this global coordinate system. But a simple test proves me wrong:

import cv2
import numpy as np

# principal point (60, 60)
cammat = np.array([[30, 0, 60], [0, 30, 60], [0, 0, 1]], dtype=np.float32)
distortion = np.array([0, 0, 0, 0, 0], dtype=np.float32)

tvec = np.array([0, 0, 0], dtype=np.float32)
rvec = np.array([0, 0, 0], dtype=np.float32)

point_3d = np.array([0.1, 0.1, 1], dtype=np.float32)

# [63.00, 63.00]
p1 = cv2.projectPoints(np.array([[point_3d]]), rvec, tvec, cammat, distortion)

# move camera a bit closer to the 3d point, expecting point on 2d plant
# to be a bit further away from the principal point
tvec = np.array([0, 0, 0.1], dtype=np.float32)
# [62.72, 62.72]
p2 = cv2.projectPoints(np.array([[point_3d]]), rvec, tvec, cammat, distortion)

Where am I wrong?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-11-22 13:15:15 -0600

Tetragramm gravatar image

The coordinate systems are described HERE, in the Detailed Description section.

It's really more the translation and rotation of the coordinate system relative to the camera. Try inverting the coordinates and see if it works. The method to invert the rvec and tvec is HERE.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-11-22 06:48:31 -0600

Seen: 8,591 times

Last updated: Nov 22 '17