问题描述
亲爱的 StackOverflow 社区, 我是计算机视觉的新手,正在尝试通过立体相机设置进行 3d 重建。我使用的是 OpenCV 4.2。
为了获得 3d 点,我在 Python 中使用了以下函数:
def listener_callback(self,left_sub,right_sub):
left_pointcloud_array=self.pointcloud2_to_array(left_sub)
right_pointcloud_array=self.pointcloud2_to_array(right_sub)
left_pointcloud_points=self.get_xyz_points(left_pointcloud_array,True)
right_pointcloud_points=self.get_xyz_points(right_pointcloud_array,True)
expanded_pointcloud_left=np.expand_dims(left_pointcloud_points[:,0:2],axis=0)
expanded_pointcloud_right=np.expand_dims(right_pointcloud_points[:,axis=0)
undistorted_left_points=cv2.undistortPoints(expanded_pointcloud_left,self.mtx_left,self.dist_left,R=self.R1,P=self.P1)
undistorted_right_points=cv2.undistortPoints(expanded_pointcloud_right,self.mtx_right,self.dist_right,R=self.R2,P=self.P2)
homogeneous_points=cv2.triangulatePoints(self.P1,self.P2,undistorted_left_points,undistorted_right_points)
euclidian_points=cv2.convertPointsFromHomogeneous(homogeneous_points.T)
我使用stereoCalibrate() 和stereoRectify() 执行了校准相机的常规程序,以获得必要的参数。
我的投影和旋转矩阵如下所示:
Rotation Left:
[[ 1.74396716e-01 -2.24232058e-02 -9.84420126e-01]
[-6.74380962e-06 9.99740653e-01 -2.27733728e-02]
[ 9.84675472e-01 3.97824016e-03 1.74351335e-01]]
Rotation Right:
[[ 0.26564842 0.01475253 -0.9639571 ]
[ 0.00640275 0.99983386 0.01706607]
[ 0.96404871 -0.01070555 0.26550983]]
Projection Left:
[[802.76027664 0. 286.89848328 0. ]
[ 0. 802.76027664 545.2985878 0. ]
[ 0. 0. 1. 0. ]]
Projection Right:
[[ 8.02760277e+02 0.00000000e+00 2.86898483e+02 -1.97666622e+04]
[ 0.00000000e+00 8.02760277e+02 5.45298588e+02 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 1.00000000e+00 0.00000000e+00]]
每个处理步骤的输出格式如下:
Left Point Cloud Points:
[[1177. 632. 0.]
[ 577. 645. 0.]
[ 709. 617. 0.]
[ 752. 599. 0.]
[1008. 606. 0.]
[ 933. 590. 0.]
[ 949. 593. 0.]]
Right Pointcloud Points:
[[ 516. 617. 0.]
[1108. 611. 0.]
[ 899. 567. 0.]
[ 958. 583. 0.]
[ 716. 575. 0.]
[ 665. 590. 0.]
[ 875. 561. 0.]]
Left undistorted Points
[[[ -621.96014059 655.29581241]]
[[ 6237.09222297 -147.54603359]]
[[-13996.99448978 1655.35728924]]
[[ -6375.59001936 888.5805037 ]]
[[ -1195.74790188 645.80792001]]
[[ -1673.46875581 624.31269017]]
[[ -1550.52589 628.6326525 ]]]
Right undistorted Points
[[[21831.58774037 -1164.08348054]]
[[ -917.20195746 655.39724904]]
[[-1774.77772702 611.04975486]]
[[-1447.74110015 635.05964827]]
[[-4224.1926576 715.17949778]]
[[-6295.03254479 894.49244928]]
[[-1940.52139146 600.20176599]]]
Homogeneous Points
[[-0.71403187 0.98887098 0.99699365 0.99187257 0.87442586 0.91830464
0.91580335]
[-0.44568786 -0.04820826 -0.04098027 -0.03222296 -0.07970141 -0.09989733
-0.03444816]
[ 0.35017816 0.1322324 -0.05588276 -0.11942512 -0.47305239 -0.3730683
-0.40006913]
[-0.41096969 0.04821559 0.03466128 0.02980154 -0.07244673 -0.08693191
-0.00788962]]
Euclidian Points
[[[ 1.73743195 1.08447866 -0.85207784]]
[[ 20.50936148 -0.99984793 2.74252362]]
[[ 28.76390524 -1.18230701 -1.61225349]]
[[ 33.28259031 -1.08125129 -4.00734679]]
[[ -12.0699145 1.10013804 6.52965812]]
[[ -10.56349263 1.14914448 4.29149981]]
[[-116.07702337 4.36626481 50.7083032 ]]]
然而,triangulatePoints() 函数给了我完整的废话答案。我不确定我是否错误地使用了 triangulatePoints() 函数或我的相机参数是垃圾。
有人能帮我解惑吗?
非常感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)