From 4ce807309654bd6274a0bb57d1e31a39ce36a9fc Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Thu, 23 Nov 2023 16:08:51 +0800 Subject: [PATCH] perf(sweep): simplify sweep num ocr --- tasks/stage/sweep.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tasks/stage/sweep.py b/tasks/stage/sweep.py index e98b076..a304527 100644 --- a/tasks/stage/sweep.py +++ b/tasks/stage/sweep.py @@ -119,18 +119,7 @@ class StageSweep: return main.appear(self.skip_skip) or main.appear(self.skip_ok_upper) or main.appear(self.skip_ok_lower) def load_sweep_num(self, main: ModuleBase): - timer = Timer(0.5, 2).start() - while 1: - main.device.screenshot() - if not timer.reached_and_reset(): - continue - ocr_result = list(filter(lambda x: x.ocr_text.isdigit(), self.num.detect_and_ocr(main.device.image))) - if not ocr_result: - logger.warning(f'No valid num in {self.num.name}') - continue - if len(ocr_result) == 1: - self.current_sweep = int(ocr_result[0].ocr_text) - return + self.current_sweep = self.num.ocr_single_line(main.device.image) def set_sweep_num(self, main: ModuleBase, skip_first_screenshot=True) -> bool: num = self.sweep_num