齐次坐标系

引入齐次坐标可以让级联的仿射变换变成矩阵连乘。n+1维齐次坐标是对n维奇卡尔坐标的扩展。
[xy]=[xy1]=[2x2y2]=[wxwyw] \begin{bmatrix} x\\y \end{bmatrix}= \begin{bmatrix} x\\y\\1 \end{bmatrix}= \begin{bmatrix} 2x\\2y\\2 \end{bmatrix}= \begin{bmatrix} wx\\wy\\w \end{bmatrix}
转换关系如上公式所示,齐次坐标系与笛卡尔坐标系的转换关系是第i维除以最后一维。
示例(from: https://www.cnblogs.com/shine-lee/p/10950963.html)
相机与世界(一)

相机与世界

世界坐标系to相机坐标系

世界坐标系(X, Y, Z):世界中的某一个坐标系

相机坐标系(Xc, Yc, Zc):相机光轴向外为z正方向,向左为x正方向,向上为y正方向
由旋转+平移得到。
[XcYcZc]=R[XYZ]+t \begin{bmatrix} Xc\\Yc\\Zc \end{bmatrix}=\mathbf{R} \begin{bmatrix} X\\Y\\Z \end{bmatrix}+\mathbf{t}
齐次坐标:
[XcYcZc1]=[Rt01][XYZ1] \begin{bmatrix} Xc\\Yc\\Zc\\1 \end{bmatrix}= \begin{bmatrix} \mathbf{R}&\mathbf{t}\\\mathbf{0}^ \intercal&1 \end{bmatrix} \begin{bmatrix} X\\Y\\Z\\1 \end{bmatrix}

相机坐标系to图像物理坐标系to图片像素坐标系

图像物理坐标系(xp,yp,zpx_p,y_p,z_p):呈现在图像上的、单位距离改变的坐标系.几何关系见下图
图像像素坐标系 (x,y,zx,y,z):图片物理坐标系的原点改变,因为一般图片原点都在图片的左上角
相机与世界(一)
相机与世界(一)
由相似三角形知识可得:
λ[xpypf]=[XcYcZc] \lambda \begin{bmatrix} x_p\\y_p\\ f \end{bmatrix}= \begin{bmatrix} X_c\\Y_c\\Z_c \end{bmatrix}
引入齐次坐标系:
[xpypf]=[XcYcZc1]=[XcYcZc1]=[100001000010][XcYcZc1] \begin{bmatrix} x_p\\y_p\\ f \end{bmatrix}= \begin{bmatrix} X_c\\Y_c\\Z_c\\1 \end{bmatrix}= \begin{bmatrix} X_c\\Y_c\\Z_c\\1 \end{bmatrix}= \begin{bmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&1&0 \end{bmatrix} \begin{bmatrix} X_c\\Y_c\\Z_c\\1 \end{bmatrix}
得:
[xpyp1]=[f000f0001][xpyp1]=[f000f0001][100001000010][XcYcZc1] \begin{bmatrix} x_p\\y_p\\ 1 \end{bmatrix}= \begin{bmatrix} f&0&0\\ 0&f&0\\0&0&1 \end{bmatrix} \begin{bmatrix} x_p\\y_p\\ 1 \end{bmatrix}= \begin{bmatrix} f&0&0\\ 0&f&0\\0&0&1 \end{bmatrix} \begin{bmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&1&0 \end{bmatrix} \begin{bmatrix} X_c\\Y_c\\Z_c\\1 \end{bmatrix}
由于是矩阵乘法,所以不做精确推导了,直接给出最后的转换关系:
[xy1]=[f000f0001][100001000010][Rt01][XYZ1] \begin{bmatrix} x\\y\\ 1 \end{bmatrix}= \begin{bmatrix} f&0&0\\ 0&f&0\\0&0&1 \end{bmatrix} \begin{bmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&1&0 \end{bmatrix} \begin{bmatrix} \mathbf{R}&\mathbf{t}\\\mathbf{0}^ \intercal&1 \end{bmatrix} \begin{bmatrix} X\\Y\\Z\\1 \end{bmatrix}
得:
x=K[Rt]X\mathbf{x}=\mathbf{K[R|t]X}
其中K称为相机的内参、R/t称为相机外参
相机与世界(一)

相关文章: