From 415fa61df95267840d839c785a41b7844dfebe44 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 14 May 2024 01:49:31 +0800 Subject: [PATCH] Fix: Try without preprocess if no doors matched --- module/ocr/ocr.py | 7 +++++-- tasks/rogue/route/exit.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/module/ocr/ocr.py b/module/ocr/ocr.py index 82fb32d39..2fa29aa03 100644 --- a/module/ocr/ocr.py +++ b/module/ocr/ocr.py @@ -422,9 +422,12 @@ class Duration(Ocr): class OcrWhiteLetterOnComplexBackground(Ocr): + white_preprocess = True + def pre_process(self, image): - image = extract_white_letters(image, threshold=255) - image = cv2.merge([image, image, image]) + if self.white_preprocess: + image = extract_white_letters(image, threshold=255) + image = cv2.merge([image, image, image]) return image def detect_and_ocr(self, *args, **kwargs): diff --git a/tasks/rogue/route/exit.py b/tasks/rogue/route/exit.py index d3fc611c4..c5d45ee48 100644 --- a/tasks/rogue/route/exit.py +++ b/tasks/rogue/route/exit.py @@ -235,6 +235,10 @@ class RogueExit(CombatInteract): ocr = OcrDomainExit(OCR_DOMAIN_EXIT) results = ocr.matched_ocr(image, keyword_classes=MapPlane) + # Try without preprocess + if not len(results): + ocr.white_preprocess = False + results = ocr.matched_ocr(image, keyword_classes=MapPlane) centers = [area_center(result.area) for result in results] logger.info(f'DomainDoor: {centers}') directions = [self.screen2direction(center) for center in centers]