This commit is contained in:
shikong 2023-09-17 16:37:43 +08:00
parent 6aee19b84b
commit f95b0b741d
3 changed files with 5 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -23,7 +23,7 @@ if __name__ == '__main__':
# if loc is not None: # if loc is not None:
# x, y = loc # x, y = loc
# moveTo(x, y) # moveTo(x, y)
loc = utils.cv2.match_resize(pim, "assets/images/win_win10.png", 0.8) loc = utils.cv2.match_resize(pim, "assets/images/test.png", 0.8)
if loc is not None: if loc is not None:
x, y = loc x, y = loc
moveTo(x, y) moveTo(x, y)

View File

@ -23,13 +23,14 @@ def match_resize(src: Image, tmpl: str, similarity=0.9, step=10, fast=False):
if fast: if fast:
if found is not None and found_location is not None: if found is not None and found_location is not None:
print(found[2], found_location[2]) print(found[2], found_location[2])
if tmp_r < r and found[2] > found_location[2]: if tmp_r < r and found[2] > found_location[2] and found[2] >= similarity:
break break
tmp_r = r tmp_r = r
# 如果我们找到了一个新的最大校正值,更新簿记变量值 # 如果我们找到了一个新的最大校正值,更新簿记变量值
if found is None or ( if found is None or (found_location is not None and found_location[2] > found[2]):
found_location is not None and found_location[2] >= similarity and found_location[2] > found[2]):
found = found_location found = found_location
if found is not None and found[2] >= similarity:
break
if found is None: if found is None:
return None return None
x, y, _ = found x, y, _ = found