生息演算地图匹配地点
In [1]:
from matplotlib import pyplot as plt
from arknights_mower.utils.matcher import Matcher
from arknights_mower.utils.image import loadimg, loadres
In [2]:
sc = loadimg("/home/zhao/Documents/Desktop/ra_map.png", True)
plt.imshow(sc, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-16 17:47:39,468 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/Desktop/ra_map.png
In [3]:
2024-07-16 17:47:39,726 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/arknights-mower/arknights_mower/resources/ra/map/资源区_射程以内.png
In [4]:
2024-07-16 17:47:39,863 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:77 - __init__ - Matcher init: shape ((900, 1370))
In [5]:
2024-07-16 17:47:40,242 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:202 - score - transform matrix: [[1.0012251734016322, -0.005298719241620122, 667.1395609672389], [0.0004466367175678509, 1.00531283833583, 454.08088001521105]]
2024-07-16 17:47:40,604 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:113 - match - match success: ([[667, 454], [925, 582]], (0.5030120481927711, 0.8988326848249028, 0.875, 0.8695953607668526))
Out[5]:
In [6]:
In [7]:
result = cv2.matchTemplate(sc, res, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
print(max_val)
h, w = res.shape
scope = max_loc, va(max_loc, (w, h))
print(scope)
img = cv2.cvtColor(sc, cv2.COLOR_GRAY2RGB)
cv2.rectangle(img, scope[0], scope[1], (0, 255, 0), 3)
plt.imshow(img)
plt.show()
In [8]:
In [9]:
In [10]:
In [11]: