import cv2
import numpy as np
img_rgb = cv2.imread('kt61.jpg')
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
temp = cv2.imread('match.jpg',0)
w, h = temp.shape[::-1]
res = cv2.matchTemplate(img_gray,temp,cv2.TM_CCOEFF_NORMED)
thresh = 0.6
loc = np.where( res >= thresh)
for pt in zip(*loc[::-1]):
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (255,0,0), 1)
cv2.imshow('Img',img_rgb)
cv2.waitKey(0)
cv2.destroyAllWindows()
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.