zoukankan      html  css  js  c++  java
  • 2D-2D:对极几何 基础矩阵F 本质矩阵E 单应矩阵H

    对极约束

    [oldsymbol{x}_{2}^{T} oldsymbol{F} oldsymbol{x}_{1}=oldsymbol{0} quad hat{oldsymbol{x}}_{2}^{T} oldsymbol{E} hat{oldsymbol{x}}_{1}=mathbf{0} ]

    其中

    [oldsymbol{E}=oldsymbol{K}_{2}^{-T} oldsymbol{F K}_{1} quad hat{oldsymbol{x}}_{1}=oldsymbol{K}_{1}^{-1} oldsymbol{x}_{1} quad hat{oldsymbol{x}}_{2}=oldsymbol{K}_{2}^{-1} oldsymbol{x}_{2} ]


    公式推导

    [oldsymbol{P}_{1}=oldsymbol{K}_{1}[oldsymbol{I}, quad mathbf{0}] quad oldsymbol{P}_{2}=oldsymbol{K}_{2} left[ egin{array}{ll}{oldsymbol{R},} & {oldsymbol{t}}end{array} ight] ]

    [d_{1} x_{1}=K_{1} X quad Rightarrow quad d_{1} K_{1}^{-1} x_{1}=X=d_{1} hat{x}_{1} ]

    [d_{2} oldsymbol{x}_{2}=oldsymbol{K}_{2}(oldsymbol{R} oldsymbol{X}+oldsymbol{t}) Rightarrow quad d_{2} oldsymbol{K}_{2}^{-1} oldsymbol{x}_{2}=oldsymbol{R} oldsymbol{X}+oldsymbol{t}=d_{1} oldsymbol{R} hat{x}_{1}+oldsymbol{t} ]

    [quad d_{2}[t]_{ imes} hat{x}_{2}=d_{1}[t]_{ imes} R hat{x}_{1}+[t]_{ imes} t ]

    [quad d_{2} hat{x}_{2}^{T}[t]_{ imes} hat{x}_{2}=d_{1} hat{x}_{2}^{T}[t]_{ imes} R hat{x}_{1}=0 ]

    [hat{oldsymbol{x}}_{2}^{T}[oldsymbol{t}]_{ imes} oldsymbol{R} hat{x}_{1}=hat{oldsymbol{x}}_{2}^{T} oldsymbol{E} hat{x}_{1}=0 ]

    [oldsymbol{E}=[oldsymbol{t}]_{ imes} oldsymbol{R} ]

    [oldsymbol{x}_{2}^{T} oldsymbol{K}_{2}^{-T}[oldsymbol{t}]_{ imes} oldsymbol{R} oldsymbol{K}_{1}^{-1} oldsymbol{x}_{1}=oldsymbol{x}_{2}^{T} oldsymbol{F} oldsymbol{x}_{1}=0 ]

    [oldsymbol{F}=oldsymbol{K}_{2}^{-T} oldsymbol{E} oldsymbol{K}_{1}^{-1} ]


    基础矩阵性质

    • 3x3的矩阵,秩为2

    • 具有7个自由度

    • 奇异值为(left[ egin{array}{lll}{sigma_{1},} & {sigma_{2},} & {0}end{array} ight]^{T})

    • 极线约束(l_{1}=oldsymbol{x}_{2}^{T} oldsymbol{F}, quad l_{2}=oldsymbol{F} oldsymbol{x}_{1}, quad oldsymbol{x}_{2}^{T} oldsymbol{F} oldsymbol{x}_{1}=0)


    基础矩阵求解方法

    直接线性变换法 (8点法+最小二乘法)

    对于一对匹配点

    [oldsymbol{x}_{1}=left[ egin{array}{ll}{u_{1},} & {v_{1},} & {1}end{array} ight]^{mathrm{T}}, quad oldsymbol{x}_{2}=left[ egin{array}{ll}{u_{2},} & {v_{2},} & {1}end{array} ight]^{mathrm{T}} ]

    根据对极约束

    [oldsymbol{x}_{2}^{T} oldsymbol{F} oldsymbol{x}_{1}=oldsymbol{0} ]

    [left( egin{array}{lll}{u_{1}} & {v_{1}} & {1}end{array} ight) left[ egin{array}{ccc}{F_{11}} & {F_{12}} & {F_{13}} \ {F_{21}} & {F_{22}} & {F_{23}} \ {F_{31}} & {F_{32}} & {F_{33}}end{array} ight] left( egin{array}{c}{u_{2}} \ {v_{2}} \ {1}end{array} ight)=0 ]

    [oldsymbol{f}=left[ egin{array}{lll}{F_{11},} & {F_{12},} & {F_{13}}, quad end{array} ight.F_{21}, quad F_{22}, quad F_{23}, quad F_{31}, quad F_{32}, quad F_{33} ]^{T} ]

    有约束

    [left[ egin{array}{llllll}{u_{1} u_{1},} & {u_{1} v_{2},} & {u_{1},} & {v_{2} u_{1},} & {v_{1} v_{2},} & {v_{1},} & {u_{2},} & {v_{2},} & {1}end{array} ight] f=0 ]

    当有n对匹配点时

    [A=left( egin{array}{ccccccccc} {egin{array}{l} {u_{1}^{(1)} u_{1}^{(1)}, quad u_{1}^{(1)} v_{2}^{(1)}, quad u_{1}^{(1)}, quad v_{1}^{(1)} u_{2}^{(1)}, quad v_{1}^{(1)} v_{2}^{(1)}, quad v_{1}^{(1)}, quad u_{2}^{(1)}, quad v_{2}^{(1)}, quad 1} \ {u_{1}^{(2)} u_{1}^{(2)}, quad u_{1}^{(2)} v_{2}^{(2)}, quad u_{1}^{(2)}, quad v_{1}^{(2)} u_{2}^{(2)}, quad v_{1}^{(2)} v_{2}^{(2)}, quad v_{1}^{(2)}, quad u_{2}^{(2)}, quad v_{2}^{(2)}, quad 1} \ quad vdots quadquad quad vdots quadquad quad vdotsquad quadquad vdots quad quadquad vdots quadquad vdotsquad quad vdotsquadquad quad vdotsquadquad vdots \u_{1}^{(n)} u_{1}^{(n)}, quad u_{1}^{(n)} v_{2}^{(n)}, quad u_{1}^{(n)}, quad v_{1}^{(n)} u_{2}^{(n)}, quad v_{1}^{(n)} v_{2}^{(n)}, quad v_{1}^{(n)}, quad u_{2}^{(n)}, quad v_{2}^{(n)}, quad 1 end{array}} end{array} ight). ]

    [A f=0 ]

    • 要保证有唯一解至少需要8对匹配点
    • n = 8时,若A非奇异,则有唯一解,称为8点法
    • n >= 8时,可用最小二乘法求解( $ A^TA $ 的最小特征值对应的特征向量即为最优解)

    奇异值约束

    直接线性变化法无法保证基础矩阵的奇异值约束—有两个非0奇异值
    根据奇异值约束对矩阵进行重构

    [min |oldsymbol{F}-hat{oldsymbol{F}}|, quad ext { wrt. } operatorname{svd}(oldsymbol{F})=left[ egin{array}{lll}{sigma_{1},} & {sigma_{2},} & {0}end{array} ight] ]

    对得到的基础矩阵进行奇异值分解

    [hat{oldsymbol{F}}=oldsymbol{U S V}^{T} quad ext { with } S=operatorname{diag}left(sigma_{1}, sigma_{2}, sigma_{3} ight) ]

    利用奇异值约束对基础矩阵进行重构

    [oldsymbol{F}=oldsymbol{U} operatorname{diag}left(sigma_{1}, quad sigma_{2}, quad 0 ight) oldsymbol{V}^{T} ]


    RANSAC-估计基础矩阵

    算法流程
    1. 随机采样8对匹配点
    2. 8点法求解基础矩阵
    3. 奇异值约束获取基础矩阵
    4. 计算误差,并统计内点个数
    5. 重复上述过程,选择内点数最多的结果
    6. 对所有内点执行2,3,重新计算
    内点判断标准-Sampson Distance

    [egin{array}{c}{dleft(oldsymbol{x}_{1}, oldsymbol{x}_{2} ight)=frac{left(oldsymbol{x}_{2}^{T} oldsymbol{F} oldsymbol{x}_{1} ight)^{2}}{left(oldsymbol{F} x_{1} ight)_{x}^{2}+left(oldsymbol{F} x_{1} ight)_{x}^{2}+left(oldsymbol{x}_{2}^{T} oldsymbol{F} ight)_{x}^{2}+left(oldsymbol{x}_{2}^{T} oldsymbol{F} ight)_{y}^{2}}} \ {dleft(oldsymbol{x}_{1}, oldsymbol{x}_{2} ight)< au}end{array} ]


    RANSAC-采样次数的计算

    N - 样本点个数
    K - 求解模型需要最少的点的个数
    p - 表示内点的概率

    [K 个点都是内点概率 p^{K} ]

    [K个至少有一个外点(采样失败)的概率1-p^{K} ]

    [M次采样全部失败的概率left(1-p^{K} ight)^{M} ]

    [M次采样至少有1次成功的概率 quad z=1-left(1-p^{K} ight)^{M} ]

    [采样次数 quad M=frac{log (1-z)}{log left(1-p^{K} ight)} ]

    [计算p=0.9, quad K=8 , 时,想要采样 成功率达到 z geq 0.99, 所需要的采样 次数 M ]


    本征矩阵E性质

    1. 3x3的矩阵,秩为2

    2. 具有5个自由度

    3. 奇异值为(left[ egin{array}{lll}{sigma,} & {sigma,} & {0}end{array} ight]^{T})


    求解本征矩阵

    [先求解基础矩阵F ]

    [widehat{oldsymbol{E}}=oldsymbol{K}_{2}^{T} oldsymbol{F} oldsymbol{K}_{1} ]

    [widehat{oldsymbol{E}}=oldsymbol{U} operatorname{diag}left(sigma_{1}, quad sigma_{2}, quad 0 ight) oldsymbol{V}^{T} ]

    [oldsymbol{E}=oldsymbol{U} operatorname{diag}left(frac{sigma_{1}+sigma_{2}}{2}, quad frac{sigma_{1}+sigma_{2}}{2}, quad 0 ight) oldsymbol{V}^{T} ]


    相机姿态的恢复

    求解Rt

    [oldsymbol{E}=oldsymbol{U} Sigma oldsymbol{V}^{T}, oldsymbol{Sigma}=operatorname{diag}(sigma, quad sigma, quad 0) ]

    [t_{1}=U( :, 2) quad R_{1}=U R_{Z}left(frac{pi}{2} ight) V^{T} ]

    [oldsymbol{t}_{2}=-oldsymbol{U}( :, oldsymbol{2}) quad oldsymbol{R}_{2}=oldsymbol{U} oldsymbol{R}_{mathrm{Z}}^{T}left(frac{pi}{2} ight) oldsymbol{V}^{T} ]

    [oldsymbol{R}_{z}left(frac{pi}{2} ight)=left( egin{array}{ccc}{0,} & {-1,} & {0} \ {1,} & {0,} & {0} \ {0,} & {0,} & {1}end{array} ight), oldsymbol{R}_{z}^{T}left(frac{pi}{2} ight)=left( egin{array}{ccc}{0,} & {1,} & {0} \ {-1,} & {0,} & {0} \ {0,} & {0,} & {1}end{array} ight) ]

    [共有4种情况 left(oldsymbol{R}_{1}, oldsymbol{t}_{1} ight),left(oldsymbol{R}_{1}, oldsymbol{t}_{2} ight),left(oldsymbol{R}_{2}, oldsymbol{t}_{1} ight),left(oldsymbol{R}_{2}, oldsymbol{t}_{2} ight) ]

    选择正确的Rt

    相机的世界坐标

    [oldsymbol{O}_{1}=-oldsymbol{R}^{T} oldsymbol{t}=0, quad oldsymbol{O}_{2}=-oldsymbol{R}^{T} oldsymbol{t} ]

    相机的世界坐标中的朝向

    [d_{1}=left[ egin{array}{lll}{0,} & {0} & {1}end{array} ight]^{T} ]

    [oldsymbol{d}_{2}=left[ egin{array}{cccc}{oldsymbol{r}_{1}^{T}} & {oldsymbol{r}_{2}^{T}} & {oldsymbol{r}_{3}^{T}} & {-oldsymbol{R}^{T} oldsymbol{t}}end{array} ight]left[ egin{array}{l}{0} \ {0} \ {1} \ {0}end{array} ight]=r_{3}^{T} ]

    [oldsymbol{R}=left[ egin{array}{c}{oldsymbol{r}_{1}} \ {oldsymbol{r}_{2}} \ {oldsymbol{r}_{3}}end{array} ight] quad oldsymbol{R}^{T}=left[ egin{array}{ccc}{oldsymbol{r}_{1}^{T}} & {oldsymbol{r}_{2}^{T}} & {oldsymbol{r}_{3}^{T}}end{array} ight] ]

    利用相机姿态和匹配点进行三角量测得到三维点P

    P需满足同时位于两个相机的前方:

    方法1:

    [egin{array}{l}{left(oldsymbol{P}-oldsymbol{O}_{1} ight)^{T} oldsymbol{d}_{1}>0} \ {left(oldsymbol{P}-oldsymbol{O}_{2} ight)^{T} oldsymbol{d}_{1}>0}end{array} ]

    方法2:

    [left[ egin{array}{l}{x_{c}} \ {y_{c}} \ {z_{c}}end{array} ight]=oldsymbol{R P}+oldsymbol{t}, quad Z_{c}>0 对两个相机成立 ]


    单应矩阵H

    即单应矩阵有两种情况:

    1.空间点位于平面
    2.相机纯旋转

    空间中特征点位于一平面上

    [oldsymbol{n}^{T} oldsymbol{X}+d=0 quad Rightarrow quad-frac{oldsymbol{n}^{T} oldsymbol{X}}{d}=1 ]

    [egin{equation} egin{aligned} oldsymbol{x}_{2} &= oldsymbol{K}_{2}(oldsymbol{R} oldsymbol{X}+oldsymbol{t})\ &=oldsymbol{K}_{2}left(oldsymbol{R} oldsymbol{X}+oldsymbol{t} cdotleft(-frac{oldsymbol{n}^{T} oldsymbol{X}}{d} ight) ight)\ &=oldsymbol{K}_{2}left(oldsymbol{R}-frac{t oldsymbol{n}^{T}}{d} ight) oldsymbol{X} \ &=oldsymbol{K}_{2}left(oldsymbol{R}-frac{t oldsymbol{n}^{T}}{d} ight) oldsymbol{K}_{1}^{-1} oldsymbol{x}_{1} end{aligned} end{equation} ]

    [oldsymbol{x}_{2}=oldsymbol{H} oldsymbol{x}_{1}, quad oldsymbol{H}=oldsymbol{K}_{2}left(oldsymbol{R}-frac{oldsymbol{t} oldsymbol{n}^{T}}{d} ight) oldsymbol{K}_{1}^{-1} ]

    单应矩阵是满秩的

    [x_{1}=H^{-1} x_{2} ]

    t = 0时,对应纯旋转

    [oldsymbol{H}=oldsymbol{K}_{2} oldsymbol{R} oldsymbol{K}_{1}^{-1} ]


    单应矩阵求法

    直接线性变换法

    [left( egin{array}{c}{u_{2}} \ {v_{2}} \ {1}end{array} ight)=left[ egin{array}{lll}{H_{11}} & {H_{12}} & {H_{13}} \ {H_{21}} & {H_{22}} & {H_{23}} \ {H_{31}} & {H_{32}} & {H_{33}}end{array} ight] left( egin{array}{l}{u_{1}} \ {v_{1}} \ {1}end{array} ight) ]

    [egin{aligned} u_{2} &=frac{H_{11} u_{1}+H_{12} v_{1}+H_{13}}{H_{31} u_{1}+H_{32} v_{1}+H_{33}} \ v_{2}& = frac{H_{21} u_{1}+H_{22} v_{1}+H_{23}}{H_{31} u_{1}+H_{32} v_{1}+H_{33}} end{aligned} ]

    8个自由度,每对点有两个约束

    [H_{11} u_{1}+H_{12} v_{1}+H_{13}-H_{31} u_{1} u_{2}-H_{32} u_{2} v_{1}-H_{33} u_{2}=0\ H_{21} u_{1}+H_{22} v_{1}+H_{23}-H_{31} u_{1} v_{2}-H_{32} v_{1} v_{2}-H_{33} v_{2}=0 ]

    (H_{33}=1)总共需要4对特征点

    [A=left( egin{array}{c} u_{1}^{(1)}, quad v_{1}^{(1)}, quad 1, quad 0, quad 0, quad 0, quad-u_{1}^{(1)} u_{2}^{(1)}, quad-u_{2}^{(1)} v_{1}^{(1)} \ 0, quad 0, quad 0, quad u_{1}^{(1)}, quad v_{1}^{(1)}, quad 1, quad-u_{1}^{(1)} v_{2}^{(1)}, quad-v_{1}^{(1)} v_{2}^{(1)}\ {vdots} \ u_{1}^{(4)}, quad v_{1}^{(4)}, quad 1, quad 0, quad 0, quad 0, quad-u_{1}^{(4)} u_{2}^{(4)}, quad-u_{2}^{(4)} v_{1}^{(4)} \ 0, quad 0, quad 0, quad u_{1}^{(1)}, quad v_{1}^{(1)}, quad 1, quad-u_{1}^{(4)} v_{2}^{(4)}, quad-v_{1}^{(4)} v_{2}^{(4)}end{array} ight) left( egin{array}{c}{F_{11}} \ {F_{12}} \ {F_{13}} \ {F_{21}} \ {F_{21}} \ {F_{22}} \ {F_{33}} \ {F_{31}} \ {F_{32}}end{array} ight) =left( egin{array}{c}{u_{2}^{(1)}} \ {v_{2}^{(1)}} \ {u_{2}^{(2)}} \ {v_{2}^{(2)}} \ {v_{2}^{(2)}} \ {u_{2}^{(3)}} \ {v_{2}^{(4)}} \ {v_{2}^{(4)}} \ {v_{2}^{(4)}}end{array} ight) ]


    RANSAC-估计单应矩阵

    算法流程

    1. 随机采样4对匹配点(left(x_{1}^{(n)}, x_{2}^{(n)} ight))
    2. 8点法求解基础矩阵H
    3. 计算误差,并统计内点个数
    4. 重复上述过程,选择内点数最多的结果
    5. 对所有内点执行3,4,重新计算H

    内点判断标准

    [Eleft(x_{1}, x_{2}, H ight)=dleft(x_{1}, H^{-1} x_{2} ight)^{2}+dleft(x_{2}, H x_{1} ight)^{2} \ Eleft(x_{1}, x_{2}, H ight)< au ]

  • 相关阅读:
    MFC子窗体、父窗体
    私有云计算安全问题不容忽视
    云计算更多的是一种模式而不是技术
    原型模式向量的原型
    企业发票异常分析分离进项与销项
    考试系统框架搭建
    抽象工厂模式人与肤色
    工厂方法模式加密算法
    简单工厂模式女娲造人
    企业发票异常分析导入,清洗
  • 原文地址:https://www.cnblogs.com/narjaja/p/10768179.html
Copyright © 2011-2022 走看看