Beyond Photometric Loss for Self-Supervised Ego-Motion Estimation
港科大,腾讯优图,香港珠穆朗玛峰创新科技(Altizure)
本文对现有的视觉历程计方法使用的损失函数进行了总结,并提出了一种基于几何一致性的损失函数。
现有里程计方法
主要分为两类:
- 间接法:
SLAM系统常用,首先计算出一些鲁棒的特征点边缘集合或者是光流信息,然后用滑窗或者全局BA最小化几何误差。 - 直接法:
VSLAM常用,直接优化对应像素的光度误差。光度误差的前提是光度一致假设,这种做法因为受到动态目标、相机自动曝光自动白平衡以及反射表面的影响,鲁棒性较差。多见于自监督学习方法中。
本文方法
先介绍下现有的损失函数:
1、光度误差(图像重建误差、合成图像误差)
图像I2中的像素点P2在I1中的投影为:
p
1
∼
K
1
[
R
12
^
∣
t
12
]
D
2
^
(
p
2
)
K
2
−
1
p
2
p_{1} \sim K_{1}\left[\hat{R_{12}} \mid t_{12}\right] \widehat{D_{2}}\left(p_{2}\right) K_{2}^{-1} p_{2}
p1∼K1[R12^∣t12]D2
(p2)K2−1p2
其中K为相机内参,D为所预测的深度图,R t为预测的两帧之间的相对位姿。
讲投影的I1与I1相减得到合成图像损失:
L
i
m
g
=
(
1
−
α
)
∥
I
2
−
I
2
1
~
∥
1
+
α
1
−
S
S
I
M
(
I
2
−
I
2
1
~
)
2
\mathcal{L}_{i m g}=(1-\alpha)\left\|\mathcal{I}_{2}-\widetilde{\mathcal{I}_{2}^{1}}\right\|_{1}+\alpha \frac{1-S S I M\left(\mathcal{I}_{2}-\widetilde{\mathcal{I}_{2}^{1}}\right)}{2}
Limg=(1−α)∥∥∥I2−I21
∥∥∥1+α21−SSIM(I2−I21
)
第一项为光度误差,第二项为结构相似性度量(从统计学角度衡量两张图像的相似性)
这个损失公式应该伴随一个平滑项来解决运动估计中的梯度局部性问题,并在低纹理区域消除所获得深度的不连续性
因此有一项平滑损失:
图
像
的
平
滑
区
域
对
深
度
图
损
失
值
的
影
响
更
大
L
smooth
=
∑
p
∣
∇
D
(
p
)
∣
T
⋅
e
−
∣
∇
I
(
p
)
∣
图像的平滑区域对深度图损失值的影响更大 \mathcal{L}_{\text {smooth}}=\sum_{p}|\nabla D(p)|^{T} \cdot e^{-|\nabla I(p)|}
图像的平滑区域对深度图损失值的影响更大Lsmooth=p∑∣∇D(p)∣T⋅e−∣∇I(p)∣
主要用于约束深度图的预测。
2、基于对极几何的几何误差
这是本文提出的损失函数。
对于两幅图像中的匹配点对,满足对极几何约束:
q
i
T
F
12
p
i
=
(
K
2
−
1
q
i
′
)
T
R
12
[
t
12
]
×
(
K
1
−
1
p
i
′
)
=
0
q_{i}^{T} F_{12} p_{i}=\left(K_{2}^{-1} q_{i}^{\prime}\right)^{T} R_{12}\left[t_{12}\right]_{\times}\left(K_{1}^{-1} p_{i}^{\prime}\right)=0
qiTF12pi=(K2−1qi′)TR12[t12]×(K1−1pi′)=0
“F12 is the corresponding fundamental matrix,p′i and q′i represent the homogeneous camera coordinates of the i-th matched points, and K1 and K2 are their corresponding intrinsic matrix.”
其中,
l
12
(
i
)
=
F
12
p
i
l_{12}^{(i)}=F_{12} p_{i}
l12(i)=F12pi定义了qi所在极线的方程,因此可以用qi到这条极线之间的距离来构建损失:
L
g
e
o
=
∑
i
dist
(
l
12
(
i
)
,
q
i
)
dist
(
a
x
+
b
y
+
c
=
0
,
(
x
0
,
y
0
)
)
=
∣
a
x
0
+
b
y
0
+
c
∣
a
2
+
b
2
\mathcal{L}_{g e o}=\sum_{i} \operatorname{dist}\left(l_{12}^{(i)}, q_{i}\right) \\ \operatorname{dist}\left(a x+b y+c=0,\left(x_{0}, y_{0}\right)\right)=\frac{\left|a x_{0}+b y_{0}+c\right|}{\sqrt{a^{2}+b^{2}}}
Lgeo=i∑dist(l12(i),qi)dist(ax+by+c=0,(x0,y0))=a2+b2∣ax0+by0+c∣
3、弱几何监督
使用位姿真值构建损失的方法,主要有直接法和间接法两种:
- 直接法:
p 1 ∼ K 1 P 1 P 2 − 1 D 2 ^ ( p 2 ) K 2 − 1 p 2 ∼ K 1 [ R 1 ∣ T 1 ] [ R 2 T ∣ − R 2 T T 2 ] D 2 ^ ( p 2 ) K 2 − 1 p 2 ∼ K 1 [ R 1 R 2 T ∣ T 1 − R 1 R 2 T T 2 ] D 2 ^ ( p 2 ) K 2 − 1 p 2 \begin{aligned} p_{1} & \sim K_{1} P_{1} P_{2}^{-1} \widehat{D_{2}}\left(p_{2}\right) K_{2}^{-1} p_{2} \\ & \sim K_{1}\left[R_{1} \mid T_{1}\right]\left[R_{2}^{T} \mid-R_{2}^{T} T_{2}\right] \widehat{D_{2}}\left(p_{2}\right) K_{2}^{-1} p_{2} \\ & \sim K_{1}\left[R_{1} R_{2}^{T} \mid T_{1}-R_{1} R_{2}^{T} T_{2}\right] \widehat{D_{2}}\left(p_{2}\right) K_{2}^{-1} p_{2} \end{aligned} p1∼K1P1P2−1D2 (p2)K2−1p2∼K1[R1∣T1][R2T∣−R2TT2]D2 (p2)K2−1p2∼K1[R1R2T∣T1−R1R2TT2]D2 (p2)K2−1p2 - 间接法:
L pose = L rotation + L translation = w r ∥ r i j − r i j ‾ ∥ 2 + w t ∥ t i j ^ − t i j ‾ ∥ 2 \begin{aligned} \mathcal{L}_{\text {pose}} &=\mathcal{L}_{\text {rotation}}+\mathcal{L}_{\text {translation}} \\ &=w_{r}\left\|r_{i j}-\overline{r_{i j}}\right\|_{2}+w_{t}\left\|\hat{t_{i j}}-\overline{t_{i j}}\right\|_{2} \end{aligned} Lpose=Lrotation+Ltranslation=wr∥rij−rij∥2+wt∥∥tij^−tij∥∥2
4、光度损失的补偿
由于动态目标、光度变化等因素,直接使用光度损失误差较大,需要一个mask来决定那些区域的像素是可靠的。本文使用一种简单的方法来动态生成mask:定义一个光度误差阈值,光度误差超过该阈值的则认为是动态区域,不计入损失函数。
具体的阈值也是动态的,标准是使得最后有效像素值为99%,即稳定的剔除1%的像素。
M
(
P
M
)
=
{
1
Percentile
(
L
i
m
g
(
i
,
j
)
)
≤
P
M
0
otherwise
P
M
=
0.99
\mathcal{M}\left(P_{M}\right)=\left\{\begin{array}{cc} 1 & \operatorname{Percentile}\left(\mathcal{L}_{i m g}(i, j)\right) \leq P_{M} \\ 0 & \text { otherwise } \end{array}\right. \\ P_M = 0.99
M(PM)={10Percentile(Limg(i,j))≤PM otherwise PM=0.99
不同阈值对mask的影响可视化:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TjLVqc4i-1605944748521)(index_files/a28a62fe-c412-4382-a9ef-57779c98b66e.jpg)]
总损失函数:
L total = M ( P M ) ⊙ L i m g + w s L smooth + [ w g L geo ] + [ w p L pose ] \mathcal{L}_{\text {total}}=\mathcal{M}\left(P_{M}\right) \odot \mathcal{L}_{i m g}+w_{s} \mathcal{L}_{\text {smooth}}+\left[w_{g} \mathcal{L}_{\text {geo}}\right]+\left[w_{p} \mathcal{L}_{\text {pose}}\right] Ltotal=M(PM)⊙Limg+wsLsmooth+[wgLgeo]+[wpLpose]
网络结构
输入相邻帧,输出相对位姿预测和深度图估计:
里程计性能评估: