我正在使用 CCTV 创建用于车牌识别的代码。当我试图获得车牌的边缘时,边缘不是矩形。如何在白色背景中添加边缘?
import numpy as np
import cv2,imutils
import matplotlib.pyplot as plt
image = cv2.imread('car2.jpg')
image = imutils.resize(image, width=500)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.bilateralFilter(gray, 11, 17, 17)
ret,thresh = cv2.threshold(gray,128,255,1,cv2.THRESH_BINARY)
edged = cv2.Canny(thresh, 170, 150)
我想在白色背景中添加边缘,如何实现通过白色背景添加边缘?
下面是问题的直观解释:
实际输出:
预期输出:
轮廓: