Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 交通标志识别中模板匹配方法识别精度低_Python_Opencv_Image Processing_Image Recognition - Fatal编程技术网

Python 交通标志识别中模板匹配方法识别精度低

Python 交通标志识别中模板匹配方法识别精度低,python,opencv,image-processing,image-recognition,Python,Opencv,Image Processing,Image Recognition,各位晚上好,我提前感谢你们的帮助。 我是一个新手,但我正试图编写一个代码,帮助计算机识别图像上的交通标志。 我使用OpenCV库、python和google colab。 我使用了模板匹配方法,但是我遇到了一个严重的问题:这个应用程序的精确度非常低,我需要帮助改进代码以提高检测能力。 也许我应该迭代旋转图像,或者可能存在其他解决方案。请帮忙,我如何改进我的代码。 代码如下: img_original = cv2.imread(fileName, 0) scale_percentage = 1

各位晚上好,我提前感谢你们的帮助。
我是一个新手,但我正试图编写一个代码,帮助计算机识别图像上的交通标志。
我使用OpenCV库、python和google colab。
我使用了模板匹配方法,但是我遇到了一个严重的问题:这个应用程序的精确度非常低,我需要帮助改进代码以提高检测能力。
也许我应该迭代旋转图像,或者可能存在其他解决方案。请帮忙,我如何改进我的代码。 代码如下:

img_original = cv2.imread(fileName, 0)


scale_percentage = 150
width = int(img_original.shape[1]*scale_percentage/100)
height = int(img_original.shape[0]*scale_percentage/100)
new_scale = (width, height)
img_original1 = cv2.resize(img_original, new_scale, interpolation = cv2.INTER_AREA)
cv2_imshow(img_original1)
img_original1.shape

img_original2 = cv2.medianBlur(img_original1, 5)

template = cv2.imread(image_template, 0)

width1, height1 = template.shape[:2]

#Обработка изображения
threshold_image = cv2.adaptiveThreshold(img_original2, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
threshold_template = cv2.adaptiveThreshold(template, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
cv2_imshow(threshold_image)

#Размытие изображения
blurred_image = cv2.GaussianBlur(threshold_image, (11,11), 0)

#Сравнение с оригиналом, порог, 
result = cv2.matchTemplate(blurred_image,threshold_template,cv2.TM_SQDIFF_NORMED)
threshold = 0.46


#np.where (condition, [x,y]) при условии(булеан, массив), где True, возвращает значения х или у в зависимости от того, где True
loc = np.where( result >= threshold)

#Цикл где происходит обход изображения по рядам и колоннам по очереди и затем рисуется прямоугольник в областях, где находится совпадение
for pt in zip(*loc[::-1]):
    cv2.rectangle(blurred_image, pt, (pt[0] + width1, pt[1] + height1), (0,0,255), 1)
cv2.imwrite('result.jpg', blurred_image)
cv2_imshow(blurred_image)
cv2_imshow(threshold_template)
cv2_imshow(result)
结果如下:


模板匹配不是解决此问题的好方法。您也可以查看。谢谢您的回答。