Fix: Try without preprocess if no doors matched

This commit is contained in:
LmeSzinc 2024-05-14 01:49:31 +08:00
parent acf72b18d5
commit 415fa61df9
2 changed files with 9 additions and 2 deletions

View File

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

View File

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