gpt4 book ai didi

opencv - 3d 点投影 2d 点错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:50:27 25 4
gpt4 key购买 nike

我尝试使用 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)

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

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

所以我把这些打印出来

root error

head error

似乎发生了一些奇怪的变化。

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

关于opencv - 3d 点投影 2d 点错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52036098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com