公制 3d 重建

发布于 2024-08-26 20:11:35 字数 3601 浏览 3 评论 0原文

我正在尝试从 2D 图像对应关系重建 3D 点。我的相机已校准。测试图像是一个方格立方体,并且对应关系是手工挑选的。径向畸变被消除。然而,三角测量后的构造似乎是错误的。 X 和 Y 值似乎是正确的,但 Z 值大致相同,并且沿立方体没有差异。 3D 点看起来就像这些点沿 Z 轴展平一样。

Z 值出了什么问题?是否需要在任何点(例如在计算基本矩阵之前)对这些点进行归一化或从图像坐标进行更改? (如果这太模糊,我可以解释我的一般过程或详细说明部分)

更新

给出: x1 = P1 * Xx2 = P2 * X

x1x2 是第一个和第二个图像点, X 是 3d 点。

但是,我发现 x1 与实际手工选取的值并不接近,但 x2 实际上很接近。

我如何计算投影矩阵:

P1 = [eye(3), zeros(3,1)];
P2 = K * [R, t];

更新 II

优化后的校准结果(具有不确定性)

% Focal Length:          fc = [ 699.13458   701.11196 ] ± [ 1.05092   1.08272 ]
% Principal point:       cc = [ 393.51797   304.05914 ] ± [ 1.61832   1.27604 ]
% Skew:             alpha_c = [ 0.00180 ] ± [ 0.00042  ]   => angle of pixel axes = 89.89661 ± 0.02379 degrees
% Distortion:            kc = [ 0.05867   -0.28214   0.00131   0.00244  0.35651 ] ± [ 0.01228   0.09805   0.00060   0.00083  0.22340 ]
% Pixel error:          err = [ 0.19975   0.23023 ]
% 
% Note: The numerical errors are approximately three times the standard
% deviations (for reference).

-

K =

  699.1346    1.2584  393.5180
         0  701.1120  304.0591
         0         0    1.0000


E =

    0.3692   -0.8351   -4.0017
    0.3881   -1.6743   -6.5774
    4.5508    6.3663    0.2764


R =

   -0.9852    0.0712   -0.1561
   -0.0967   -0.9820    0.1624
    0.1417   -0.1751   -0.9743


t =

    0.7942
   -0.5761
    0.1935


P1 =

     1     0     0     0
     0     1     0     0
     0     0     1     0


P2 =

 -633.1409  -20.3941 -492.3047  630.6410
  -24.6964 -741.7198 -182.3506 -345.0670
    0.1417   -0.1751   -0.9743    0.1935


C1 =

     0
     0
     0
     1


C2 =

    0.6993
   -0.5883
    0.4060
    1.0000


% new points using cpselect

%x1
input_points =

  422.7500  260.2500
  384.2500  238.7500
  339.7500  211.7500
  298.7500  186.7500
  452.7500  236.2500
  412.2500  214.2500
  368.7500  191.2500
  329.7500  165.2500
  482.7500  210.2500
  443.2500  189.2500
  402.2500  166.2500
  362.7500  143.2500
  510.7500  186.7500
  466.7500  165.7500
  425.7500  144.2500
  392.2500  125.7500
  403.2500  369.7500
  367.7500  345.2500
  330.2500  319.7500
  296.2500  297.7500
  406.7500  341.2500
  365.7500  316.2500
  331.2500  293.2500
  295.2500  270.2500
  414.2500  306.7500
  370.2500  281.2500
  333.2500  257.7500
  296.7500  232.7500
  434.7500  341.2500
  441.7500  312.7500
  446.2500  282.2500
  462.7500  311.2500
  466.7500  286.2500
  475.2500  252.2500
  481.7500  292.7500
  490.2500  262.7500
  498.2500  232.7500

%x2
base_points =

  393.2500  311.7500
  358.7500  282.7500
  319.7500  249.2500
  284.2500  216.2500
  431.7500  285.2500
  395.7500  256.2500
  356.7500  223.7500
  320.2500  194.2500
  474.7500  254.7500
  437.7500  226.2500
  398.7500  197.2500
  362.7500  168.7500
  511.2500  227.7500
  471.2500  196.7500
  432.7500  169.7500
  400.2500  145.7500
  388.2500  404.2500
  357.2500  373.2500
  326.7500  343.2500
  297.2500  318.7500
  387.7500  381.7500
  356.2500  351.7500
  323.2500  321.7500
  291.7500  292.7500
  390.7500  352.7500
  357.2500  323.2500
  320.2500  291.2500
  287.2500  258.7500
  427.7500  376.7500
  429.7500  351.7500
  431.7500  324.2500
  462.7500  345.7500
  463.7500  325.2500
  470.7500  295.2500
  491.7500  325.2500
  497.7500  298.2500
  504.7500  270.2500

更新 III

请参阅答案以进行更正。上面计算的答案使用了错误的变量/值。

I'm trying to reconstruct 3D points from 2D image correspondences. My camera is calibrated. The test images are of a checkered cube and correspondences are hand picked. Radial distortion is removed. After triangulation the construction seems to be wrong however. The X and Y values seem to be correct, but the Z values are about the same and do not differentiate along the cube. The 3D points look like as if the points were flattened along the Z-axis.

What is going wrong in the Z values? Do the points need to be normalized or changed from image coordinates at any point, say before the fundamental matrix is computed? (If this is too vague I can explain my general process or elaborate on parts)

Update

Given:
x1 = P1 * X and x2 = P2 * X

x1, x2 being the first and second image points and X being the 3d point.

However, I have found that x1 is not close to the actual hand picked value but x2 is in fact close.

How I compute projection matrices:

P1 = [eye(3), zeros(3,1)];
P2 = K * [R, t];

Update II

Calibration results after optimization (with uncertainties)

% Focal Length:          fc = [ 699.13458   701.11196 ] ± [ 1.05092   1.08272 ]
% Principal point:       cc = [ 393.51797   304.05914 ] ± [ 1.61832   1.27604 ]
% Skew:             alpha_c = [ 0.00180 ] ± [ 0.00042  ]   => angle of pixel axes = 89.89661 ± 0.02379 degrees
% Distortion:            kc = [ 0.05867   -0.28214   0.00131   0.00244  0.35651 ] ± [ 0.01228   0.09805   0.00060   0.00083  0.22340 ]
% Pixel error:          err = [ 0.19975   0.23023 ]
% 
% Note: The numerical errors are approximately three times the standard
% deviations (for reference).

-

K =

  699.1346    1.2584  393.5180
         0  701.1120  304.0591
         0         0    1.0000


E =

    0.3692   -0.8351   -4.0017
    0.3881   -1.6743   -6.5774
    4.5508    6.3663    0.2764


R =

   -0.9852    0.0712   -0.1561
   -0.0967   -0.9820    0.1624
    0.1417   -0.1751   -0.9743


t =

    0.7942
   -0.5761
    0.1935


P1 =

     1     0     0     0
     0     1     0     0
     0     0     1     0


P2 =

 -633.1409  -20.3941 -492.3047  630.6410
  -24.6964 -741.7198 -182.3506 -345.0670
    0.1417   -0.1751   -0.9743    0.1935


C1 =

     0
     0
     0
     1


C2 =

    0.6993
   -0.5883
    0.4060
    1.0000


% new points using cpselect

%x1
input_points =

  422.7500  260.2500
  384.2500  238.7500
  339.7500  211.7500
  298.7500  186.7500
  452.7500  236.2500
  412.2500  214.2500
  368.7500  191.2500
  329.7500  165.2500
  482.7500  210.2500
  443.2500  189.2500
  402.2500  166.2500
  362.7500  143.2500
  510.7500  186.7500
  466.7500  165.7500
  425.7500  144.2500
  392.2500  125.7500
  403.2500  369.7500
  367.7500  345.2500
  330.2500  319.7500
  296.2500  297.7500
  406.7500  341.2500
  365.7500  316.2500
  331.2500  293.2500
  295.2500  270.2500
  414.2500  306.7500
  370.2500  281.2500
  333.2500  257.7500
  296.7500  232.7500
  434.7500  341.2500
  441.7500  312.7500
  446.2500  282.2500
  462.7500  311.2500
  466.7500  286.2500
  475.2500  252.2500
  481.7500  292.7500
  490.2500  262.7500
  498.2500  232.7500

%x2
base_points =

  393.2500  311.7500
  358.7500  282.7500
  319.7500  249.2500
  284.2500  216.2500
  431.7500  285.2500
  395.7500  256.2500
  356.7500  223.7500
  320.2500  194.2500
  474.7500  254.7500
  437.7500  226.2500
  398.7500  197.2500
  362.7500  168.7500
  511.2500  227.7500
  471.2500  196.7500
  432.7500  169.7500
  400.2500  145.7500
  388.2500  404.2500
  357.2500  373.2500
  326.7500  343.2500
  297.2500  318.7500
  387.7500  381.7500
  356.2500  351.7500
  323.2500  321.7500
  291.7500  292.7500
  390.7500  352.7500
  357.2500  323.2500
  320.2500  291.2500
  287.2500  258.7500
  427.7500  376.7500
  429.7500  351.7500
  431.7500  324.2500
  462.7500  345.7500
  463.7500  325.2500
  470.7500  295.2500
  491.7500  325.2500
  497.7500  298.2500
  504.7500  270.2500

Update III

See answer for corrections. Answers computed above were using the wrong variables/values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不打扰别人 2024-09-02 20:11:35

** 请注意,所有参考文献均来自 Hartley 和 Zisserman 的《计算机视觉中的多视图几何》。

好的,所以有几个错误:

  1. 在计算基本矩阵(第 257-259 页)时,作者提到了四个 R,t 集合中正确的 R,t 对(结果 9.19)是其中3D 点位于两个摄像机的前面(图 9.12,a),但没有提及如何计算它。 我重读了第 6 章,发现 6.2.3 (p.162) 讨论了点的深度,结果 6.1 是获得正确的 R 和 t 所需的方程。

  2. 在我在步骤 2 中实现最佳三角测量方法(算法 12.1 (p.318))时,我有 T2^-1' * F * T1^-1 我需要 <代码>(T2^-1)' * F * T1^-1。前者平移 -1。我想要平移 T2 矩阵的倒数(再次被 MATLAB 挫败!)。

  3. 最后,我没有正确计算 P1,它应该是 P1 = K * [eye(3),zeros(3,1)];。我忘记乘以校准矩阵 K。

希望这对未来的路人有帮助!

** Note all reference are to Multiple View Geometry in Computer Vision by Hartley and Zisserman.

OK, so there were a couple bugs:

  1. When computing the essential matrix (p. 257-259) the author mentions the correct R,t pair from the set of four R,t (Result 9.19) is the one where the 3D points lay in front of both cameras (Fig. 9.12, a) but doesn't mention how one computes this. By chance I was re-reading chapter 6 and discovered that 6.2.3 (p.162) discusses depth of points and Result 6.1 is the equation needed to be applied to get the correct R and t.

  2. In my implementation of the optimal triangulation method (Algorithm 12.1 (p.318)) in step 2 I had T2^-1' * F * T1^-1 where I needed to have (T2^-1)' * F * T1^-1. The former translates the -1.I wanted, and in the latter, to translate the inverted the T2 matrix (foiled again by MATLAB!).

  3. Finally, I wasn't computing P1 correctly, it should have been P1 = K * [eye(3),zeros(3,1)];. I forgot to multiple by the calibration matrix K.

Hope this helps future passerby's !

你的背包 2024-09-02 20:11:35

您的点可能处于退化配置。尝试从场景中添加一些不属于立方体的点,看看效果如何。

It may be that your points are in a degenerate configuration. Try to add a couple of points from the scene that don't belong to the cube and see how it goes.

泛滥成性 2024-09-02 20:11:35

需要更多信息:

  • t 是什么?基线对于视差来说可能太小。
  • x1x2 之间有什么差异?
  • 您对校准的准确性有信心吗(我假设您使用 Bouguet Toolbox 的立体声部分)?
  • 当您说对应关系是手工挑选的时,您的意思是您选择了图像上的对应点,还是您在两个图像上使用了兴趣点检测器然后设置了对应关系?

我确信我们可以解决这个问题:)

More information required:

  • What is t? The baseline might be too small for parallax.
  • What is the disparity between x1 and x2?
  • Are you confident about the accuracy of the calibration (I'm assuming you used the Stereo part of the Bouguet Toolbox)?
  • When you say the correspondences are hand-picked, do you mean you selected the corresponding points on the image or did you use an interest point detector on the two images are then set the correspondences?

I'm sure we can resolve this problem :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文