推导 编辑
基础矩阵有许多种推导方式,下面介绍其中一种。
图1 在双相机的拍摄场景中建立一个空间直角坐标系,称为世界坐标系(如图1中蓝色坐标系)。物点就是场景中物体表面上的点,比如说点 P {\displaystyle P} 在世界坐标系中的坐标为 ( X , Y , Z ) ⊤ {\displaystyle (X,Y,Z)^{\top }} 。
相机的光心从物理上讲就是相机镜头组的光学中心。以光心为原点,主光轴为Z轴建立空间直角坐标系,称为相机坐标系(如图1中绿色和红色坐标系)。像平面在相机坐标系中的方程即为z=1,像点就是在物点在像平面上的投影 ,这个投影关系是透视投影 。
用一句话来概括相机的拍摄模型,就是物点、像点、光心三点一线,此模型称为针孔相机模型。在此模型中,世界坐标系到左右相机坐标系的变换是刚性变换,即只包含旋转和平移,因此我们分别用增广矩阵 [ R | t ] {\displaystyle [R|t]} 和 [ R ′ | t ′ ] {\displaystyle [R'|t']} 表示,其中 R {\displaystyle R} 和 R ′ {\displaystyle R'} 是 3 × 3 {\displaystyle 3\times 3} 的旋转矩阵, t {\displaystyle t} 和 t ′ {\displaystyle t'} 为平移向量。令 P ~ {\displaystyle {\widetilde {P}}} 为P的齐次化坐标,那么物点P在左右相机坐标系下的坐标分别为 P c a m ( X C , Y C , Z C ) ⊤ = [ R | t ] P ~ {\displaystyle P_{cam}(X_{C},Y_{C},Z_{C})^{\top }=[R|t]{\widetilde {P}}} 和 P c a m ′ ( X C ′ , Y C ′ , Z C ′ ) ⊤ = [ R ′ | t ′ ] P ~ {\displaystyle P'_{cam}(X_{C'},Y_{C'},Z_{C'})^{\top }=[R'|t']{\widetilde {P}}} 。
图2 以一台相机为例,如图2所示, C {\displaystyle C} 为相机光心, Z {\displaystyle Z} 轴为主轴。物点在相机坐标系下的坐标 P ~ {\displaystyle {\widetilde {P}}} 和以相片左下角为原点的像点坐标 p {\displaystyle p} 有如下关系:
x = ( f x X C Z C + x 0 , ) ⊤ {\displaystyle x=\left({\frac {f_{x}X_{C}}{Z_{C}}}+x_{0},\right)^{\top }} 和 y = ( f y Y C Z C + y 0 , ) ⊤ {\displaystyle y=\left({\frac {f_{y}Y_{C}}{Z_{C}}}+y_{0},\right)^{\top }} 式中 ( x 0 , y 0 , f ) {\displaystyle (x_{0},y_{0},f)} 为像主点在相机坐标系下的坐标。
设两相机内参数矩阵同为:
K = [ f x 0 p c x 0 f y p c y 0 0 1 ] , {\displaystyle K=\left[{\begin{array}{ccc}f_{x}&0&{p_{c}}_{x}\\0&f_{y}&{p_{c}}_{y}\\0&0&1\end{array}}\right],} 那么物点与像点之间的关系为:
p = 1 Z C K P c a m = 1 Z C K [ R | t ] P , {\displaystyle p={\frac {1}{Z_{C}}}KP_{cam}={\frac {1}{Z_{C}}}K[R|t]P,} p ′ = 1 Z C K P c a m ′ = 1 Z C K [ R ′ | t ′ ] P , {\displaystyle p'={\frac {1}{Z_{C}}}KP'_{cam}={\frac {1}{Z_{C}}}K[R'|t']P,} 将 P = [ R | t ] + P c a m = Z C ′ K [ R | t ] + p {\displaystyle P=[R|t]^{+}P_{cam}=Z'_{C}K[R|t]^{+}p} 代入上式,并令 H π = K [ R ′ | t ′ ] K [ R | t ] + {\displaystyle H_{\pi }=K[R'|t']K[R|t]^{+}} ,得:
p ′ = Z C ′ Z C H π p {\displaystyle p'={\frac {Z'_{C}}{Z_{C}}}H_{\pi }p} 由于物点、像点、光心三点一线,那么物点、一对同名点和2个光心这5个点一定处于同一个平面上,我们将这个平面称为𝜋平面。𝜋平面和像平面的交线称为极线 l ′ {\displaystyle l'} 。显然,左片上的每一个像点 p {\displaystyle p} 对应于右片上的一条极线 l ′ {\displaystyle l'} ,且 p ′ {\displaystyle p'} 一定在 l ′ {\displaystyle l'} 上。两个相机光心的连线与右片像平面的交点称为极点,用 e ′ {\displaystyle e'} 表示。
在右片像平面内,极线 l ′ {\displaystyle l'} 的方程可以表示为 A x + B y + C = 0 {\displaystyle Ax+By+C=0} 。这个平面直线方程的一般式可以视为:
( A , B , C ) ⊤ ⋅ ( x , y , 1 ) ⊤ = 0 {\displaystyle (A,B,C)^{\top }\cdot (x,y,1)^{\top }=0} 因此,我们可以用一个三维向量 ( A , B , C ) {\displaystyle (A,B,C)} 来表示极线 l ′ {\displaystyle l'} ,并且 l ′ {\displaystyle l'} 的方程可以简单的由 e ′ {\displaystyle e'} 坐标向量与 p ′ {\displaystyle p'} 坐标向量做向量积得到,即 l ′ : e ′ × p ′ = [ e ′ ] × p ′ {\displaystyle l':e'\times p'=[e']_{\times }p'} 。其中
[ e ′ ] × = [ 0 − 1 y 0 1 0 − x 0 − y 0 x 0 0 ] , {\displaystyle [e']_{\times }=\left[{\begin{array}{ccc}0&-1&y_{0}\\1&0&-x_{0}\\-y_{0}&x_{0}&0\end{array}}\right],} 令 [ e ′ ] x {\displaystyle [e']x} 表示向量积的矩阵形式,那么再将同名点之间的变换关系代入,得到极线的方程为: l ′ : Z C ′ Z C [ e ′ ] × H π p {\displaystyle l':{\frac {Z'_{C}}{Z_{C}}}[e']_{\times }H_{\pi }p}
因为 p ′ {\displaystyle p'} 在 l ′ {\displaystyle l'} 上,所以显然有:
p ′ l ′ = p ′ [ e ′ ] × H π p = 0 {\displaystyle p'l'=p'[e']_{\times }H_{\pi }p=0} 令 F = [ e ′ ] × H π {\displaystyle \mathrm {F} =[e']_{\times }H_{\pi }} ,即得到:
p ′ ⊤ F p = 0 {\displaystyle p'^{\top }\mathrm {F} p=0} 根据立体像对估算基础矩阵 编辑 在三维重建技术中的应用 编辑 参考文献 编辑
^ Q. T. Luong. Matrice fondamentale et auto-calibration en vision par ordinateur. PhD Thesis, University of Paris, Orsay. 1992. ^ Olivier D. Faugeras. What can be seen in three dimensions with an uncalibrated stereo rig?. Proceedings of European Conference on Computer Vision. 1992. 外部链接 编辑