cv2.triangulatePoints 是不是很准确?

问题描述

总结

我正在尝试从 2 张图像中对点进行三角测量,但根本没有得到准确的结果。

详情

这是我正在做的事情:

  1. 在现实世界坐标中测量我的 16 个对象点。

  2. 确定每个图像的 16 个对象点的像素坐标。

  3. 使用 cv2.solvePnP() 获取每个摄像头的 tvecs 和 rvecs。

  4. 使用 cv2.projectPoints 来验证 tvecs 和 rvecs 是否将给定的 3D 点重新投影到正确的图像坐标(它确实有效)。例如:

    img_point_right = cv2.projectPoints(np.array([[0,39]],np.float),right_rvecs,right_tvecs,right_intrinsics,right_distortion)
    
  5. 验证后,使用此公式获得旋转矩阵:

    left_rotation,jacobian = cv2.Rodrigues(left_rvecs)
    right_rotation,jacobian = cv2.Rodrigues(right_rvecs)
    

    然后是投影矩阵:

    RT = np.zeros((3,4))
    RT[:3,:3] = left_rotation
    RT[:3,3] = left_translation.transpose()
    left_projection = np.dot(left_intrinsics,RT)
    
    RT = np.zeros((3,:3] = right_rotation
    RT[:3,3] = right_translation.transpose()
    right_projection = np.dot(right_intrinsics,RT)
    
  6. 在进行三角剖分之前,使用 cv2.undistortPoints 取消扭曲点。例如:

    left_undist = cv2.undistortPoints(left_points,cameraMatrix=left_intrinsics,distCoeffs=left_distortion)
    
  7. 对点进行三角测量。例如:

    # Transpose to get into OpenCV's 2xN format.
    left_points_t = np.array(left_undist[0]).transpose()
    right_points_t = np.array(right_undist[0]).transpose()
    # Note,I take the 0th index of each points matrix to get rid of the extra dimension,# although it doesn't affect the output.
    
    triangulation = cv2.triangulatePoints(left_projection,right_projection,left_points_t,right_points_t)
    homog_points = triangulation.transpose()
    
    euclid_points = cv2.convertPointsFromHomogeneous(tri_homog)
    

不幸的是,当我获得最后一步的输出时,尽管我试图重现具有正 Z 位置的 3D 点,但我的点甚至没有正 Z 方向。

作为参考,正 Z 为向前,正 Y 为向下,正 X 为右。

例如,3D 点 (0,39) - 想象一个在你面前 39 英尺的点 - 给出 (4.47,-8.77,-44.81) 的三角测量输出

问题

这是对点进行三角测量的有效方法吗?

如果是这样,cv2.triangulatePoints 是不是一个很好的方法来对点进行三角测量和任何替代建议?

感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)