摄像机标定:求解摄像机内、外参数矩阵 K [R T];
因为摄像机内外参数矩阵描述了三维世界到二维像素的映射关系;
- 摄像机内外参数共同构成了投影矩阵,投影矩阵共有11个未知量;
- 每对点可以列出两个方程,因此,最少需要6对对应点;
- 实际操作中通常使用多于6对点来获得更加鲁棒的结果;
- 方程个数 2 n 2n 2n 个,且 n > 6 n > 6 n>6;
- 未知参数11个;
- 这是一个超定齐次线性方程组;
M = K [ R T ] = [ K R K T ] = [ A b ] M=K[R \quad T]=[KR \quad KT]=[A \quad b] M=K[RT]=[KRKT]=[Ab]
考虑投影矩阵M求解时,假定 ∣ ∣ m ∣ ∣ = 1 ||m||=1 ∣∣m∣∣=1,因此在M前面乘了一个 ρ \rho ρ
从上式第三行可得:
∵ ρ a 3 T = r 3 T a n d ∣ r 3 ∣ = 1 ∴ ∣ ρ ∣ ∣ a 3 ∣ = 1 \begin{aligned} \because \quad &\rho a_3^T = r_3^T \quad and \quad |r_3|=1 \\ \therefore \quad & |\rho||a_3|=1 \\ \end{aligned} ∵∴ρa3T=r3Tand∣r3∣=1∣ρ∣∣a3∣=1
∴ ρ = ± 1 ∣ a 3 ∣ \therefore \quad \rho=\frac{\pm 1}{|a_3|} ∴ρ=∣a3∣±1
∵ r 1 ⋅ r 3 = 0 r 2 ⋅ r 3 = 0 r 3 ⋅ r 3 = 1 \begin{aligned} \because \quad & r_1 \cdot r_3=0 \\ \quad \quad & r_2 \cdot r_3=0 \\ \quad \quad & r_3 \cdot r_3=1 \end{aligned} ∵r1⋅r3=0r2⋅r3=0r3⋅r3=1
∴ ρ a 1 T ⋅ ρ a 3 T = ( α r 1 T − α c o t θ r 2 T + u 0 R 3 T ) ⋅ r 3 T = 0 − 0 + u 0 ρ a 2 T ⋅ ρ a 3 T = ( β s i n θ r 2 T + v 0 r 3 T ) ⋅ r 3 T = 0 + v 0 \begin{aligned} \therefore \quad & \rho a_1^T \cdot \rho a_3^T \\ & =(\alpha r_1^T-\alpha cot \theta r_2^T+u_0 R_3^T) \cdot r_3^T\\ & =0-0+u_0\\\\ & \rho a_2^T \cdot \rho a_3^T \\ & =(\frac{\beta}{sin \theta}r_2^T+v_0r_3^T) \cdot r_3^T\\ & =0+v_0 \end{aligned} ∴ρa1T⋅ρa3T=(αr1T−αcotθr2T+u0R3T)⋅r3T=0−0+u0ρa2T⋅ρa3T=(sinθβr2T+v0r3T)⋅r3T=0+v0
∴ u 0 = ρ 2 ( a 1 ⋅ a 3 ) v 0 = ρ 2 ( a 2 ⋅ a 3 ) \begin{aligned} \therefore \quad & u_0=\rho^2(a_1 \cdot a_3)\\ & v_0=\rho^2(a_2 \cdot a_3) \end{aligned} ∴u0=ρ2(a1⋅a3)v0=ρ2(a2⋅a3)
∵ r 1 × r 2 = r 3 r 1 × r 3 = r 2 r 3 × r 3 = 0 ∣ a ⃗ ∣ = a ⃗ T ⋅ a ⃗ c o t θ = c o s θ s i n θ s i n 2 θ + c o s 2 θ = 1 \begin{aligned} \because \quad & r_1 \times r_2=r_3 \\ & r_1 \times r_3=r_2 \\ & r_3 \times r_3=0\\ & |\vec a|=\sqrt{\vec a^T \cdot \vec a} \\ & cot \theta = \frac{cos \theta}{sin \theta}\\ & sin^2 \theta + cos^2 \theta=1\\ \end{aligned} ∵r1×r2=r3r1×r3=r2r3×r3=0∣a∣=aT⋅acotθ=sinθcosθsin2θ+cos2θ=1
∴ ρ 2 ( a 1 × a 3 ) = ( α r 1 T − α c o t θ r 2 T + u 0 R 3 T ) × r 3 T = α r 2 − α c o t θ r 1 ρ 2 ( a 2 × a 3 ) = ( β s i n θ r 2 T + v 0 r 3 T ) × r 3 T = β s i n θ r 1 \begin{aligned} \therefore \quad \rho^2 (a_1 \times a_3) & = (\alpha r_1^T-\alpha cot \theta r_2^T+u_0 R_3^T) \times r_3^T\\ &=\alpha r_2 - \alpha cot \theta r_1 \\ \rho^2 (a_2 \times a_3) & = (\frac{\beta}{sin \theta}r_2^T+v_0r_3^T) \times r_3^T\\ &=\frac{\beta}{sin \theta}r_1 \end{aligned} ∴ρ2(a1×a3)ρ2(a2×a3)=(αr1T−αcotθr2T+u0R3T)×r3T=αr2−αcotθr1=(sinθβr2T+v0r3T)×r3T=sinθβr1
∴ ρ 2 ∣ a 1 × a 3 ∣ = ∣ ( α r 2 − α c o t θ r 1 ) ∣ = ( α r 2 − α c o t θ r 1 ) T ⋅ ( α r 2 − α c o t θ r 1 ) = α 2 + ( α c o t θ ) 2 = α 2 ( 1 + ( c o s θ s i n θ ) 2 ) = ( α s i n θ ) 2 = ∣ α ∣ s i n θ ρ 2 ∣ a 2 × a 3 ∣ = ∣ β s i n θ r 1 ∣ = ( β s i n θ r 1 ) T ⋅ ( β s i n θ r 1 ) = ( β s i n θ ) 2 = ∣ β ∣ s i n θ \begin{aligned} \therefore \quad & \rho^2 |a_1 \times a_3|\\ & =|(\alpha r_2 - \alpha cot \theta r_1)|\\ & =\sqrt {(\alpha r_2 - \alpha cot \theta r_1)^T \cdot (\alpha r_2 - \alpha cot \theta r_1)}\\ & =\sqrt {\alpha^2 + (\alpha cot \theta)^2} \\ & =\sqrt {\alpha^2 (1+(\frac{cos \theta}{sin \theta})^2)}\\ & = \sqrt {(\frac{\alpha}{sin \theta})^2}\\ & = \frac{|\alpha|}{sin \theta}\\\\ & \rho^2 |a_2 \times a_3|\\ & = |\frac{\beta}{sin \theta}r_1|\\ & = \sqrt {(\frac{\beta}{sin \theta}r_1)^T \cdot (\frac{\beta}{sin \theta}r_1)}\\ & = \sqrt {(\frac{\beta}{sin \theta})^2}\\ & = \frac{|\beta|}{sin \theta} \end{aligned} ∴ρ2∣a1×a3∣=∣(αr2−αcotθr1)∣=(αr2−αcotθr1)T⋅(αr2−αcotθr1)=α2+(αcotθ)2=α2(1+(sinθcosθ)2)=(sinθα)2=sinθ∣α∣ρ2∣a2×a3∣=∣sinθβr1∣=(sinθβr1)T⋅(sinθβr1)=(sinθβ)2=sinθ∣β∣
∵ ρ 2 ( a 1 × a 3 ) ⋅ ρ 2 ( a 2 × a 3 ) = ( α r 2 − α c o t θ r 1 ) ⋅ ( β s i n θ r 1 ) = − α c o t θ β s i n θ = − α c o s θ s i n θ β s i n θ = − a c o s θ β s i n 2 θ ρ 2 ∣ a 1 × a 3 ∣ ⋅ ρ 2 ∣ a 2 × a 3 ∣ = ∣ α ∣ s i n θ ⋅ ∣ β ∣ s i n θ = ∣ α ∣ ∣ β ∣ s i n 2 θ \begin{aligned} \because \quad & \rho^2 (a_1 \times a_3) \cdot \rho^2 (a_2 \times a_3)\\ &=(\alpha r_2 - \alpha cot \theta r_1) \cdot (\frac{\beta}{sin \theta}r_1)\\ &=-\alpha cot \theta \frac{\beta}{sin \theta}\\ &=-\alpha \frac{cos \theta}{sin \theta} \frac{\beta}{sin \theta}\\ &=-\frac{a cos \theta \beta}{sin^2 \theta}\\\\ &\rho^2 |a_1 \times a_3| \cdot \rho^2 |a_2 \times a_3|\\ &=\frac{|\alpha|}{sin \theta} \cdot \frac{|\beta|}{sin \theta}\\ &= \frac{|\alpha||\beta|}{sin^2 \theta} \end{aligned} ∵ρ2(a1×a3)⋅ρ2(a2×a3)=(αr2−αcotθr1)⋅(sinθβr1)=−αcotθsinθβ=−αsinθcosθsinθβ=−sin2θacosθβρ2∣a1×a3∣⋅ρ2∣a2×a3∣=sinθ∣α∣⋅sinθ∣β∣=sin2θ∣α∣∣β∣
∴ ρ 2 ( a 1 × a 3 ) ⋅ ρ 2 ( a 2 × a 3 ) ρ 2 ∣ a 1 × a 3 ∣ ⋅ ρ 2 ∣ a 2 × a 3 ∣ = − a c o s θ β s i n 2 θ s i n 2 θ ∣ α ∣ ∣ β ∣ = − c o s θ \begin{aligned} \therefore \quad & \frac{\rho^2 (a_1 \times a_3) \cdot \rho^2 (a_2 \times a_3)}{\rho^2 |a_1 \times a_3| \cdot \rho^2 |a_2 \times a_3|}\\ &=-\frac{a cos \theta \beta}{sin^2 \theta} \frac{sin^2 \theta}{|\alpha||\beta|}\\ &=-cos \theta \end{aligned} ∴ρ2∣a1×a3∣⋅ρ2∣a2×a3∣ρ2(a1×a3)⋅ρ2(a2×a3)=−sin2θacosθβ∣α∣∣β∣sin2θ=−cosθ
∴ c o s θ = − ( a 1 × a 3 ) ⋅ ( a 2 × a 3 ) ∣ a 1 × a 3 ∣ ⋅ ∣ a 2 × a 3 ∣ \therefore \quad cos \theta=-\frac{ (a_1 \times a_3) \cdot (a_2 \times a_3)}{ |a_1 \times a_3| \cdot |a_2 \times a_3|} ∴cosθ=−∣a1×a3∣⋅∣a2×a3∣(a1×a3)⋅(a2×a3)
如果 θ = 9 0 o \theta=90^o θ=90o,则 c o s θ = 0 cos \theta=0 cosθ=0,所以 ( a 1 × a 3 ) ⋅ ( a 2 × a 3 ) = 0 (a_1 \times a_3) \cdot (a_2 \times a_3)=0 (a1×a3)⋅(a2×a3)=0,这正时之前提到的投影矩阵M满足零倾斜透视投影的条件;
之前(3)中推导过:
∵ ρ 2 ∣ a 1 × a 3 ∣ = ∣ α ∣ s i n θ ρ 2 ∣ a 2 × a 3 ∣ = ∣ β ∣ s i n θ \begin{aligned} \because \quad & \rho^2 |a_1 \times a_3| = \frac{|\alpha|}{sin \theta}\\\\ & \rho^2 |a_2 \times a_3|= \frac{|\beta|}{sin \theta} \end{aligned} ∵ρ2∣a1×a3∣=sinθ∣α∣ρ2∣a2×a3∣=sinθ∣β∣
∴ α = ρ 2 ∣ a 1 × a 3 ∣ s i n θ β = ρ 2 ∣ a 2 × a 3 ∣ s i n θ \begin{aligned} \therefore \quad & \alpha = \rho^2|a_1 \times a_3|sin \theta\\ & \beta = \rho^2|a_2 \times a_3|sin \theta \end{aligned} ∴α=ρ2∣a1×a3∣sinθβ=ρ2∣a2×a3∣sinθ
如果 α = β \alpha=\beta α=β,所以 ∣ a 1 × a 3 ∣ = ∣ a 2 × a 3 ∣ |a_1 \times a_3|=|a_2 \times a_3| ∣a1×a3∣=∣a2×a3∣,所以 ( a 1 × a 3 ) ⋅ ( a 1 × a 3 ) = ( a 2 × a 3 ) ⋅ ( a 2 × a 3 ) (a_1 \times a_3)\cdot(a_1 \times a_3)=(a_2 \times a_3) \cdot (a_2 \times a_3) (a1×a3)⋅(a1×a3)=(a2×a3)⋅(a2×a3),这也是前面提到的零倾斜透视投影的基础上宽高比为1的另一个条件。
∵ ρ a 3 T = r 3 T a n d ρ = ± 1 ∣ a 3 ∣ \because \quad \rho a_3^T = r_3^T \quad and \quad \rho=\frac{\pm1}{|a_3|} ∵ρa3T=r3Tandρ=∣a3∣±1
∴ r 3 = ± a 3 ∣ a 3 ∣ \therefore \quad r_3 = \frac{\pm a_3}{|a_3|} ∴r3=∣a3∣±a3
∵ ρ a 2 T × ρ a 3 T = ( β s i n θ r 2 T + v 0 r 3 T ) × r 3 T ∴ ρ 2 ( a 2 × a 3 ) = β s i n θ r 1 \begin{aligned} & \because \quad \rho a_2^T \times \rho a_3^T = (\frac{\beta}{sin \theta} r_2^T + v_0 r_3^T) \times r_3^T\\ & \therefore \quad \rho^2(a_2 \times a_3)=\frac{\beta}{sin \theta}r_1 \end{aligned} ∵ρa2T×ρa3T=(sinθβr2T+v0r3T)×r3T∴ρ2(a2×a3)=sinθβr1
因为 r 1 r_1 r1 是单位向量,且 ρ 2 , β s i n θ 为实数 \rho^2,\frac{\beta}{sin \theta}为实数 ρ2,sinθβ为实数,
∴ r 1 = ( a 2 × a 3 ) ∣ a 2 × a 3 ∣ \begin{aligned} & \therefore \quad r_1=\frac{(a_2 \times a_3)}{|a_2 \times a_3|} \end{aligned} ∴r1=∣a2×a3∣(a2×a3)
r 2 = r 3 × r 1 r_2 = r_3 \times r_1 r2=r3×r1
ρ [ A b ] = K [ R T ] = [ K R K T ] ρ b = K T K − 1 ρ b = T \begin{aligned} \rho [A \quad b]=K[R \quad T]&=[KR \quad KT]\\ \rho b &= KT\\ K^{-1}\rho b & = T \end{aligned} ρ[Ab]=K[RT]ρbK−1ρb=[KRKT]=KT=T
∴ T = ρ K − 1 b \therefore \quad T=\rho K^{-1}b ∴T=ρK−1b
如下图所示的径向畸变情况下,图像的放大率随距离光轴距离增加而减小:
对于桶形畸变来说, K p > 0 K_p>0 Kp>0,则 λ > 1 \lambda >1 λ>1;
对于桶形畸变来说, K p < 0 K_p<0 Kp<0,则 λ < 1 \lambda <1 λ<1;
∴ { u i = 1 λ m 1 P i m 3 P i v i = 1 λ m 2 P i m 3 P i ∴ { u i λ m 3 P i = m 1 P i v i λ m 3 P i = m 2 P i ∴ { m 1 P i − u i λ m 3 P i = 0 m 2 P i − v i λ m 3 P i = 0 \begin{aligned} & \therefore \quad \begin{cases} u_i = \frac{1}{\lambda}\frac{m_1P_i}{m_3P_i}\\ v_i = \frac{1}{\lambda}\frac{m_2P_i}{m_3P_i} \end{cases}\\ &\therefore \quad \begin{cases} u_i \lambda m_3 P_i=m_1P_i\\ v_i \lambda m_3 P_i=m_2P_i\\ \end{cases}\\ & \therefore \quad \begin{cases}m_1P_i-u_i \lambda m_3 P_i=0\\ m_2P_i-v_i \lambda m_3 P_i=0\\ \end{cases}\\ \end{aligned} ∴{ui=λ1m3Pim1Pivi=λ1m3Pim2Pi∴{uiλm3Pi=m1Piviλm3Pi=m2Pi∴{m1Pi−uiλm3Pi=0m2Pi−viλm3Pi=0
Q m ⃗ = 0 Q \vec m=0 Qm=0
在第一节中此处列出的公式是:
P m ⃗ = 0 P \vec m=0 Pm=0
P是由3D点 P i P_i Pi和2D图像点 p i p_i pi构成的全是已知数的矩阵, m ⃗ \vec m m为待求解的投影矩阵,所以这是一个线性方程。
而Q里面除了包含由3D点 P i P_i Pi和2D图像点 p i p_i pi构成的已知数外,还包含未知数 λ \lambda λ,所以Q不是线性方程组;
此处即然 λ \lambda λ是未知数,为啥不能把 λ \lambda λ写到待求解的 m ⃗ \vec m m里面呢,因为不同点的 λ \lambda λ是不一样的。
由于从初始解开始迭代的话,若初始解与实际相距较远,可能收敛会很慢。
因此,可以求解系统的线性部分,以找到近似解;适用该解作为整个系统的初始条件。
核心:通过比值消掉未知数 λ \lambda λ。
均匀伸缩变化如下:
相似变换由缩放变换和欧式变换合成: