def this(img_pat, img_temp):
"""pass img_pat as a cv2 image format, img_temp as a file
Passed Function to do w/e after finding img_temp"""
cwd = os.getcwd()
if cwd not in img_temp:
img_temp = cwd+img_temp
if '.png' not in img_temp:
img_temp = cwd+img_temp+'.png'
#print for DEBUG
#print(img_temp)
#img_temp
img_temp = cv2.imread(img_temp,0)
#save for DEBUG
#cv2.imwrite('img_temp', img_temp)
w, h = img_temp.shape[::-1]
res = cv2.matchTemplate(img_pat,img_temp,cv2.TM_CCOEFF_NORMED)
threshold = .8 #default is 8
loc = np.where( res >= threshold)
return loc, w, h
评论列表
文章目录