From d41771a6c4e45bdbb07ded46baf48c4e1bafce8a Mon Sep 17 00:00:00 2001 From: mgleed Date: Tue, 31 May 2022 21:24:29 -0400 Subject: [PATCH] fix --- src/pather.py | 2 +- src/template_finder.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pather.py b/src/pather.py index 4eeaf82..220709c 100644 --- a/src/pather.py +++ b/src/pather.py @@ -706,7 +706,7 @@ if __name__ == "__main__": display_img = img.copy() template_map = {} template_scores = {} - for template_type in template_finder._templates: + for template_type in template_finder.stored_templates().keys(): if filter is None or filter in template_type: template_match = template_finder.search(template_type, img, use_grayscale=True, threshold=0.78) if template_match.valid: diff --git a/src/template_finder.py b/src/template_finder.py index 5d8244f..42192eb 100644 --- a/src/template_finder.py +++ b/src/template_finder.py @@ -43,7 +43,7 @@ TEMPLATE_PATHS = [ ] @cache -def _templates() -> dict[Template]: +def stored_templates() -> dict[Template]: paths = [] templates = {} for path in TEMPLATE_PATHS: @@ -64,7 +64,7 @@ def _templates() -> dict[Template]: def get_template(key): with templates_lock: - return _templates()[key].img_bgr + return stored_templates()[key].img_bgr def _process_template_refs(ref: Union[str, np.ndarray, list[str]]) -> list[Template]: templates = [] @@ -73,7 +73,7 @@ def _process_template_refs(ref: Union[str, np.ndarray, list[str]]) -> list[Templ for i in ref: # if the reference is a string, then it's a reference to a named template asset if type(i) == str: - templates.append(_templates()[i.upper()]) + templates.append(stored_templates()[i.upper()]) # if the reference is an image, append new Template class object elif type(i) == np.ndarray: templates.append(Template(