立体三角测量的奇怪问题:两个有效的解决方案

Strange issue with stereo triangulation: TWO valid solutions

我目前正在使用 OpenCV 进行与姿势估计相关的工作,其中我在对之间的点进行三角测量以进行重建和比例因子估计。我在处理这个问题时遇到了一个奇怪的问题,尤其是在 opencv 函数 recoverPose() 和 triangulatePoints() 中。

假设我有摄像头 1 和摄像头 2,在 X 中相隔 spaced,cam1 位于 (0,0,0),cam2 位于其右侧(正 X)。我有两个数组 points1 和 points2,它们是两个图像之间的匹配特征。根据 OpenCV 文档和代码,我注意到两点:

  1. recoverPose() 假定 points1 属于 (0,0,0) 处的相机。
  2. triangulatePoints() 被调用两次:一次来自 recoverPose() 告诉我们四个 R/t 组合中哪一个是有效的,然后再次来自我的代码,文档说:

    cv::triangulatePoints(P1, P2, points1, points2, points3D)  : points1 -> P1 and points2 -> P2. 
    

因此,与 recoverPose() 的情况一样,可以安全地假设 P1 是 [I|0],P2 是 [R|t]。

我实际发现:它不是那样工作的。尽管我的 camera1 位于 0,0,0,camera2 位于 1,0,0(1 符合比例),但只有 运行

才能获得唯一正确的配置
recoverPose(E, points2, points1...)
triangulatePoints([I|0], [R|t], points2, points1, pts3D) 

这应该是不正确的,因为 points2 是来自 R|t 的集合,而不是 points1。我在我的房间里测试了一个场景的图像对,三角测量后有三个明显的物体:一个显示器和它后面墙上的两张海报。这是三角测量产生的点云(请原谅 MS Paint)

如果我按照 OpenCV 规定的方式进行操作:(海报点分散在 space 中,看起来很奇怪)

如果我按照我的(错误的?)方式去做:

任何人都可以分享他们对这里发生的事情的看法吗?从技术上讲,这两种解决方案都是有效的,因为所有的点都落在两个摄像头的前面:而且在将它渲染为点云之前我不知道该选择什么。我做错了什么,还是文档中有错误?我对计算机视觉理论不是很了解,所以我可能在这里遗漏了一些基本知识。感谢您的宝贵时间!

我运行遇到了类似的问题。我相信 OpenCV 以与预期相反的方式定义 t运行slation 向量。使用您的相机配置,t运行slation 向量将为 [-1, 0, 0]。这是违反直觉的,但是 RecoverPose 和 stereoCalibrate 都给出了这个 t运行slation 向量。

我发现当我使用不正确但直观的 t运行slation 向量(例如 [1, 0, 0])时,我无法得到正确的结果,除非我交换 points1 和 points2,就像你做到了。

我怀疑 t运行slation 矢量实际上是 t运行 将点设置到另一个相机坐标系中,而不是 t运行 设置相机姿势的矢量。 OpenCV Documentation,好像是在暗示是这样的:

The joint rotation-translation matrix [R|t] is called a matrix of extrinsic parameters. It is used to describe the camera motion around a static scene, or vice versa, rigid motion of an object in front of a still camera. That is, [R|t] translates coordinates of a point (X,Y,Z) to a coordinate system, fixed with respect to the camera.

维基百科对 Translation of Axis 的描述很好:

In the new coordinate system, the point P will appear to have been translated in the opposite direction. For example, if the xy-system is translated a distance h to the right and a distance k upward, then P will appear to have been translated a distance h to the left and a distance k downward in the x'y'-system

此线程中讨论了此观察结果的原因

平移 t 是 cam2 坐标系中从 cam2 到 cam1 的向量。