This commit is contained in:
mgleed
2022-05-31 21:24:29 -04:00
parent 58d2834949
commit d41771a6c4
2 changed files with 4 additions and 4 deletions

View File

@@ -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:

View File

@@ -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(