OpenCV 图片矫正

实验原理:

通过使用透视变换函数 ,把一个图像投影到一个新的视平面

第一步:输入原图像的四个相应的坐标

第二步:定义目标图像中四个角点的坐标

第三步:计算透视变换矩阵

第四步:计算透视变换矩阵

详细函数解释:OpenCV 功能函数介绍-CSDN博客

实验代码:

python 复制代码
import cv2
import numpy as np


img = cv2.imread("./6667.png")

points1 = np.array([[166, 136], [632, 40], [82, 500], [660,550]],
                   dtype=np.float32)

points2 = np.array([[0, 0], [img.shape[1], 0], [0, img.shape[0]], [img.shape[1], img.shape[0]]],
                   dtype=np.float32)
M = cv2.getPerspectiveTransform(points1, points2)

img_warp = cv2.warpPerspective(img, M,(img.shape[1], img.shape[0]))


cv2.imshow("img",img)
cv2.imshow("img1",img_warp)
cv2.waitKey(0)

实验现象:

相关推荐
FindYou.7 分钟前
机器学习day01(机器学习概述 + KNN算法)
人工智能·机器学习
β添砖java12 分钟前
深度学习(17)卷积层里的多输入多输出通道
人工智能·pytorch·深度学习
Cosolar13 分钟前
一文了解Transformer架构:大模型的核心基石与实战全攻略
人工智能·面试·架构
Python私教33 分钟前
GenericAgent记忆系统深度解析:四层架构如何让AI拥有永不遗忘的大脑
网络·人工智能·架构
txg6661 小时前
自动驾驶领域热点简报(2026-04-26 ~ 2026-05-03)
linux·人工智能·自动驾驶
zhaoyong2221 小时前
MySQL 存储过程中字符集与排序规则不匹配导致查询性能下降的解决方案
jvm·数据库·python
sinat_383437361 小时前
golang如何从Python转型Go开发_golang从Python转型Go开发攻略
jvm·数据库·python
rockey6271 小时前
基于AScript的python3脚本语言发布啦!
python·c#·.net·script·python3·eval·expression·function·动态脚本
gqk011 小时前
Python入门
python