因此,我训练了一个对象识别神经网络(YOLOv3),以检测以各种倾斜和直角拍摄的汽车图片的车牌周围的边界框,并且该网络确实可靠。但是现在我想利用图像处理从包围它的包围盒中提取车牌平行四边形,而不必训练另一个神经网络来这样做。样本图片:

我已尝试使用OpenCV内置函数执行边缘和轮廓检测,如以下最少的代码所示,但仅设法通过这种方式成功在一小部分图像上成功:
import cv2
import matplotlib.pyplot as plt
import numpy as np
def auto_canny(image, sigma=0.25):
# compute the median of the single channel pixel intensities
v = np.median(image)
# apply automatic Canny edge detection using the computed median
lower = int(max(0, (1.0 - sigma) * v))
upper = int(min(255, (1.0 + sigma) * v))
edged = cv2.Canny(image, lower, upper)
# return the edged image
return edged
# Load the image
orig_img = cv2.imread(input_file)
img = orig_img.copy()
dim1,dim2, _ …Run Code Online (Sandbox Code Playgroud)