倾斜倾斜且呈长方形的矩形图片

您好,我有一个问题与正确的车牌图像对齐有关。我已经在Google中搜索过,但仍然找不到答案代码。

现在,因为我使用python,opencv解决了这个问题。

我的车牌图像偏斜,倾斜或对角线,如下所示。

倾斜倾斜且呈长方形的矩形图片

所以,我希望这些图像对齐并“歪斜”。

如果您有一些代码,您愿意为我分享吗? 谢谢

roccp423 回答:倾斜倾斜且呈长方形的矩形图片

使用geometric_transformations

enter image description here

import cv2
import numpy as np
# load image
img = cv2.imread('4llcP.png')
rows,cols,ch = img.shape
# cornerpoints of plate
pts1 = np.float32([[64,29],[533,120],[34,318]])
# new positions of points
pts2 = np.float32([[0,0],[cols-30,[0,rows-30]])
# transform image
M = cv2.getAffineTransform(pts1,pts2)
dst = cv2.warpAffine(img,M,(cols,rows))
# show image
cv2.imshow('Res',dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
本文链接:https://www.f2er.com/3125884.html

大家都在问