我有一个 3D 世界,我试图使用 cv2.projectPoints 将其映射到 2D 视图,但它没有按我的预期运行。我对 opencv、numpy 和矩阵运算的掌握很弱,所以我一定在某个地方做出了错误的假设。这段代码:
src = np.ones((6, 3))
src[:,1] = 2
src[:,2] = range(6) # source points
rvec = np.array([0,0,0], np.float) # rotation vector
tvec = np.array([0,0,0], np.float) # translation vector
fx = fy = 1.0
cx = cy = 0.0
cameraMatrix = np.array([[fx,0,cx],[0,fy,cy],[0,0,1]])
result = cv2.projectPoints(src, rvec, tvec, cameraMatrix, None)
for n in range(len(src)):
print src[n], '==>', result[0][n]
Run Code Online (Sandbox Code Playgroud)
生成此输出:
[ 1. 2. 0.] ==> [[ 1. 2.]]
[ 1. 2. 1.] ==> [[ 1. …
Run Code Online (Sandbox Code Playgroud)