def identify_summons(image_path):
import cv2
import numpy as np
image = cv2.cvtColor(cv2.imread(image_path), cv2.COLOR_BGR2GRAY)
summons = []
points = 0
for file_name, (point_value, actual_name) in possible_summons.items():
template = cv2.imread(os.path.join('screenshots', 'summons', file_name + '.png'), cv2.IMREAD_GRAYSCALE)
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(res >= CLOSENESS_THRESHOLD)
for pt in zip(*loc[::-1]):
# Due to weird behaviour, only add one instance of each summon
if actual_name in summons:
continue
summons.append(actual_name)
points += point_value
return (summons, points)
评论列表
文章目录