3d 点投影 2d 点错误

3d points project 2d points error

我尝试使用 cv2.projectpoints 将人体骨骼的 3d 点投影到 2d 点。

这是我的代码:

tmp = np.array(data_3d['root'][i]).reshape(1,3)
revc = np.array([0, -15, -25], np.float)  # rotation vector
tvec = np.array([-2, -2, -12], 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(tmp, revc, tvec, cameraMatrix, None)

但是我在投影过程中发现了一些奇怪的二维点。

root:
     X min_max=(-166.92720209469152, 1243.4813901875507)
       mean=4.290786012592475, variance=4722.3197294835645
     Y min_max=(-402.9192018458054,55.87842522603996)
       mean=0.11309526315136062, variance=499.5386080289831
head:
     X min_max=(-1757.835481879438, 425.7047344280786)
       mean=-4.077206416367477, variance=10165.268433754276
     Y min_max=(-426.06627880880535, 104.67033311809274) 
       mean=0.14534586064178603, variance=600.3554834467959

所以我把这些打印出来

看来,发生了一些奇怪的变化。

40 => 80 => 190 => 425 => -1757 => -268 => -60 => -33

我的问题是为什么会发生这种奇怪的事情?

我觉得一开始可能会遮挡,但是head不会被遮挡

旋转矢量 rvec 以弧度为单位,而不是度数。而是将其声明为:

revc = np.rad2deg(np.array([0, -15, -25], np.float))  # rotation vector

此外,焦距 fx=fx=1 的单位是米,我怀疑你的相机的焦距是 1 毫米。如果你的焦距是 1 毫米,那么说:

fx = fy = .001 # in meters

如果您需要更多帮助,请将这些点绘制在图像上,然后向我们展示图像。这也将使您对投影的外观有一个很好的了解。这可以通过以下方式完成:

from matplotlib import pyplot as plt
plt.scatter(*zip(*result[0][:,0,:]))
plt.show()

还有,下面的是什么意思?

As it seems, there is some strange change.

40 => 80 => 190 => 425 => -1757 => -268 => -60 => -33