当前位置:网站首页>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矩阵,以便实现以下计算:

边栏推荐
- An introduction to the camera
- Golang 通道 channel
- How to disable software from running in the background in Windows 11?How to prevent apps from running in the background in Windows 11
- 汉源高科G8032标准ERPS环网交换机千兆4光10电工业以太网交换机环网+WEB管理+SNMP划VLAN
- The new interface, jingdong comment interface
- 图像融合GAN-FM学习笔记
- BOM系列之sessionStorage
- YOLOv5 training data prompts No labels found, with_suffix is used, WARNING: Ignoring corrupted image and/or label appears during yolov5 training
- 免费的网络传真平台_发传真不显示发送号码
- (through page) ali time to upload the jar
猜你喜欢

ECCV 2022 | AirDet: 无需微调的小样本目标检测方法

nacos app

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

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?

易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元

为冲销量下探中低端市场,蔚来新品牌产品定价低至10万?

An工具介绍之钢笔工具、铅笔工具与画笔工具

PolarFormer: Multi-camera 3D Object Detection with Polar Transformers 论文笔记

An动画优化之传统引导层动画

An动画优化之补间形状与传统补间的优化
随机推荐
15. PARTITIONS「建议收藏」
漫画:怎么证明sleep不释放锁,而wait释放锁?
链游NFT元宇宙游戏系统开发技术方案及源码
An动画优化之遮罩层动画
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
博客记录生活
Free Internet fax platform fax _ don't show number
Chapter 15 Source Code File REST API Introduction
7月份最后一篇博客
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
图像融合DDcGAN学习笔记
Key points for account opening of futures companies
An动画基础之元件的图形动画与按钮动画
为冲销量下探中低端市场,蔚来新品牌产品定价低至10万?
五、函数的调用过程
Nodejs 安装依赖cpnm时,install 出现Error: Cannot find module ‘fs/promises‘
来广州找工作有一个多月了,今天终于有着落了,工资7000
【蓝桥杯选拔赛真题48】Scratch跳舞机游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
Last blog for July
GameFi industry down but not out | June Report