用关键点检测网络检测出车牌的四个关键点,然后需要进行车牌对齐。车牌对齐的方法有:仿射变换;stn
一、仿射变换
参考:https://github.com/gm19900510/Pytorch_Retina_License_Plate
https://www.pianshen.com/article/399876939/
# 定义对应的点
points1 = np.float32([[new_x1, new_y1], [new_x2, new_y2], [new_x3, new_y3], [new_x4, new_y4]])
points2 = np.float32([[0, 0], [94, 0], [0, 24], [94, 24]])
# 计算得到转换矩阵
M = cv2.getPerspectiveTransform(points1, points2)
# 实现透视变换转换
processed = cv2.warpPerspective(img_box, M, (94, 24))
# 显示原图和处理后的图像
cv2.imshow("processed", processed)
二、stn
参考:https://github.com/kevinzakka/spatial-transformer-network
https://blog.csdn.net/qq_14845119/article/details/79510714