diff --git a/assets/images/test.png b/assets/images/test.png index bc58e95..2879957 100644 Binary files a/assets/images/test.png and b/assets/images/test.png differ diff --git a/main.py b/main.py index 0548765..8ba4b49 100644 --- a/main.py +++ b/main.py @@ -23,7 +23,7 @@ if __name__ == '__main__': # if loc is not None: # x, y = loc # 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: x, y = loc moveTo(x, y) diff --git a/utils/cv2.py b/utils/cv2.py index 1bb5569..e177f88 100644 --- a/utils/cv2.py +++ b/utils/cv2.py @@ -23,13 +23,14 @@ def match_resize(src: Image, tmpl: str, similarity=0.9, step=10, fast=False): if fast: if found is not None and found_location is not None: 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 tmp_r = r # 如果我们找到了一个新的最大校正值,更新簿记变量值 - if found is None or ( - found_location is not None and found_location[2] >= similarity and found_location[2] > found[2]): + if found is None or (found_location is not None and found_location[2] > found[2]): found = found_location + if found is not None and found[2] >= similarity: + break if found is None: return None x, y, _ = found