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)

实验现象:

相关推荐
电子元件小说家1 小时前
2026年四季度电感市场观察:AI算力与汽车电子驱动下的选型与验证建议智能硬件
人工智能·汽车
网易CodeWave-小码哥1 小时前
支持多模块 Java 微服务导入|CodeWave SDD V4.5.10 上线
人工智能
AI你一生一世1 小时前
不止于时序存储:DolphinDB 如何成为 AI 时代的工业智能底座
java·人工智能·struts·时序数据库·工业智能·dolphindb·ai基础设施
belldeep1 小时前
python:genesis-world, Genesis-Embodied-AI
人工智能·python·ai·genesis
怕浪猫1 小时前
小程序成长计划上新:10 亿 Token 现在能调 DeepSeek-v4.1-flash了
人工智能·aigc·ai编程
ss2732 小时前
为什么PostgreSQL适合AI场景?
数据库·人工智能·postgresql
benchmark_cc2 小时前
A 股、港股、美股如何建立统一的标的主数据格式?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
七牛云行业应用3 小时前
DeepSeek Super-agent 与 Grok Bot:开源 Agent 架构和聊天助手有何区别
人工智能·ai·架构·ai编程
维克兜率天3 小时前
【维克】趋势型CTA:期货市场的“追涨杀跌“
人工智能·python
u1301303 小时前
GitHub 热榜项目:日榜(2026-11-03)
人工智能·github