利用特征匹配定位目标图像

In [1]:

from matplotlib import pyplot as plt
from arknights_mower.utils.image import cropimg, loadimg, loadres
from arknights_mower.utils.matcher import Matcher

In [2]:

sc = loadimg("/home/zhao/Documents/mower-profile/screenshot/202/20240714174003.png", True)
plt.imshow(sc, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:27,949 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/mower-profile/screenshot/202/20240714174003.png

No description has been provided for this image

In [3]:

res = loadres("infra_collect_factory", True)
plt.imshow(res, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:28,274 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/arknights-mower/arknights_mower/resources/infra_collect_factory.png

No description has been provided for this image

In [4]:

matcher = Matcher(sc)
2024-07-15 12:15:28,441 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:77 - __init__ - Matcher init: shape ((1080, 1920))

In [5]:

matcher.match(res, draw=True)

No description has been provided for this image

2024-07-15 12:15:28,781 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:202 - score - transform matrix: [[1.0002113191377349, 0.0021223900228503905, 242.8645414564958], [-0.00010565956886722923, 0.9989388049885747, 985.0677292717521]]

No description has been provided for this image

No description has been provided for this image

2024-07-15 12:15:29,228 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:113 - match - match success: ([[243, 985], [321, 1063]], (0.6619718309859155, 0.717948717948718, 1.0, 0.9736551440651242))

Out[5]:

[[243, 985], [321, 1063]]

In [6]:

sc = loadimg("/home/zhao/Documents/mower-profile/screenshot/201/20240714214339.png", True)
plt.imshow(sc, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:29,239 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/mower-profile/screenshot/201/20240714214339.png

No description has been provided for this image

In [7]:

res = loadres("control_central", True)
plt.imshow(res, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:29,479 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/arknights-mower/arknights_mower/resources/control_central.png

No description has been provided for this image

In [8]:

matcher = Matcher(sc)
2024-07-15 12:15:29,653 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:77 - __init__ - Matcher init: shape ((1080, 1920))

In [9]:

matcher.match(res, draw=True, dpi_aware=True)

No description has been provided for this image

2024-07-15 12:15:30,082 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:202 - score - transform matrix: [[0.7535227826125278, -0.0005473631013470435, 1097.909614955585], [-0.0013096213809555084, 0.754970238050705, 239.22899092320966]]

No description has been provided for this image

No description has been provided for this image

2024-07-15 12:15:30,562 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:113 - match - match success: ([[1098, 239], [1294, 360]], (0.0953819594302978, 0.8839385106013371, 0.9375, 0.8595908226210209))

Out[9]:

[[1098, 239], [1294, 360]]

In [10]:

sc = loadimg("/home/zhao/Documents/mower-profile/screenshot/1105/20240712065207.png", True)
plt.imshow(sc, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:30,575 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/mower-profile/screenshot/1105/20240712065207.png

No description has been provided for this image

In [11]:

res = loadimg("/home/zhao/Documents/mower-profile/screenshot/1106/20240712065212.png", True)
plt.imshow(res, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:30,821 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/mower-profile/screenshot/1106/20240712065212.png

No description has been provided for this image

In [12]:

res = cropimg(res, ((1020, 230), (1210, 280)))
plt.imshow(res, cmap="gray", vmin=0, vmax=255)
plt.show()

No description has been provided for this image

In [13]:

matcher = Matcher(sc)
2024-07-15 12:15:31,162 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:77 - __init__ - Matcher init: shape ((1080, 1920))

In [14]:

matcher.match(res, draw=True, dpi_aware=True)

No description has been provided for this image

2024-07-15 12:15:31,483 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:202 - score - transform matrix: [[1.1167040828189694, -0.018270101836457227, 1014.5181388435077], [-0.0008505324769905506, 1.1183497106314426, 610.7774407553333]]

No description has been provided for this image

No description has been provided for this image

2024-07-15 12:15:31,865 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:113 - match - match success: ([[1015, 611], [1227, 667]], (0.050080775444264945, 0.6736842105263158, 0.875, 0.6841249306767808))

Out[14]:

[[1015, 611], [1227, 667]]

In [15]:

sc = loadimg("/home/zhao/Documents/Desktop/crc/108/20240222230009.png", True)
plt.imshow(sc, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:31,876 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/Desktop/crc/108/20240222230009.png

No description has been provided for this image

In [16]:

res = loadres("login_captcha", True)
plt.imshow(res, cmap="gray", vmin=0, vmax=255)
plt.show()
2024-07-15 12:15:32,137 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/image.py:44 - loadimg - /home/zhao/Documents/arknights-mower/arknights_mower/resources/login_captcha.png

No description has been provided for this image

In [17]:

matcher = Matcher(sc)
2024-07-15 12:15:32,268 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:77 - __init__ - Matcher init: shape ((1080, 1920))

In [18]:

matcher.match(res, draw=True, dpi_aware=True)

No description has been provided for this image

2024-07-15 12:15:32,606 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:202 - score - transform matrix: [[0.860710131969706, 0.004565988396697833, 646.7586268579719], [0.002056726918675809, 0.8712260893573366, 639.807371571572]]

No description has been provided for this image

No description has been provided for this image

2024-07-15 12:15:33,141 - DEBUG - /home/zhao/Documents/arknights-mower/arknights_mower/utils/matcher.py:113 - match - match success: ([[647, 640], [778, 865]], (0.1348314606741573, 0.8102526539250424, 1.0, 0.9463482497394052))

Out[18]:

[[647, 640], [778, 865]]