zoukankan      html  css  js  c++  java
  • 【多视图几何】TUM 课程 第6章 多视图重建

    课程的 YouTube 地址为:https://www.youtube.com/playlist?list=PLTBdjV_4f-EJn6udZ34tht9EVIW7lbeo4 。视频评论区可以找到课程所使用课件与练习题的下载地址。

    课程第6章介绍从多张影像重建同名点三维空间坐标的方法,详细讲解线性系统的秩与现实世界的对应关系。

    1. 从双视图到多视图

    双视图对一个空间点只能提供四个测量值(左右影像的 (x, y)),三视图能够提供六个测量值,多视图能够提供更多的测量值,对空间点的三维坐标有更大的约束,所以能够得到更精确的结果。

    一般而言,实际使用的大多是三视图重建,而不会选择使用四视图、五视图。。。这是一个效率上的问题。

    2. 多视图的原像与余像

    同名点或者同名线在多张影像上的原像(Preimage)是其在各影像上原像的交集。

    [preimage(mathbf{x_1}, dots, mathbf{x_m}) = preimage(mathbf{x_1}) cap dots cap preimage(mathbf{x_n}) ]

    [preimage(mathscr{l_1}, dots, mathscr{l_m}) = preimage(mathscr{l_1}) cap dots cap preimage(mathscr{l_m}) ]

    双视图中点与线的原像(图片来源于 TUM 课程 Slides):

    TwoViewPreimageOfPointAndLine

    考虑在多视图中点与线的投影关系,以得到在多视图中的约束关系。

    假设有一空间点 (mathbf{X}) 在时刻 (t) 的影像上的坐标为 (mathbf{x}(t)),对于时刻 (t) 能够列出以下方程:

    [lambda(t)mathbf{x}(t) = K(t) Pi_0g(t)mathbf{X} ]

    对于空间中一直线 (L),该直线可以用集合表示:

    [L = left{ mathbf{X} left. ight| mathbf{X} = mathbf{X_0} + mu mathbf{V}, mu in mathbb{R} ight} subset mathbb{R}^4 ]

    其中 $ mathbf{X_0} = {egin{bmatrix} X_0, Y_0, Z_0, 1 end{bmatrix}}^T in mathbb{R}^4 $ 是基础点 (p_0),表示线所在的位置;$ mathbf{V} = {egin{bmatrix} V_1, V_2, V_3, 0 end{bmatrix}}^T in mathbb{R}^4 $ 表示线的方向。

    对于直线 (L) 在时刻 (t) 的影像上的坐标可以用 (mathscr{l}(t)) 表示,(mathscr{l}(t)) 向量与直线在 (t) 时刻影像上的像中的任意点 (mathbb{x}(t)) 垂直:

    [mathscr{l}(t)^T mathbf{x}(t) =mathscr{l}(t)^TK(t)Pi_0g(t)mathbf{X} = 0 ]

    整理一下,将时刻 (t) 离散化,只有时刻 (t_1, dots, t_m) 对应 (m) 张影像,令 (Pi_i = K(t_i)Pi_0g(t_i)),结合线 (L) 的集合表达((mathbf{X_0})(mathbf{V}) 线性无关):

    [mathscr{l}_i^TPi_imathbf{X_0} = mathscr{l}_i^TPi_imathbf{V} = 0 ]

    3. 原像与秩约束

    3.1 点

    (mathbf{X})(m) 张影像上的像平面坐标系坐标为 (mathbf{x_1}, dots, mathbf{x_m}),每一张影像都能列出

    [lambda_imathbf{x_i} = Pi_imathbf{X} ]

    整合成一个式子

    [mathscr{I} vec{lambda} equiv {egin{bmatrix} mathbf{x_1} & 0 & dots & 0 \ 0 & mathbf{x_2} & dots & 0 \ vdots & vdots & ddots & vdots \ 0 & 0 & dots & mathbf{x_m} end{bmatrix}} {egin{bmatrix} lambda_1 \ lambda_2 \ vdots \ lambda_m end{bmatrix}} = {egin{bmatrix} Pi_1 \ Pi_2 \ vdots \ Pi_m end{bmatrix}} mathbf{X} equiv Pimathbf{X} ]

    [mathscr{I}vec{lambda} = Pimathbf{X} ]

    [mathscr{I} in mathbb{R}^{3m imes m}, quad veclambda in mathbb{R}^m, quad Pi in mathbb{R}^{3m imes 4} ]

    这种形式还是不可以,因为不是 (Ax = 0) 的形式,不能用线性代数求解,引入新的矩阵 (N_p) 与向量 (u)

    [N_p equiv egin{bmatrix} Pi, mathscr{I} end{bmatrix} = {egin{bmatrix} Pi_1 & mathbf{x_1} & 0 & dots & 0 \ Pi_2 & 0 & mathbf{x_2} & dots & 0 \ vdots & vdots & vdots & ddots & vdots \ Pi_m & 0 & 0 & dots & mathbf{x_m} end{bmatrix}} in mathbb{R}^{3m imes (m+4)} ]

    [u equiv egin{bmatrix} mathbf{X} \ -veclambda end{bmatrix} in mathbb{R}^{m+4} ]

    于是式子简化为

    [N_p u = 0 ]

    其实还可以继续简化(-_-||),把 (veclambda) 去掉。引入一个能够去除 (mathscr{I}) 的矩阵 (mathscr{I}^{ot})

    [mathscr{I}^{ot} = egin{bmatrix} hat{mathbf{x_1}} & 0 & dots & 0 \ 0 & hat{mathbf{x_2}} & dots & 0 \ vdots & vdots & ddots & vdots \ 0 & 0 & dots & hat{mathbf{x_m}} end{bmatrix} in mathbb{R}^{3m imes 3m} ]

    简化后

    [mathscr{I}^{ot}Pimathbf{X} = 0 ]

    不能简化了。。。

    新定义一个矩阵 (W_p) 方便讨论:

    [W_p equiv mathscr{I}^{ot}Pi = egin{bmatrix} hat{mathbf{x_1}}Pi_1 \ hat{mathbf{x_2}}Pi_2 \ vdots \ hat{mathbf{x_m}}Pi_m end{bmatrix} in mathbb{R}^{3m imes 4} ]

    影像的数量 (m ge 2),所以 (W_p) 的满秩是4,而 (W_p) 有一维 null space 是 (mathbf{X}) ,于是得到 (W_p) 的秩的限制条件:

    [rank(W_p) le 3 ]

    整理一下:

    [rank(W_p) = rank(N_p) - m le 3 ]

    3.2 线

    空间中直线 (L)(m) 张影像中有 (m) 个像(或者说是余像,线在影像中的像就是用余像表达的嘛) (mathscr{l}_i, i = 1, dots, m),于是对于用基底 (mathbf{X_0}) 和方向 (mathbf{V}) 表达的直线有

    [mathscr{l}_i^T Pi_i mathbf{X_0} = mathscr{l}_i^T Pi_i mathbf{V} = 0 ]

    合并有

    [W_l equiv egin{bmatrix} mathscr{l}_1^TPi_1 \ mathscr{l}_2^TPi_2 \ vdots \ mathscr{l}_m^TPi_m end{bmatrix} in mathbf{R}^{m imes 4} ]

    (W_l) 的 null space 维度为2,所以当 (m = 2) 时,满秩为2,与列满秩4相差2,刚好能够求解得到两个 null space,解出的直线唯一。

    要解出一条直线,需要

    [rank(W_l) le 2 ]

    4. 几何理解

    4.1 点

    对于空间的一个点 (mathbf{X}),列出线性系统

    [W_p mathbf{X} = 0, quad W_p = egin{bmatrix} hat{mathbf{x_1}}Pi_1 \ hat{mathbf{x_2}}Pi_2 \ vdots \ hat{mathbf{x_m}}Pi_m end{bmatrix} in mathbb{R}^{3m imes 4} ]

    其中 $ hat{mathbf{x_i}} $ 的秩为2,(W_p) 中独立的行最多有 (2m) 个,每一个独立的行都定义了一个平面,空间点 (mathbf{X}) 就是这 (2m) 个平面的交点(图片来源于 TUM 课程 Slides):

    4PlaneIntersectAPoint

    (m=1) 时,(W_p) 的秩为2,null space 的维度为2,空间点落在一条直线上,无法求解,可以想象一下单片的情况。

    (m=2) 时,(W_p) 满秩为4,此时无解,但是如果 (2m = 4) 个平面中有两个平面重合,则 (W_p) 的秩为3,能够唯一解出一个 (mathbf{X})

    (m ge 3) 时,(W_p) 满秩为4,此时要求 (W_p) 的秩为3,能够唯一解出 (mathbf{X})

    4.2 线

    对于空间中的一条直线 (L) 列出线性系统:

    [W_l = egin{bmatrix} mathscr{l}_1^TPi_1 \ mathscr{l}_2^TPi_2 \ vdots \ mathscr{l}_m^TPi_m end{bmatrix} in mathbf{R}^{m imes 4} ]

    (m=1) 时,(W_l) 的秩为1,null space 的维度为3,直线 (L) 落在一个平面上,无法确定。

    (m=2) 时,(W_l) 满秩为2,null space 的维度为2,直线 (L) 可以被唯一确定,但这种确定没有任何意义,因为两个平面只要不是平行关系都能唯一确定一条交线。

    (m=3) 时,(W_l) 满秩为3,null space 的维度为1,只能确定一个点了,所以需要 (W_l) 不满秩,其秩为2,能够唯一确定一条交线。

    (m ge 4)(W_l) 满秩为4,null space 的维度为0,无解,对 (W_l) 秩的要求同 (m=3) 的情形。

    5. 多视图重建矩阵

    现在考虑前面得到的矩阵的秩与普通极线约束之间的关系。

    对于空间中的一个点,得到了矩阵 (W_p)

    [W_p equiv mathscr{I}^{ot}Pi = egin{bmatrix} hat{mathbf{x_1}}Pi_1 \ hat{mathbf{x_2}}Pi_2 \ vdots \ hat{mathbf{x_m}}Pi_m end{bmatrix} in mathbb{R}^{3m imes 4} ]

    正常情况((nge2))下,(W_p) 满秩是4,用一个满秩矩阵 (D_p in mathbb{R}^{4 imes 5}) 右乘它,结果的秩与 (W_p) 的秩相同:

    [W_pD_p = egin{bmatrix} hat{mathbf{x_1}}Pi_1 \ hat{mathbf{x_2}}Pi_2 \ vdots \ hat{mathbf{x_m}}Pi_m end{bmatrix} egin{bmatrix} hat{mathbf{x_1}} & mathbf{x_1} & 0 \ 0 & 0 & 1 end{bmatrix} = egin{bmatrix} hat{mathbf{x_1}}hat{mathbf{x_1}} & 0 & 0 \ hat{mathbf{x_2}}R_2hat{mathbf{x_1}} & hat{mathbf{x_2}}R_2mathbf{x_1} & hat{mathbf{x_2}}T_2 \ hat{mathbf{x_3}}R_3hat{mathbf{x_1}} & hat{mathbf{x_3}}R_3mathbf{x_1} & hat{mathbf{x_3}}T_3 \ vdots & vdots & vdots \ hat{mathbf{x_m}}R_mhat{mathbf{x_1}} & hat{mathbf{x_m}}R_mmathbf{x_1} & hat{mathbf{x_m}}T_m end{bmatrix} in mathbb{R}^{3m imes 5} ]

    (W_p) 的秩的限制条件为 (rank(W_p) le 3),于是有矩阵

    [M_p equiv egin{bmatrix} hat{mathbf{x_2}}R_2mathbf{x_1} & hat{mathbf{x_2}}T_2 \ hat{mathbf{x_3}}R_3mathbf{x_1} & hat{mathbf{x_3}}T_3 \ vdots & vdots \ hat{mathbf{x_m}}R_mmathbf{x_1} & hat{mathbf{x_m}}T_m end{bmatrix} in mathbb{R}^{3(m-1) imes 2 } ]

    的秩 (rank(M_p) le 1)

    (rank(M_p) le 1) 的意思就是 (M_p) 的两列线性相关,于是:

    [lambda hat{mathbf{x_i}}R_imathbf{x_1} + hat{mathbf{x_i}}T_i = 0, quad i = 1, 2, dots, m ]

    [M_p egin{bmatrix} lambda_1 \ 1 end{bmatrix} = 0 ]

    6. 与极线约束的关系

    其实上式中的 (lambda = lambda_1),是空间点在第一张影像中的景深。

    上式即极线约束,证明如下:

    (hat{mathbf{x_i}}R_imathbf{x_1})(hat{mathbf{x_i}}T_i) 线性相关,即 (mathbf{x_i} imes R_imathbf{x_1})(mathbf{x_i} imes T_i) 的方向一致,即可得出结论“(mathbf{x_i}, T_i, R_imathbf{x_1}) 三条向量共面”,这就是极线约束的几何意义。

    [mathbf{x_i}^T(T_i imes R_i mathbf{x_1}) = mathbf{x_i}^That{T_i}R_imathbf{x_1} = 0 ]

    对于任意非零向量 (a_i, b_i in mathbb{R}^3, i = 1, dots, n),矩阵 $$ egin{bmatrix} a_1 & b_1 a_2 & b_2 vdots & vdots a_n & b_n end{bmatrix} in mathbb{R}^{3n imes}$$ 非满秩(rank-deficient),当且仅当 (a_i b_j^T - b_i a_j^T =0, forall i, j = 1, dots, n)

    利用这个性质,对矩阵 (M_p) 可以写出

    [hat{mathbf{x_i}}R_imathbf{x_1}(hat{mathbf{x_j}}T_j)^T - hat{mathbf{x_i}}T_i(hat{mathbf{x_j}}R_jmathbf{x_1})^T = 0 ]

    整理一下,得到三视图的极线约束(trilinear constraint):

    [hat{mathbf{x_i}}(T_imathbf{x_1}^TR_j^T - R_imathbf{x_1}T_j^T)hat{mathbf{x_j}} = 0 ]

    利用在双试图重建中的方法(克罗内克积)可以一步求得两张影像 (i, j) 相对于第一张影像的位姿,一个点能够提供9个方程,但其中仅有4个线性无关的方程((hat{mathbf{x_i}}) 的秩为2)。

    7. 多视图重建的求解算法

    这是一个迭代的求解方法。

    (M_p) 两个列向量线性无关得到了这个式子:

    [M_p egin{bmatrix} lambda_1 \ 1 end{bmatrix} = 0 ]

    除以一个 (lambda_1)

    [M_p egin{bmatrix} 1 \ alpha end{bmatrix} = 0, quad alpha = {1 over lambda_1} ]

    采集了空间中 (n) 个点的影像,对于第 (j) 个点,能够列出下面的方程:

    [egin{bmatrix} hat{mathbf{x_2^j}}R_2mathbf{x_1} \ hat{mathbf{x_3^j}}R_3mathbf{x_1} \ vdots \ hat{mathbf{x_m^j}}R_mmathbf{x_1} end{bmatrix} + alpha^j egin{bmatrix} hat{mathbf{x_2^j}}T_2 \ hat{mathbf{x_3^j}}T_3 \ vdots \ hat{mathbf{x_m^j}}T_m end{bmatrix} = 0 ]

    对于第 (i) 张影像以及所有空间点:

    [P_i egin{bmatrix} R_i^s \ T_i end{bmatrix} = egin{bmatrix} mathbf{x_1^1} otimes hat{mathbf{x_i^1}} & alpha^1hat{mathbf{x_i^1}} \ mathbf{x_1^2} otimes hat{mathbf{x_i^2}} & alpha^2hat{mathbf{x_i^2}} \ vdots & vdots \ mathbf{x_1^n} otimes hat{mathbf{x_i^n}} & alpha^nhat{mathbf{x_i^n}} end{bmatrix} egin{bmatrix} R_i^s \ T_i end{bmatrix} ]

    $ P_i in mathbb{R}^{3n imes 12} $ 当点 (n ge 6) 时,其满秩为12,其秩为11,则 null space 有唯一解。

    然而解上面的 (R_i, T_i) 需要事先知道各点的景深 (alpha^1, dots, alpha^n),对于 RGBD 相机和双目相机,这完全没有问题,可以直接获取。

    但是对于普通单目相机,这个问题就是一个迭代的过程,在景深和位姿之间迭代。

    [alpha^j = - {Sigma_{i=2}^m(hat{mathbf{x_i^j}} T_i)^T hat{mathbf{x_i^j}}R_imathbf{x_1^j} over Sigma_{i=2}^m| hat{mathbf{x_i^j}} T_i |^2}, quad j = 1, dots, n ]

    8. 线的多视图重建

    与点的方式类似,就不赘述了。

  • 相关阅读:
    读《大道至简—编程的精义》有感
    c++ 指针做为参数和返回值
    c++ 函数
    c++ 分配与释放内存
    c++ 以多维数组的形式访问动态内存
    c++ 动态数组,指针与动态内存分配
    c++ 指针访问数组
    c++ 常量指针
    c++ 指针
    c++ 字符串转换
  • 原文地址:https://www.cnblogs.com/JingeTU/p/6390877.html
Copyright © 2011-2022 走看看