我安装了Python和OpenCV 2.7 x86并使用PyCharm作为我的IDE。这是我的要求。我想在任何角度和形状下识别1到5的任何罗马数字。所以罗马数字可以是薄的,厚的,小的或大的。给定随机数的背景很幸运,只有一种颜色(亮棕色)。你有什么好的教程我可以看看吗?这是我到目前为止所做的,但它无法正常工作。
import cv2
import numpy as np
img_rgb = cv2.imread('rz-template.jpg')
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
template = cv2.imread('rz-image.jpg',0)
w, h = template.shape[::-1]
res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
threshold = 0.3
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,255,255), 2)
cv2.imshow('Detected',img_rgb)
cv2.waitKey()