相机平面与工作平面带夹角下的坐标换算

        如上图,我们假设A平面为相机平面,B平面为工作平面。对于带相机定位的机械设备,我们需要通过相机图像上定位到的像素坐标a(x,y),映射到工作平面的机械坐标系下的b(x',y')。现再假设我们知道相机的实际毫米像素比。则\left | a \right |的尺寸就是实际的机械坐标系下的尺寸。

        我们令_{}^{A}\textrm{a}=\begin{pmatrix} x\\ y\\ 0\\ 1 \end{pmatrix},_{}^{B}\textrm{b}=\begin{pmatrix} x'\\ y'\\ 0\\ 1 \end{pmatrix}_{}^{A}\textrm{a}的上标表示其坐标是在A平面为XY基平面的坐标系下的坐标。同理理解_{}^{B}\textrm{b}

        则,我们可以通过一个变换矩阵将_{}^{A}\textrm{a}转换到 _{}^{B}\textrm{b}。设这个变换矩阵为T,则有:

                                        _{}^{B}\textrm{b}=T_{}^{A}\textrm{a}

                       T=\begin{pmatrix} t_{11} &t_{12} &t_{13} &t_{14} \\ t_{21}&t_{22} &t_{23} &t_{24} \\ t_{31}&t_{32} &t_{33} &t_{34} \\ 0&0 &0 &1 \end{pmatrix}

        由于_{}^{A}\textrm{a}=\begin{pmatrix} x\\ y\\ 0\\ 1 \end{pmatrix}_{}^{B}\textrm{b}=\begin{pmatrix} x'\\ y'\\ 0\\ 1 \end{pmatrix}的元素3恒为零,所以我们可以不用顾及T的3行和3列的数值。T可以进一步缩小为T'=\begin{pmatrix} t_{11} &t_{12} &t_{14} \\ t_{21} &t_{22} &t_{24} \\ 0&0 &1 \end{pmatrix}。我们在平面A中取三个线性不相关的点_{}^{A}\textrm{a1}=\begin{pmatrix} x_{1}\\ y_{1}\\ 1 \end{pmatrix},_{}^{A}\textrm{a2}=\begin{pmatrix} x_{2}\\ y_{2}\\ 1 \end{pmatrix},_{}^{A}\textrm{a3}=\begin{pmatrix} x_{3}\\ y_{3}\\ 1 \end{pmatrix},组成一个矩阵A=\begin{pmatrix} x_{1} &x_{2} &x_{3} \\ y_{1}&y_{2} &y_{3} \\ 1& 1 &1 \end{pmatrix},同样映射到B平面得到矩阵B=\begin{pmatrix} x'_{1} &x'_{2} &x'_{3} \\ y'_{1}&y'_{2} &y'_{3} \\ 1&1 &1 \end{pmatrix}。因此我们可以通过求A_{}^{-1}得到T'

                                        BA_{}^{-1}=T'

        在这里我们要求A_{}^{-1},我们可以通过求A的特征值和特征向量来求取A_{}^{-1}。 

再仔细研究下T,我们可以发现,_{}^{A}\textrm{a}可以先通过将A平面旋转到与B平面重合后,得到_{}^{B}\textrm{a},然后通过平移得到_{}^{B}\textrm{b}。将T按上述步骤展开,我们有:

T=\begin{pmatrix} 1 &0 &0 &f(x,y)\bar{x}_{AB}\\ 0& 1 &0 &f(x,y)\bar{y}_{AB} \\ 0& 0 &1 &f(x,y)\bar{z}_{AB}\\ 0& 0 &0 &1 \end{pmatrix}\begin{pmatrix} c_{11} &c_{12} &c_{13} &c_{14} \\ c_{21} &c_{22} &c_{23} &c_{24} \\ c_{31}&c_{32} &c_{33} &c_{34} \\ 0& 0 & 0 &1 \end{pmatrix}

其中,\begin{pmatrix} \bar{x}_{AB}\\ \bar{y}_{AB}\\ \bar{z}_{AB}\\ 1 \end{pmatrix}构成了A平面的法向量\bar{n},指向B平面。f(x,y)_{}^{B}\textrm{a}平移到_{}^{B}\textrm{b}所要的向量数值。\begin{pmatrix} c_{11} &c_{12} &c_{13} &c_{14} \\ c_{21} &c_{22} &c_{23} &c_{24} \\ c_{31}&c_{32} &c_{33} &c_{34} \\ 0& 0 & 0 &1 \end{pmatrix}为A平面到B平面的变换矩阵。具体直观可参看下图。

        我们有\left | f(x,y) \right |=\sqrt{x'^{2}+y'^{2}-x^{2}-y^{2}},其符号视情况而定。又由于\bar{n}始终垂直于A平面,\bar{n}的投影始终在b上,所以可以得到\bar{x}_{AB}=\frac{x'}{\left | _{}^{B}\textrm{b}\right |},\bar{y}_{AB}=\frac{y'}{\left | _{}^{B}\textrm{b} \right |},而\left | \bar{z}_{AB} \right |=\sqrt{1-\bar{x}_{AB}^{2}-\bar{y}_{AB}^{2}},其符号视情况而定。

        前面我们有:

                                                           _{}^{B}\textrm{b}=T_{}^{A}\textrm{a}

                            \begin{pmatrix} x'\\ y'\\ 0\\ 1 \end{pmatrix}=\begin{pmatrix} 1 & 0 &0 &f(x,y)\bar{x}_{AB} \\ 0& 1 & 0 &f(x,y)\bar{y}_{AB} \\ 0& 0 &1 &f(x,y)\bar{z}_{AB} \\ 0& 0 &0 &1 \end{pmatrix}\begin{pmatrix} c_{11}&c_{12} &c_{13} &c_{14} \\ c_{21}&c_{22} &c_{23} &c_{24} \\ c_{31}&c_{32} &c_{33} &c_{34} \\ 0& 0 &0 &1 \end{pmatrix}\begin{pmatrix} x\\ y\\ 0\\ 1 \end{pmatrix}

                

因此我们可以通过变换得到_{}^{B}\textrm{a}

 _{}^{B}\textrm{a}=\begin{pmatrix} 1 &0 &0 &-f(x,y)\bar{x}_{AB} \\ 0&1 &0 &-f(x,y)\bar{y}_{AB} \\ 0& 0 &1 &-f(x,y)\bar{z}_{AB} \\ 0& 0 & 0 &1 \end{pmatrix}\begin{pmatrix} x'\\ y'\\ 0\\ 1 \end{pmatrix}=\begin{pmatrix} c_{11} &c_{12} &c_{13} &c_{14} \\ c_{21}&c_{22} &c_{23} &c_{24} \\ c_{31}&c_{32} &c_{33} &c_{34} \\ 0& 0 &0 &1 \end{pmatrix}\begin{pmatrix} x\\ y\\ 0\\ 1 \end{pmatrix}

从上述变换,我们再根据最开始所述的,由于最右边_{}^{A}\textrm{a}=\begin{pmatrix} x\\ y\\ 0\\ 1 \end{pmatrix}的第三个元素恒为零,我们可以将上式缩减一下:

        ​​​​​​​        \begin{pmatrix} 1 &0 &0 &-f(x,y)\bar{x}_{AB} \\ 0&1 &0 & -f(x,y)\bar{y}_{AB}\\ 0& 0 &1 &-f(x,y)\bar{z}_{AB} \\ 0&0 &0 &1 \end{pmatrix}\begin{pmatrix} x'\\ y'\\ 0\\ 1 \end{pmatrix}=\begin{pmatrix} c_{11} & c_{12} &c_{14} \\ c_{21}&c_{22} &c_{24} \\ c_{31}& c_{32} &c_{34} \\ 0&0 &1 \end{pmatrix}\begin{pmatrix} x\\ y\\ 1 \end{pmatrix}

同时,在A平面内取三个线性不相关的变量\begin{pmatrix} x_{1}\\ y_{1}\\ 1 \end{pmatrix},\begin{pmatrix} x_{2}\\ y_{2}\\ 1 \end{pmatrix},\begin{pmatrix} x_{3}\\ y_{3}\\ 1 \end{pmatrix},我们有:

        ​​​​​​​        \begin{pmatrix} x'_{1}+[-f(x_{1},y_{1})\bar{x}_{AB}] &x'_{2}+[-f(x_{2},y_{2})\bar{x}_{AB}] & x'_{3}+[-f(x_{3},y_{3})\bar{x}_{AB}]\\ y'_{1}+[-f(x_{1},y_{1})\bar{y}_{AB}]&y'_{2}+[-f(x_{2},y_{2})\bar{y}_{AB}] &y'_{3}+[-f(x_{3},y_{3})\bar{y}_{AB}] \\ -f(x_{1},y_{1})\bar{z}_{AB}& -f(x_{2},y_{2})\bar{z}_{AB} &-f(x_{3},y_{3})\bar{z}_{AB} \\ 1& 1 & 1 \end{pmatrix}=

        ​​​​​​​        ​​​​​​​        ​​​​​​​        ​​​​​​​        ​​​​​​​        \begin{pmatrix} c_{11} &c_{12} &c_{14} \\ c_{21}&c_{22} &c_{24} \\ c_{31}&c_{32} &c_{34} \\ 0&0 &1 \end{pmatrix}\begin{pmatrix} x_{1} &x_{2} &x_{3} \\ y_{1}&y_{2} &y_{3} \\ 1& 1 &1 \end{pmatrix}

\begin{pmatrix} c_{11} &c_{12} &c_{14} \\ c_{21}&c_{22} &c_{24} \\ c_{31}&c_{32} &c_{34} \\ 0&0 &1 \end{pmatrix}=\begin{pmatrix} x'_{1}+[-f(x_{1},y_{1})\bar{x}_{AB}] &x'_{2}+[-f(x_{2},y_{2})\bar{x}_{AB}] &x'_{3}+[-f(x_{3},y_{3})\bar{x}_{AB}] \\ y'_{1}+[-f(x_{1},y_{1})\bar{y}_{AB}]& y'_{2}+[-f(x_{2},y_{2})\bar{y}_{AB}]& y'_{3}+[-f(x_{3},y_{3})\bar{y}_{AB}]\\ -f(x_{1},y_{1})\bar{z}_{AB}&-f(x_{2},y_{2})\bar{z}_{AB} & -f(x_{3},y_{3})\bar{z}_{AB}\\ 1& 1 & 1 \end{pmatrix}\begin{pmatrix} x_{1}&x_{2} &x_{3} \\ y_{1}&y_{2} &y_{3} \\ 1& 1 &1 \end{pmatrix}^{-1}​​​​​​​

知道了\begin{pmatrix} c_{11} &c_{12} &c_{14} \\ c_{21}&c_{22} &c_{24} \\ c_{31}&c_{32} &c_{34} \\ 0&0 &1 \end{pmatrix},接下来我们只要确定方程f(x,y),就可以在A平面内任意取一点_{}^{A}\textrm{a}=\begin{pmatrix} x\\ y\\ 0\\ 1 \end{pmatrix}而算出_{}^{B}\textrm{b}=\begin{pmatrix} x'\\ y'\\ 0\\ 1 \end{pmatrix}

我们可以确定f(x,y)为一个平面方程,设f(x,y)=\alpha x+\beta y+\gamma。可以确定的是\gamma =0。我们取点\left ( x,0 \right ),x>0。同时人为的,根据实际情况确定f(x,y)的符号。由于\left | f(x,y) \right |=\sqrt{x'^{2}+y'^{2}-x^{2}-y^{2}}。则 \alpha =\pm \frac{\left | f(x,y) \right |}{x}​​​​​​​,\alpha的符号由f(x,y)决定。

同理,我们可以得到\beta =\pm \frac{\left | f(x,y) \right |}{y},\beta的符号由f(x,y)决定。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值