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

时间:2019-11-11 07:35:53

标签: python opencv alignment

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

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

我的车牌图像偏斜,倾斜或对角线,如下所示。 [enter image description here

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

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

1 个答案:

答案 0 :(得分:0)

使用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],[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()
相关问题