From 257e092936f6cab29dfcfbcccb701eff18f6f621 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Wed, 29 Nov 2023 13:10:47 +0800 Subject: [PATCH] refactor(sweep): use regex for index match --- tasks/stage/list.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tasks/stage/list.py b/tasks/stage/list.py index 9294d82..a6bb916 100644 --- a/tasks/stage/list.py +++ b/tasks/stage/list.py @@ -1,3 +1,5 @@ +import re + import numpy as np from module.base.base import ModuleBase @@ -50,7 +52,8 @@ class StageList: def load_stage_indexes(self, main: ModuleBase): self.current_indexes = list( - filter(lambda x: x.ocr_text.isdigit(), self.index_ocr.detect_and_ocr(main.device.image)) + filter(lambda x: re.match(r'^\d{1,2}-?\d?$', x.ocr_text), + self.index_ocr.detect_and_ocr(main.device.image)) ) if not self.current_indexes: logger.warning(f'No valid index in {self.index_ocr.name}')