diff --git a/module/base/button.py b/module/base/button.py index 4c206838d..5b5dc1507 100644 --- a/module/base/button.py +++ b/module/base/button.py @@ -57,12 +57,12 @@ class Button(Resource): return load_image(self.file, self.area) @cached_property - def image_binary(self): - return rgb2gray(self.image) + def image_luma(self): + return rgb2luma(self.image) def resource_release(self): del_cached_property(self, 'image') - del_cached_property(self, 'image_binary') + del_cached_property(self, 'image_luma') self.clear_offset() def __str__(self): @@ -119,7 +119,7 @@ class Button(Resource): self._button_offset = np.array(point) + self.search[:2] - self.area[:2] return sim > similarity - def match_template_binary(self, image, similarity=0.85, direct_match=False) -> bool: + def match_template_luma(self, image, similarity=0.85, direct_match=False) -> bool: """ Detects assets by template matching. @@ -135,8 +135,8 @@ class Button(Resource): """ if not direct_match: image = crop(image, self.search, copy=False) - image = rgb2gray(image) - res = cv2.matchTemplate(self.image_binary, image, cv2.TM_CCOEFF_NORMED) + image = rgb2luma(image) + res = cv2.matchTemplate(self.image_luma, image, cv2.TM_CCOEFF_NORMED) _, sim, _, point = cv2.minMaxLoc(res) self._button_offset = np.array(point) + self.search[:2] - self.area[:2] @@ -254,9 +254,9 @@ class ButtonWrapper(Resource): return True return False - def match_template_binary(self, image, similarity=0.85, direct_match=False) -> bool: + def match_template_luma(self, image, similarity=0.85, direct_match=False) -> bool: for assets in self.buttons: - if assets.match_template_binary(image, similarity=similarity, direct_match=direct_match): + if assets.match_template_luma(image, similarity=similarity, direct_match=direct_match): self._matched_button = assets return True return False diff --git a/tasks/base/ui.py b/tasks/base/ui.py index 185c36ce1..ffcaebd5e 100644 --- a/tasks/base/ui.py +++ b/tasks/base/ui.py @@ -314,11 +314,11 @@ class UI(MainPage): return False appear = False - if MAIN_GOTO_CHARACTER.match_template_binary(self.device.image): + if MAIN_GOTO_CHARACTER.match_template_luma(self.device.image): if self.image_color_count(MAIN_GOTO_CHARACTER, color=(235, 235, 235), threshold=234, count=400): appear = True if not appear: - if MAP_EXIT.match_template_binary(self.device.image): + if MAP_EXIT.match_template_luma(self.device.image): if self.image_color_count(MAP_EXIT, color=(235, 235, 235), threshold=221, count=50): appear = True @@ -334,7 +334,7 @@ class UI(MainPage): return False appear = False - if MAP_EXIT.match_template_binary(self.device.image): + if MAP_EXIT.match_template_luma(self.device.image): if self.image_color_count(MAP_EXIT, color=(235, 235, 235), threshold=221, count=50): appear = True