根据内参调整图像大小

根据内参进行图像缩放

公式推导参考:图像缩放后相机内参如何变化的

注意:直接调用OpenCV对图像进行resize只能改变图像shape,从相机层级出发 应该是根据内参来进行转换的(其中可能涉及 焦距 和 分辨率的调整)。

设原始相机内参为

K 1 = [ f x 1 0 u 0 1 0 f y 1 v 0 1 0 0 1 ] K^{1}=\left[ \begin{array}{rcl} f_{x}^{1} & 0 & u_{0}^{1}\\ 0 & f_{y}^{1} & v_{0}^{1}\\ 0 & 0 & 1 \end{array} \right] K1= fx1000fy10u01v011

目的相机内参为:

K 2 = [ f x 2 0 u 0 2 0 f y 2 v 0 2 0 0 1 ] K^{2}=\left[ \begin{array}{rcl} f_{x}^{2} & 0 & u_{0}^{2}\\ 0 & f_{y}^{2} & v_{0}^{2}\\ 0 & 0 & 1 \end{array} \right] K2= fx2000fy20u02v021

根据坐标系间的关系:

[ X c Y c Z c 1 ] = [ R T 0 1 ] [ X w Y w Z w 1 ] \left[ \begin{array}{rcl} X_{c}\\ Y_{c}\\ Z_{c}\\ 1\\ \end{array} \right]= \left[ \begin{array}{rcl} R & T\\ 0& 1\\ \end{array} \right] \left[ \begin{array}{rcl} X_{w}\\ Y_{w}\\ Z_{w}\\ 1\\ \end{array} \right] XcYcZc1 =[R0T1] XwYwZw1

Z c [ u v 1 ] = [ f x 0 u 0 0 0 f y v 0 0 0 0 1 0 ] [ R T 0 1 ] [ X w Y w Z w 1 ] Z_{c}\left[ \begin{array}{rcl} u\\ v \\ 1 \end{array} \right] =\left[ \begin{array}{rcl} f_{x} & 0 & u_{0} & 0\\ 0 & f_{y} & v_{0} & 0\\ 0 & 0 & 1 & 0 \end{array} \right] \left[ \begin{array}{rcl} R & T\\ 0& 1\\ \end{array} \right] \left[ \begin{array}{rcl} X_{w}\\ Y_{w}\\ Z_{w}\\ 1\\ \end{array} \right] Zc uv1 = fx000fy0u0v01000 [R0T1] XwYwZw1

将图像像素坐标 左乘原始相机内参的逆 再左乘目的相机内参 即可:

[ u 2 v 2 1 ] = [ f x 2 0 u 0 2 0 f y 2 v 0 2 0 0 1 ] [ f x 1 0 u 0 1 0 f y 1 v 0 1 0 0 1 ] − 1 [ u 1 v 1 1 ] \left[ \begin{array}{rcl} u^{2}\\ v^{2} \\ 1 \end{array} \right]= \left[ \begin{array}{rcl} f_{x}^{2} & 0 & u_{0}^{2}\\ 0 & f_{y}^{2} & v_{0}^{2}\\ 0 & 0 & 1 \end{array} \right] \left[ \begin{array}{rcl} f_{x}^{1} & 0 & u_{0}^{1}\\ 0 & f_{y}^{1} & v_{0}^{1}\\ 0 & 0 & 1 \end{array} \right]^{-1} \left[ \begin{array}{rcl} u^{1}\\ v^{1} \\ 1 \end{array} \right] u2v21 = fx2000fy20u02v021 fx1000fy10u01v011 1 u1v11

超分辨率重建

一文掌握图像超分辨率重建(算法原理、Pytorch实现)——含完整代码和数据

你可能感兴趣的:(图像处理,计算机视觉,opencv,人工智能)