Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

projectPoints tvec and rvec

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?