【原创】VIO/VISLAM中的BA问题详解1
(转载请注明出处)
这几篇笔记打算对Bundle Adjustment问题的数学描述进行深入探讨。主要是对利用非线性最小二乘(Gauss-Newton法和Levenberg-Marquardt法等)对该问题进行迭代求解时,其增量方程的形式进行剖析,分析稀疏BA的由来。
对BA问题采用由特殊(典型视觉BA问题)到一般(general最小二乘问题)再到特殊(VIO中的BA)的顺序进行分析。
本篇首先介绍典型视觉BA问题。
场景如下:假设有3帧图像对应的相机状态\({{\bf{x}}_{ci}}\)(\(i = 1,2,3\)),以及4个地图点坐标\({{\bf{x}}_{pj}}\)(\(j=1,2,3,4\)),先不管某帧图像是否对某个地图点有观测,我们暂时认为所有帧都可能观测到所有地图点,后面再来分析当每帧只观测到部分特征点时的情况(这将带来额外的稀疏性)。
此时,BA问题用数学描述如下$$
\tag{1}\label{1}
\min \mathop {\arg }\limits_{\bf{x}} \sum\limits_{i = 1}^3 {\sum\limits_{j = 1}^4 {\left| {{{\bf{z}}{ij}} - \pmb{\pi} \left( {{{\bf{x}}{ci}},{{\bf{x}}{fj}}} \right)} \right|{{{\pmb{\Omega }}_{ij}}}^2} }
\tag{2}\label{2}
{{\bf{r}}{ij}} = {{\bf{z}}{ij}} - \pmb{\pi} \left( {{{\bf{x}}{ci}},{{\bf{x}}{fj}}} \right)
\tag{3}\label{3}
\begin{array}{l}
\sum\limits_{i = 1}^3 {\sum\limits_{j = 1}^4 {\left| {{{\bf{z}}{ij}} - \pmb{\pi} \left( {{{\bf{x}}{ci}},{{\bf{x}}{fj}}} \right)} \right|{{{\pmb{\Omega }}{ij}}}^2} } \
= \sum\limits^3 {\sum\limits_{j = 1}^4 {\left| {{{\bf{r}}{ij}}} \right|{{{\pmb{\Omega }}_{ij}}}^2} }
\end{array}
\tag{4}\label{4}
\bf{f} = {\bf{f}}\left( {\bf{x}} \right) = {\left[ {\begin{array}{*{20}{c}}
{{\bf{r}}{11}^T}& \cdots &{{\bf{r}}^T}&{ \cdots \cdots }&{{\bf{r}}{31}^T}& \cdots &{{\bf{r}}^T}
\end{array}} \right]^T}
\tag{5}\label{5}
{\pmb{\Omega }} = \left[ {\begin{array}{*{20}{c}}
{{{\pmb{\Omega }}{11}}}&{\bf{0}}&{}& \cdots &{}&{}&{\bf{0}}\
{\bf{0}}& \ddots &{}&{}&{}&{}&{}\
{}&{}&{{{\pmb{\Omega }}{14}}}&{}&{}&{}&{}\
\vdots &{}&{}& \ddots &{}&{}& \vdots \
{}&{}&{}&{}&{{{\pmb{\Omega }}{31}}}&{}&{}\
{}&{}&{}&{}&{}& \ddots &{\bf{0}}\
{\bf{0}}&{}&{}& \cdots &{}&{\bf{0}}&{{{\pmb{\Omega }}{34}}}
\end{array}} \right]
\tag{6}\label{6}
\begin{array}{l}
\sum\limits_{i = 1}^3 {\sum\limits_{j = 1}^4 {\left| {{{\bf{r}}{ij}}} \right|{{{\pmb{\Omega }}{ij}}}^2} } \
= \sum\limits^3 {\sum\limits_{j = 1}^4 {{\bf{r}}{ij}^T{{\pmb{\Omega }}{ij}}{{\bf{r}}{ij}}} } \
= {{\bf{f}}^T}{\pmb{\Omega}}{\bf{f}}\
= \left| {\bf{f}} \right|{\pmb{\Omega }}^2
\end{array}
\tag{7}\label{7}
\min \mathop {\arg }\limits_{\bf{x}} \left| {{\bf{f}}\left( {\bf{x}} \right)} \right|_{\pmb{\Omega }}^2
\tag{8}\label{8}
\tag{9}\label{9}
\begin{array}{l}
{\bf{f}}\left( {{{\bf{x}}^ + }} \right)\
= {\bf{f}}\left( {{{\bf{x}}^ - } \oplus \delta {\bf{x}}} \right)\
\approx {\bf{f}}\left( {{{\bf{x}}^ - }} \right) + {\bf{J}}\delta {\bf{x}}
\end{array}
\tag{10}\label{10}
\begin{array}{l}
{\left( {{\bf{e}} + {\bf{J}}\delta {\bf{x}}} \right)^T}{\pmb{\Omega }}\left( {{\bf{e}} + {\bf{J}}\delta {\bf{x}}} \right)\
= {{\bf{e}}^T}{\pmb{\Omega}\bf{e}} + 2{{\bf{e}}^T}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\bf{A}}{34}}}&{\bf{0}}&{\bf{0}}&{\bf{0}}&{{{\bf{B}}{34}}}
\end{array}} \right]
\tag{13}\label{13}
\tag{14}\label{14}
{\bf{H}} = {{\bf{J}}^T}{\pmb{\Omega}\bf{J}} = \left[ {\begin{array}{*{20}{c}}
{\sum\limits_{j = 1}^4 {{\bf{A}}{1j}^T{{\pmb{\Omega }}{1j}}{{\bf{A}}{1j}}} }&{\bf{0}}&{\bf{0}}&{{\bf{A}}^T{{\pmb{\Omega }}{11}}{{\bf{B}}{11}}}&{{\bf{A}}{12}^T{{\pmb{\Omega }}{12}}{{\bf{B}}{12}}}&{{\bf{A}}^T{{\pmb{\Omega }}{13}}{{\bf{B}}{13}}}&{{\bf{A}}{14}^T{{\pmb{\Omega }}{14}}{{\bf{B}}{14}}}\
{\bf{0}}&{\sum\limits^4 {{\bf{A}}{2j}^T{{\pmb{\Omega }}{2j}}{{\bf{A}}{2j}}} }&{\bf{0}}&{{\bf{A}}^T{{\pmb{\Omega }}{21}}{{\bf{B}}{21}}}&{{\bf{A}}{22}^T{{\pmb{\Omega }}{22}}{{\bf{B}}{22}}}&{{\bf{A}}^T{{\pmb{\Omega }}{23}}{{\bf{B}}{23}}}&{{\bf{A}}{24}^T{{\pmb{\Omega }}{24}}{{\bf{B}}{24}}}\
{\bf{0}}&{\bf{0}}&{\sum\limits^4 {{\bf{A}}{3j}^T{{\pmb{\Omega }}{3j}}{{\bf{A}}{3j}}} }&{{\bf{A}}^T{{\pmb{\Omega }}{31}}{{\bf{B}}{31}}}&{{\bf{A}}{32}^T{{\pmb{\Omega }}{32}}{{\bf{B}}{32}}}&{{\bf{A}}^T{{\pmb{\Omega }}{33}}{{\bf{B}}{33}}}&{{\bf{A}}{34}^T{{\pmb{\Omega }}{34}}{{\bf{B}}{34}}}\
{{\bf{B}}^T{{\pmb{\Omega }}{11}}{{\bf{A}}{11}}}&{{\bf{B}}{21}^T{{\pmb{\Omega }}{21}}{{\bf{A}}{21}}}&{{\bf{B}}^T{{\pmb{\Omega }}{31}}{{\bf{A}}{31}}}&{\sum\limits_{i = 1}^3 {{\bf{B}}{i1}^T{{\pmb{\Omega }}{i1}}{{\bf{B}}{i1}}} }&{\bf{0}}&{\bf{0}}&{\bf{0}}\
{{\bf{B}}^T{{\pmb{\Omega }}{12}}{{\bf{A}}{12}}}&{{\bf{B}}{22}^T{{\pmb{\Omega }}{22}}{{\bf{A}}{22}}}&{{\bf{B}}^T{{\pmb{\Omega }}{32}}{{\bf{A}}{32}}}&{\bf{0}}&{\sum\limits_{i = 1}^3 {{\bf{B}}{i2}^T{{\pmb{\Omega }}{i2}}{{\bf{B}}{i2}}} }&{\bf{0}}&{\bf{0}}\
{{\bf{B}}^T{{\pmb{\Omega }}{13}}{{\bf{A}}{13}}}&{{\bf{B}}{23}^T{{\pmb{\Omega }}{23}}{{\bf{A}}{23}}}&{{\bf{B}}^T{{\pmb{\Omega }}{33}}{{\bf{A}}{33}}}&{\bf{0}}&{\bf{0}}&{\sum\limits_{i = 1}^3 {{\bf{B}}{i3}^T{{\pmb{\Omega }}{i3}}{{\bf{B}}{i3}}} }&{\bf{0}}\
{{\bf{B}}^T{{\pmb{\Omega }}{14}}{{\bf{A}}{14}}}&{{\bf{B}}{24}^T{{\pmb{\Omega }}{24}}{{\bf{A}}{24}}}&{{\bf{B}}^T{{\pmb{\Omega }}{34}}{{\bf{A}}{34}}}&{\bf{0}}&{\bf{0}}&{\bf{0}}&{\sum\limits_{i = 1}^3 {{\bf{B}}{i4}^T{{\pmb{\Omega }}{i4}}{{\bf{B}}_{i4}}} }
\end{array}} \right]
\tag{15}\label{15}
{\bf{d}} = \left[ {\begin{array}{*{20}{c}}
{\sum\limits_{j = 1}^4 {{\bf{A}}{1j}^T{{\pmb{\Omega }}{1j}}{\bf{r}}{1j}^ - } }\
{\sum\limits^4 {{\bf{A}}{2j}^T{{\pmb{\Omega }}{2j}}{\bf{r}}{2j}^ - } }\
{\sum\limits^4 {{\bf{A}}{3j}^T{{\pmb{\Omega }}{3j}}{\bf{r}}{3j}^ - } }\
{\sum\limits^3 {{\bf{B}}{i1}^T{{\pmb{\Omega }}{i1}}{\bf{r}}{i1}^ - } }\
{\sum\limits^3 {{\bf{B}}{i2}^T{{\pmb{\Omega }}{i2}}{\bf{r}}{i2}^ - } }\
{\sum\limits^3 {{\bf{B}}{i3}^T{{\pmb{\Omega }}{i3}}{\bf{r}}{i3}^ - } }\
{\sum\limits^3 {{\bf{B}}{i4}^T{{\pmb{\Omega }}{i4}}{\bf{r}}_{i4}^ - } }
\end{array}} \right]
\tag{16}\label{16}
\left[ {\begin{array}{{20}{c}}
{\bf{U}}&{\bf{W}}\
{{{\bf{W}}^T}}&{\bf{V}}
\end{array}} \right]\left[ {\begin{array}{{c}}
{\delta {{\bf{x}}_c}}\
{\delta {{\bf{x}}_p}}
\end{array}} \right] = - \left[ {\begin{array}{*{20}{c}}
{\bf{u}}\
{\bf{v}}
\end{array}} \right]
\tag{17}\label{17}
\begin{array}{l}
{\bf{U}} = \left[ {\begin{array}{{20}{c}}
{{{\bf{U}}_1}}&{\bf{0}}&{\bf{0}}\
{\bf{0}}&{{{\bf{U}}_2}}&{\bf{0}}\
{\bf{0}}&{\bf{0}}&{{{\bf{U}}_3}}
\end{array}} \right]\
= \left[ {\begin{array}{{c}}
{\sum\limits_{j = 1}^4 {{\bf{A}}{1j}^T{{\pmb{\Omega }}{1j}}{{\bf{A}}{1j}}} }&{\bf{0}}&{\bf{0}}\
{\bf{0}}&{\sum\limits^4 {{\bf{A}}{2j}^T{{\pmb{\Omega }}{2j}}{{\bf{A}}{2j}}} }&{\bf{0}}\
{\bf{0}}&{\bf{0}}&{\sum\limits^4 {{\bf{A}}{3j}^T{{\pmb{\Omega }}{3j}}{{\bf{A}}_{3j}}} }
\end{array}} \right]
\end{array}
\tag{18}\label{18}
\begin{array}{l}
{\bf{V}} = \left[ {\begin{array}{{20}{c}}
{{{\bf{V}}_1}}&{\bf{0}}&{\bf{0}}&{\bf{0}}\
{\bf{0}}&{{{\bf{V}}_2}}&{\bf{0}}&{\bf{0}}\
{\bf{0}}&{\bf{0}}&{{{\bf{V}}_3}}&{\bf{0}}\
{\bf{0}}&{\bf{0}}&{\bf{0}}&{{{\bf{V}}_4}}
\end{array}} \right]\
= \left[ {\begin{array}{{c}}
{\sum\limits_{i = 1}^3 {{\bf{B}}{i1}^T{{\pmb{\Omega }}{i1}}{{\bf{B}}{i1}}} }&{\bf{0}}&{\bf{0}}&{\bf{0}}\
{\bf{0}}&{\sum\limits^3 {{\bf{B}}{i2}^T{{\pmb{\Omega }}{i2}}{{\bf{B}}{i2}}} }&{\bf{0}}&{\bf{0}}\
{\bf{0}}&{\bf{0}}&{\sum\limits^3 {{\bf{B}}{i3}^T{{\pmb{\Omega }}{i3}}{{\bf{B}}{i3}}} }&{\bf{0}}\
{\bf{0}}&{\bf{0}}&{\bf{0}}&{\sum\limits^3 {{\bf{B}}{i4}^T{{\pmb{\Omega }}{i4}}{{\bf{B}}_{i4}}} }
\end{array}} \right]
\end{array}
\tag{19}\label{19}
\begin{array}{l}
{\bf{W}} = \left[ {\begin{array}{{20}{c}}
{{{\bf{W}}{11}}}&{{{\bf{W}}{12}}}&{{{\bf{W}}{13}}}&{{{\bf{W}}{14}}}\
{{{\bf{W}}{21}}}&{{{\bf{W}}{22}}}&{{{\bf{W}}{23}}}&{{{\bf{W}}{24}}}\
{{{\bf{W}}{31}}}&{{{\bf{W}}{32}}}&{{{\bf{W}}{33}}}&{{{\bf{W}}{34}}}
\end{array}} \right]\
= \left[ {\begin{array}{{c}}
{{\bf{A}}{11}^T{{\pmb{\Omega }}{11}}{{\bf{B}}{11}}}&{{\bf{A}}^T{{\pmb{\Omega }}{12}}{{\bf{B}}{12}}}&{{\bf{A}}{13}^T{{\pmb{\Omega }}{13}}{{\bf{B}}{13}}}&{{\bf{A}}^T{{\pmb{\Omega }}{14}}{{\bf{B}}{14}}}\
{{\bf{A}}{21}^T{{\pmb{\Omega }}{21}}{{\bf{B}}{21}}}&{{\bf{A}}^T{{\pmb{\Omega }}{22}}{{\bf{B}}{22}}}&{{\bf{A}}{23}^T{{\pmb{\Omega }}{23}}{{\bf{B}}{23}}}&{{\bf{A}}^T{{\pmb{\Omega }}{24}}{{\bf{B}}{24}}}\
{{\bf{A}}{31}^T{{\pmb{\Omega }}{31}}{{\bf{B}}{31}}}&{{\bf{A}}^T{{\pmb{\Omega }}{32}}{{\bf{B}}{32}}}&{{\bf{A}}{33}^T{{\pmb{\Omega }}{33}}{{\bf{B}}{33}}}&{{\bf{A}}^T{{\pmb{\Omega }}{34}}{{\bf{B}}{34}}}
\end{array}} \right]
\end{array}
\tag{20}\label{20}
{\bf{u}} = \left[ {\begin{array}{{20}{c}}
{{{\bf{u}}_1}}\
{{{\bf{u}}_2}}\
{{{\bf{u}}_3}}
\end{array}} \right] = \left[ {\begin{array}{{c}}
{\sum\limits_{j = 1}^4 {{\bf{A}}{1j}^T{{\bf{\Omega }}{1j}}{\bf{r}}{1j}^ - } }\
{\sum\limits^4 {{\bf{A}}{2j}^T{{\bf{\Omega }}{2j}}{\bf{r}}{2j}^ - } }\
{\sum\limits^4 {{\bf{A}}{3j}^T{{\bf{\Omega }}{3j}}{\bf{r}}_{3j}^ - } }
\end{array}} \right]
\tag{21}\label{21}
{\bf{v}} = \left[ {\begin{array}{{20}{c}}
{{{\bf{v}}_1}}\
{{{\bf{v}}_2}}\
{{{\bf{v}}_3}}\
{{{\bf{v}}_4}}
\end{array}} \right] = \left[ {\begin{array}{{c}}
{\sum\limits_{i = 1}^3 {{\bf{B}}{i1}^T{{\pmb{\Omega }}{i1}}{\bf{r}}{i1}^ - } }\
{\sum\limits^3 {{\bf{B}}{i2}^T{{\pmb{\Omega }}{i2}}{\bf{r}}{i2}^ - } }\
{\sum\limits^3 {{\bf{B}}{i3}^T{{\pmb{\Omega }}{i3}}{\bf{r}}{i3}^ - } }\
{\sum\limits^3 {{\bf{B}}{i4}^T{{\pmb{\Omega }}{i4}}{\bf{r}}_{i4}^ - } }
\end{array}} \right]
\tag{22}\label{22}
\left[ {\begin{array}{{20}{c}}
{{\bf{U}} - {\bf{W}}{{\bf{V}}^{ - 1}}{{\bf{W}}^T}}&{\bf{0}}\
{{{\bf{W}}^T}}&{\bf{V}}
\end{array}} \right]\left[ {\begin{array}{{c}}
{\delta {{\bf{x}}_c}}\
{\delta {{\bf{x}}_p}}
\end{array}} \right] = - \left[ {\begin{array}{*{20}{c}}
{{\bf{u}} - {\bf{W}}{{\bf{V}}^{ - 1}}{\bf{v}}}\
{\bf{v}}
\end{array}} \right]
\tag{23}\label{23}
\left( {{\bf{U}} - {\bf{W}}{{\bf{V}}^{ - 1}}{{\bf{W}}^T}} \right)\delta {{\bf{x}}_c} = - \left( {{\bf{u}} - {\bf{W}}{{\bf{V}}^{ - 1}}{\bf{v}}} \right)
\tag{24}\label{24}
\begin{array}{l}
{\bf{S}} = {\bf{W}}{{\bf{V}}^{ - 1}}{{\bf{W}}^T}\
= \left[ {\begin{array}{*{20}{c}}
{{{\bf{S}}{11}}}&{{{\bf{S}}{12}}}&{{{\bf{S}}{13}}}\
{{\bf{S}}^T}&{{{\bf{S}}{22}}}&{{{\bf{S}}{23}}}\
{{\bf{S}}{13}T}&{{\bf{S}}_{23}T}&{{{\bf{S}}{33}}}
\end{array}} \right]
\end{array}
\tag{25}\label{25}
{{\bf{S}}{{i_1}{i_2}}} = \sum\limits^4 {{{\bf{W}}_{{i_1}j}}{\bf{V}}j^{ - 1}{\bf{W}}j}^T}
\tag{26}\label{26}
{\bf{s}} = \left[ {\begin{array}{*{20}{c}}
{{{\bf{s}}_1}}\
{{{\bf{s}}_1}}\
{{{\bf{s}}_1}}
\end{array}} \right] = {\bf{W}}{{\bf{V}}^{ - 1}}{\bf{v}}
\tag{27}\label{27}
{{\bf{s}}i} = \sum\limits^4 {{{\bf{W}}_{ij}}{\bf{V}}_j^{ - 1}{{\bf{v}}_j}}
\tag{28}\label{28}