当前位置:网站首页>OpenCV perspective transform
OpenCV perspective transform
2022-08-03 13:14:00 【I this year 16 years old】
目录
一:OpenCV透视变换的概念
仿射变换Based on an image3个固定顶点的变换,接下来学习的透视变换是4个固定顶点的变换
二:透视变换工作原理
透视变换(Perspective Transformation)的本质是将图像投影到一个新的视平面,其通用变换公式为:
(u,v)为原始图像像素坐标,(x=x’/w’,y=y’/w’)为变换之后的图像像素坐标.透视变换矩阵图解如下:
仿射变换(Affine Transformation)可以理解为透视变换的特殊形式.透视变换的数学表达式为:
所以,给定透视变换对应的Four pairs of pixel coordinates,即可求得透视变换矩阵;反之,给定透视变换矩阵,即可对图像或像素点坐标完成透视变换,如下图所示:
三: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())
函数参数说明:
Figure in the red dot is the fixed vertex,在变换先后固定顶点的像素值不变,Image as a whole, according to the rules of transformation to transform
同理,透视变换Based on an image4个固定顶点的变换,如图所示:
五:getPerspectiveTransform函数
函数原型:
C++方式一:Mat getPerspectiveTransform(InputArray src, InputArray dst)
C++方式二:Mat getPerspectiveTransform(const Point2f src[], const Point2f dst[])
函数参数说明:
src – 源图像中四边形顶点的坐标
dst – 目标图像中相应四边形顶点的坐标.
该函数计算透视变换的3乘3矩阵,以便实现以下计算:
边栏推荐
猜你喜欢
PolarFormer: Multi-camera 3D Object Detection with Polar Transformers 论文笔记
Win11怎么禁止软件后台运行?Win11系统禁止应用在后台运行的方法
PyTorch构建分类网络模型(Mnist数据集,全连接神经网络)
An工具介绍之3D工具
【深度学习】高效轻量级语义分割综述
Sogou news - dataset
软件测试面试(四)
基于php志愿者服务平台管理系统获取(php毕业设计)
setTimeout, setInterval requestAnimationFrame
How to disable software from running in the background in Windows 11?How to prevent apps from running in the background in Windows 11
随机推荐
来广州找工作有一个多月了,今天终于有着落了,工资7000
leetcode16 Sum of the closest three numbers (sort + double pointer)
When Nodejs installation depends on cpnm, the install shows Error: Cannot find module 'fs/promises'
B站回应“HR 称核心用户都是 Loser”:该面试官去年底已被劝退,会吸取教训加强管理
leetcode16最接近的三数之和 (排序+ 双指针)
JS get browser type
R language ggplot2 visualization: use the patchwork bag plot_layout function will be more visual image together, ncol parameter specifies the number of rows, specify byrow parameters configuration dia
超多精美礼品等你来拿!2022年中国混沌工程调查启动
An动画基础之散件动画原理与形状提示点
Blog records life
IDEA的模板(Templates)
How can I get a city's year-round weather data for free?Precipitation, temperature, humidity, solar radiation, etc.
基于php志愿者服务平台管理系统获取(php毕业设计)
期货开户中常见问题汇总
Oracle is installed (system disk) and transferred from the system disk to the data disk
Secure Custom Web Application Login
An动画优化之遮罩层动画
[Deep Learning] Overview of Efficient and Lightweight Semantic Segmentation
An工具介绍之3D工具
How to build an overseas purchasing system/purchasing website - source code analysis