def images(img_pat, img_temp,x,y, func):
w, h = img_temp.shape[::-1]
try:
res = cv2.matchTemplate(img_temp,img_pat,cv2.TM_CCOEFF_NORMED)
except Exception as e:
print("cannot match")
print(e)
threshold = .9 #default is 8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):#goes through each found image
func(img_pat, x, y, pt, w, h)
return 0
return 1
#return loc to be iterable outisde the function
#also sometimes width and height of image is needed
评论列表
文章目录