知识预备
• 问题描述
给定两个点云
X
=
{
x
1
,
.
.
.
,
x
i
,
.
.
.
,
x
N
}
⊂
R
3
X = \lbrace x_1, ..., x_i, ..., x_N\rbrace \subset R^3
X={x1,...,xi,...,xN}⊂R3和
Y
=
{
y
1
,
.
.
.
,
y
i
,
.
.
.
,
y
M
}
⊂
R
3
Y = \lbrace y_1, ..., y_i, ..., y_M\rbrace \subset R^3
Y={y1,...,yi,...,yM}⊂R3, 刚性配准(rigid registration)的任务是找到一个旋转矩阵
R
X
Y
∈
S
O
(
3
)
R_{XY} \in SO(3)
RXY∈SO(3)和平移矩阵
t
X
Y
∈
R
3
t_{XY} \in R^3
tXY∈R3.
- 点云配准的应用: 机器人, 无人驾驶, 医疗影像, 计算化学等
- 旋转矩阵与群:
- 旋转矩阵: 行列式为1的正交矩阵.
S O ( n ) = { R ∈ R n × n ∣ R R T = I , det ( R ) = 1 } SO(n) = \lbrace R \in \mathbb R^{n \times n } | RR^T = I, \text{det}(R) = 1 \rbrace SO(n)={R∈Rn×n∣RRT=I,det(R)=1}, 对于乘法,属于特殊正交群(Special Orthogonal Group).
• 群: 一种集合加上一种运算的代数结构. 定义如下, 集合记作 A A A, 运算记作, 那么群记作 G = ( A , ⋅ ) G=(A, \cdot) G=(A,⋅). 群要求这个运算满足以下几个条件:- 封闭性: ∀ a 1 , a 2 ∈ A , a 1 ⋅ a 2 ∈ A \forall a_1,a_2 \in A, a_1 \cdot a_2 \in A ∀a1,a2∈A,a1⋅a2∈A
- 结合律: ∀ a 1 , a 2 , a 3 ∈ A , ( a 1 ⋅ a 2 ) ⋅ a 3 = a 1 ⋅ ( a 2 ⋅ a 3 ) \forall a_1, a_2, a_3 \in A, (a_1 \cdot a_2)\cdot a_3 = a_1 \cdot (a_2 \cdot a_3) ∀a1,a2,a3∈A,(a1⋅a2)⋅a3=a1⋅(a2⋅a3)
- 幺元: ∃ a 0 ∈ A , s . t . ∀ a ∈ A , a 0 ⋅ a = a ⋅ a 0 = a \exists a_0 \in A, s.t. \forall a \in A, a_0 \cdot a = a \cdot a_0 = a ∃a0∈A,s.t.∀a∈A,a0⋅a=a⋅a0=a
- 逆:
∀
a
∈
A
,
∃
a
−
1
∈
A
,
s
.
t
.
a
⋅
a
−
1
=
a
0
\forall a \in A, \exists a^{-1} \in A, s.t. a \cdot a^{-1} = a_0
∀a∈A,∃a−1∈A,s.t.a⋅a−1=a0
其中 S E ( 3 ) = { [ R t 0 T 1 ] ∈ R 4 × 4 ∣ R ∈ S O ( 3 ) , t ∈ R 3 } SE(3) = \lbrace \left[ \begin{matrix} R & t \\ 0^T & 1 \end{matrix} \right] \in \mathbb{R}^{4 \times 4} | R \in SO(3), t \in \mathbb{R}^3 \rbrace SE(3)={[R0Tt1]∈R4×4∣R∈SO(3),t∈R3}
,关于乘法,也属于群.
• 李群: 具有连续性质的群
• 整数群这样离散的群没有连续性质, 不是李群.
• SO(n)和SE(n)在实数空间上是连续的, 属于李群.
- 旋转矩阵: 行列式为1的正交矩阵.
ICP算法
-
迭代进行如下操作:
- m ( x i , Y ) = arg min j ∣ ∣ R X Y x i + t X Y − y j ∣ ∣ m(x_i, Y) = \underset {j}{\text{arg min} }||R_{XY}x_i + t_{XY} - y_j|| m(xi,Y)=jarg min∣∣RXYxi+tXY−yj∣∣
-
E
(
R
X
Y
,
t
X
Y
,
m
)
=
1
N
∑
i
=
1
N
∣
∣
R
X
Y
x
i
+
t
X
Y
−
y
m
(
x
i
)
∣
∣
2
E(R_{XY}, t_{XY}, m) = \frac {1}{N} \sum_{i=1}^N||R_{XY}x_i + t_{XY} - y_{m(x_i)}||^2
E(RXY,tXY,m)=N1∑i=1N∣∣RXYxi+tXY−ym(xi)∣∣2
- 当映射关系 m m m确定时, R X Y = V U T , t X Y = − R X Y x ‾ + y ‾ R_{XY} = VU^T, t_{XY} = -R_{XY} \overline x + \overline y RXY=VUT,tXY=−RXYx+y, 参数说明和证明过程如下。
- 其中 x ‾ = 1 N ∑ i = 1 n x i , y ‾ = 1 N ∑ i = 1 n y i \overline x= \frac{1}{N}\sum_{i=1}^n{x_i}, \overline y = \frac{1}{N}\sum_{i=1}^n{y_i} x=N1∑i=1nxi,y=N1∑i=1nyi, 记 v i = y i − y ‾ , u i = x i − x ‾ v_i = y_i - \overline y, u_i = x_i - \overline x vi=yi−y,ui=xi−x, H = ∑ i = 1 N ( u i v i T ) H = \sum_{i=1}^N(u_iv_i^T) H=∑i=1N(uiviT), 对进行SVD分解 H = U Σ V T H = U\Sigma V^T H=UΣVT, 上述 U U U和 V V V是SVD分解得到.
-
SVD 求解ICP算法及其证明[Least-squares fitting of two 3-D point sets]:
-
第一步, 化简
记 x ‾ = 1 N ∑ i = 1 n x i , y ‾ = 1 N ∑ i = 1 n y i \overline x = \frac{1}{N}\sum_{i=1}^n{x_i}, \overline y = \frac{1}{N}\sum_{i=1}^n{y_i} x=N1∑i=1nxi,y=N1∑i=1nyi, 当 m ( x i ) = y i m(x_i) = y_i m(xi)=yi时,E ( R X Y , t X Y ) = 1 N ∑ i = 1 N ∣ ∣ R X Y x i + t X Y − y i ∣ ∣ 2 = 1 N ∑ i = 1 N ∣ ∣ R X Y x i + t X Y − y i − y ‾ + y ‾ − R X Y x ‾ + R X Y x ‾ ∣ ∣ 2 = 1 N ∑ i = 1 N ∣ ∣ ( y ‾ − y i + R X Y ( x i − x ‾ ) ) + ( t X Y + R X Y x ‾ − y ‾ ) ∣ ∣ 2 = 1 N ∑ i = 1 N [ ∣ ∣ y ‾ − y i + R X Y ( x i − x ‾ ) ∣ ∣ 2 + ∣ ∣ t X Y + R X Y x ‾ − y ‾ ∣ ∣ 2 + 2 ( y ‾ − y i + R X Y ( x i − x ‾ ) ) T ( t X Y + R X Y x ‾ − y ‾ ) ] \begin{aligned} E(R_{XY}, t_{XY})&=\frac {1}{N} \sum_{i=1}^N||R_{XY}x_i + t_{XY} - y_i||^2 \\ &=\frac{1}{N}\sum_{i=1}^N||R_{XY}x_i + t_{XY} - y_i - \overline y + \overline y - R_{XY}\overline x + R_{XY} \overline x ||^2 \\ &=\frac{1}{N}\sum_{i=1}^N||(\overline y - y_i + R_{XY}(x_i - \overline x)) + (t_{XY} + R_{XY}\overline x - \overline y)||^2 \\ &=\frac{1}{N}\sum_{i=1}^N[||\overline y - y_i + R_{XY}(x_i - \overline x)||^2 + ||t_{XY} + R_{XY}\overline x - \overline y||^2 + \\ & 2(\overline y - y_i + R_{XY}(x_i - \overline x))^T(t_{XY} + R_{XY}\overline x - \overline y)] \end{aligned} E(RXY,tXY)=N1i=1∑N∣∣RXYxi+tXY−yi∣∣2=N1i=1∑N∣∣RXYxi+tXY−yi−y+y−RXYx+RXYx∣∣2=N1i=1∑N∣∣(y−yi+RXY(xi−x))+(tXY+RXYx−y)∣∣2=N1i=1∑N[∣∣y−yi+RXY(xi−x)∣∣2+∣∣tXY+RXYx−y∣∣2+2(y−yi+RXY(xi−x))T(tXY+RXYx−y)]
其中第三项:
1 N ∑ i = 1 N 2 ( y ‾ − y i + R X Y ( x i − x ‾ ) ) T ( t X Y + R X Y x ‾ − y ‾ ) = 2 N [ ∑ i = 1 N ( y ‾ − y i + R X Y ( x i − x ‾ ) ) ] ( t X Y + R X Y x ‾ − y ‾ ) = 2 N [ n y ‾ − ∑ i = 1 N y i + R X Y ( ∑ i = 1 N x i − n x ‾ ) ] ( t X Y + R X Y X ‾ − y ‾ ) = 1 N ⋅ 0 ⋅ ( t X Y + R X Y X ‾ − y ‾ ) = 0 \begin{aligned} & \frac{1}{N}\sum_{i=1}^N 2(\overline y - y_i + R_{XY}(x_i - \overline x))^T(t_{XY} + R_{XY}\overline x - \overline y) \\ &=\frac{2}{N}[\sum_{i=1}^N(\overline y - y_i + R_{XY}(x_i - \overline x))](t_{XY} + R_{XY}\overline x - \overline y) \\ & = \frac{2}{N}[n\overline y - \sum_{i=1}^Ny_i + R_{XY}(\sum_{i=1}^Nx_i - n\overline x)] (t_{XY} + R_{XY} \overline X - \overline y) \\ &= \frac{1}{N} \cdot 0 \cdot (t_{XY} + R_{XY} \overline X - \overline y) \\ &=0 \end{aligned} N1i=1∑N2(y−yi+RXY(xi−x))T(tXY+RXYx−y)=N2[i=1∑N(y−yi+RXY(xi−x))](tXY+RXYx−y)=N2[ny−i=1∑Nyi+RXY(i=1∑Nxi−nx)](tXY+RXYX−y)=N1⋅0⋅(tXY+RXYX−y)=0
因此, 原优化函数可以化简成
E ( R X Y , t X Y ) = 1 N ∑ i = 1 N [ ∣ ∣ y ‾ − y i + R X Y ( x i − x ‾ ) ∣ ∣ 2 + ∣ ∣ t X Y + R X Y x ‾ − y ‾ ∣ ∣ 2 ] = 1 N ∑ i = 1 N [ ∣ ∣ y i − y ‾ − R X Y ( x i − x ‾ ) ∣ ∣ 2 + ∣ ∣ t X Y + R X Y x ‾ − y ‾ ∣ ∣ 2 ] \begin{aligned} E(R_{XY}, t_{XY})&=\frac{1}{N}\sum_{i=1}^N[||\overline y - y_i + R_{XY}(x_i - \overline x)||^2 + ||t_{XY} + R_{XY}\overline x - \overline y||^2 ] \\ &=\frac{1}{N}\sum_{i=1}^N[||y_i - \overline y - R_{XY}(x_i - \overline x)||^2 + ||t_{XY} + R_{XY}\overline x - \overline y||^2 ] \\ \end{aligned} E(RXY,tXY)=N1i=1∑N[∣∣y−yi+RXY(xi−x)∣∣2+∣∣tXY+RXYx−y∣∣2]=N1i=1∑N[∣∣yi−y−RXY(xi−x)∣∣2+∣∣tXY+RXYx−y∣∣2]
-
第二步, 分析
注意到第一项只包含 R X Y R_{XY} RXY, 因此只需求解 R X Y R_{XY} RXY使得 ∑ i = 1 N ∣ ∣ y i − y ‾ − R X Y ( x i − x ‾ ) ∣ ∣ 2 \sum_{i=1}^N||y_i - \overline y - R_{XY}(x_i - \overline x)||^2 ∑i=1N∣∣yi−y−RXY(xi−x)∣∣2最小即可, t X Y t_{XY} tXY可通过 t X Y = y ‾ − R X Y x ‾ t_{XY} = \overline y - R_{XY}\overline x tXY=y−RXYx求得.考虑去均值坐标, 记 v i = y i − y ‾ , u i = x i − x ‾ , v_i = y_i - \overline y, u_i = x_i - \overline x, vi=yi−y,ui=xi−x,
arg min R X Y ∑ i = 1 N ∣ ∣ y i − y ‾ − R X Y ( x i − x ‾ ) ∣ ∣ 2 = arg min R X Y ∑ i = 1 N ∣ ∣ v i − R X Y u i ∣ ∣ 2 = arg min R X Y ∑ i = 1 N ( v i T v i + u i T R X Y T R X Y u i − 2 v i T R X Y u i ) = arg min R X Y ∑ i = 1 N ( v i T v i + u i T u i − 2 v i T R X Y u i ) = arg min R X Y ∑ i = 1 N ( − v i T R X Y u i ) = arg min R X Y ∑ i = 1 N ( − tr ( R X Y u i v i T ) ) = arg min R X Y − tr ( R X Y ∑ i = 1 N ( u i v i T ) ) \begin{aligned} {\underset {R_{XY}}{\operatorname {arg\,min} }}\sum_{i=1}^N||y_i - \overline y - R_{XY}(x_i - \overline x)||^2 & = {\underset {R_{XY}}{\operatorname {arg\,min} }}\sum_{i=1}^N||v_i - R_{XY}u_i||^2 \\ &= {\underset {R_{XY}}{\operatorname {arg\,min} }}\sum_{i=1}^N(v_i^Tv_i + u_i^TR_{XY}^TR_{XY}u_i - 2v_i^TR_{XY}u_i) \\ &= {\underset {R_{XY}}{\operatorname {arg\,min} }} \sum_{i=1}^N(v_i^Tv_i + u_i^Tu_i - 2v_i^TR_{XY}u_i) \\ &= {\underset {R_{XY}}{\operatorname {arg\,min} }} \sum_{i=1}^N(-v_i^TR_{XY}u_i) \\ &= {\underset {R_{XY}}{\operatorname {arg\,min} }} \sum_{i=1}^N(-\text{tr}(R_{XY}u_iv_i^T)) \\ &= {\underset {R_{XY}}{\operatorname {arg\,min} }} -\text{tr}(R_{XY}\sum_{i=1}^N(u_iv_i^T)) \end{aligned} RXYargmini=1∑N∣∣yi−y−RXY(xi−x)∣∣2=RXYargmini=1∑N∣∣vi−RXYui∣∣2=RXYargmini=1∑N(viTvi+uiTRXYTRXYui−2viTRXYui)=RXYargmini=1∑N(viTvi+uiTui−2viTRXYui)=RXYargmini=1∑N(−viTRXYui)=RXYargmini=1∑N(−tr(RXYuiviT))=RXYargmin−tr(RXYi=1∑N(uiviT))记 H = ∑ i = 1 N ( u i v i T ) H = \sum_{i=1}^N(u_iv_i^T) H=∑i=1N(uiviT), 对 H H H进行SVD分解 H = U Σ V T H = U\Sigma V^T H=UΣVT, 其中 U U U, V V V是正交阵
引理(Lemma):
对于任意正定矩阵 A A T AA^T AAT与正交矩阵 B B B, 有 tr ( A A T ) ≥ tr ( B A A T ) \text {tr}(AA^T) \geq \text{tr}(BAA^T) tr(AAT)≥tr(BAAT).借助引理:
tr ( R X Y H ) = tr ( R X Y U Σ V T ) = tr ( R X Y U Σ 1 2 Σ 1 2 V T ) = tr ( R X Y U V T V Σ 1 2 Σ 1 2 V T ) = tr ( R X Y U V T V Σ 1 2 ( V Σ 1 2 ) T ) < = t r ( V Σ 1 2 ( V Σ 1 2 ) T ) [ Derivated from Lemma ] \begin{aligned} \text {tr}(R_{XY}H) &= \text{tr} (R_{XY}U\Sigma V^T) \\ &= \text{tr}(R_{XY}U\Sigma ^{\frac{1}{2}}\Sigma ^{\frac{1}{2}}V^T) \\ &= \text{tr}(R_{XY}UV^TV\Sigma ^{\frac{1}{2}}\Sigma ^{\frac{1}{2}}V^T) \\ & = \text{tr}(R_{XY}UV^TV\Sigma ^{\frac{1}{2}}(V \Sigma ^{\frac{1}{2}})^T) \\ & <= tr(V\Sigma ^{\frac{1}{2}}(V \Sigma ^{\frac{1}{2}})^T) [\text{Derivated from Lemma}] \end{aligned} tr(RXYH)=tr(RXYUΣVT)=tr(RXYUΣ21Σ21VT)=tr(RXYUVTVΣ21Σ21VT)=tr(RXYUVTVΣ21(VΣ21)T)<=tr(VΣ21(VΣ21)T)[Derivated from Lemma]
取等条件 R X Y = V U T R_{XY} = VU^T RXY=VUT
-
-
缺点: 非凸, 局部最优; 对于大点云, 耗时.