当前位置:网站首页>OpenCV 透视变换
OpenCV 透视变换
2022-08-03 12:49:00 【我今年十六岁】
目录
一:OpenCV透视变换的概念

仿射变换是图像基于3个固定顶点的变换,接下来学习的透视变换是4个固定顶点的变换
二:透视变换工作原理
透视变换(Perspective Transformation)的本质是将图像投影到一个新的视平面,其通用变换公式为:

(u,v)为原始图像像素坐标,(x=x’/w’,y=y’/w’)为变换之后的图像像素坐标。透视变换矩阵图解如下:

仿射变换(Affine Transformation)可以理解为透视变换的特殊形式。透视变换的数学表达式为:

所以,给定透视变换对应的四对像素点坐标,即可求得透视变换矩阵;反之,给定透视变换矩阵,即可对图像或像素点坐标完成透视变换,如下图所示:


三:findHomography函数
findHomography: 计算多个二维点对之间的最优单映射变换矩阵 H(3行x3列) ,使用最小均方误差或者RANSAC方法。
函数功能:找到两个平面之间的变换矩阵。
函数参数:
Mat cv::findHomography ( InputArray srcPoints,
InputArray dstPoints,
int method = 0,
double ransacReprojThreshold = 3,
OutputArray mask = noArray(),
const int maxIters = 2000,
const double confidence = 0.995
)

四:warpPerspective函数
函数原型:
void warpPerspective(InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
函数参数说明:
图中红点即为固定顶点,在变换先后固定顶点的像素值不变,图像整体则根据变换规则进行变换
同理,透视变换是图像基于4个固定顶点的变换,如图所示:

五:getPerspectiveTransform函数
函数原型:
C++方式一:Mat getPerspectiveTransform(InputArray src, InputArray dst)
C++方式二:Mat getPerspectiveTransform(const Point2f src[], const Point2f dst[])
函数参数说明:
src – 源图像中四边形顶点的坐标
dst – 目标图像中相应四边形顶点的坐标。
该函数计算透视变换的3乘3矩阵,以便实现以下计算:

边栏推荐
- Redis 6 的多线程
- 力扣刷题 每日两题(一)
- leetcode/字符串中的所有变位词(s1字符串的某个排列是s2的子串)的左索引
- Redis connection pool tool class
- Notepad++ 安装jsonview插件
- 有趣的opencv-记录图片二值化和相似度实现
- An动画优化之遮罩层动画
- YOLOv5 training data prompts No labels found, with_suffix is used, WARNING: Ignoring corrupted image and/or label appears during yolov5 training
- 字节最爱问的智力题,你会几道?
- Basic principle of the bulk of the animation and shape the An animation tip point
猜你喜欢

The components of the basis of An animation movie clip animation between traditional filling

Jmeter使用

Sogou news-数据集

IronOS, an open source system for portable soldering irons, supports a variety of portable DC, QC, PD powered soldering irons, and supports all standard functions of smart soldering irons

软件测试面试(四)

【蓝桥杯选拔赛真题48】Scratch跳舞机游戏 少儿编程scratch蓝桥杯选拔赛真题讲解

可视化图表设计Cookbook

An工具介绍之形状工具及渐变变形工具

层次分析法

Feature dimensionality reduction study notes (pca and lda) (1)
随机推荐
软件测试自学还是报班好?
什么是分布式锁?几种分布式锁分别是怎么实现的?
漫画:怎么证明sleep不释放锁,而wait释放锁?
浅谈低代码平台远程组件加载方案
An animation basic element movie clip effect
Classes and Objects (lower middle)
self-discipline
PyTorch构建神经网络预测气温(数据集对比,CPU与GPU对比)
In order to counteract the drop in sales and explore the low-end market, Weilai's new brand products are priced as low as 100,000?
Secure Custom Web Application Login
leetcode16 Sum of the closest three numbers (sort + double pointer)
leetcode 11. The container that holds the most water
An工具介绍之宽度工具、变形工具与套索工具
链游NFT元宇宙游戏系统开发技术方案及源码
Feature Engineering Study Notes
Unsupervised learning KMeans notes and examples
业界新标杆!阿里开源自研高并发编程核心笔记(2022最新版)
2022 年 CISO 最关心的是什么?
Oracle is installed (system disk) and transferred from the system disk to the data disk
An动画基础之元件的图形动画与按钮动画