是否有任何opencv函数可将边缘添加到白色背景?

时间:2019-06-23 06:41:31

标签: python-3.7 opencv4

我正在创建用于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)

我想在白色背景中添加边缘,是否有任何opencv函数在白色背景中添加边缘?

下面是该问题的直观说明:

实际输出:

Actual output

预期输出:

expected output

轮廓:

contours

0 个答案:

没有答案