opencv的仿射变换Affine Transforms
什么是仿射变换?
仿射变换能从x,y方向上缩放,平移,剪切。
从(x,y)变换到(x', y')用一个矩阵M表示为:
(x', y') = M * (x, y)
M是一个2x2的矩阵
表示缩放
表示旋转
opencv中的仿射变换:
warpAffine()接收原图像,和一个2x3的仿射矩阵,输出变换后的矩阵。
warpAffine() 用的是下列公式
getRotationMatrix2D() 生成2x3的仿射矩阵,需要指定旋转角度和旋转中心
估计仿射矩阵
有时你想获得两张图之间的仿射变换,用getAffineTransform()。基本思想是,你在两幅图像中三对相应的点,使用简单的数学就可以获得它们之间的仿射变换
因为每对点可以有两个方程,仿射矩阵6个变量需要三对点就可以求出来。
透视变换Perspective Transforms
对于3x3的矩阵M,warpPerspective()采用的方程为:
通常M33为1,所以透视变换矩阵变量为8个,只需要四对点就可以求出。
findHomography()函数解决这个问题,如果调用CV_RANSAC,采用的是RANSAC算法鲁棒估计这些点之间的透视变换
现在的问题是,怎么寻找这些匹配的点。这跟立体视觉寻找匹配 点的问题一样。