Skip to content

Commit dd1a514

Browse files
committed
♻️ refactor(commissions): 改进ocr图像参数传递
- ocr函数现在接收frame的副本作为参数
1 parent 65e4a91 commit dd1a514

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/tasks/AutoDefence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def handle_mission_start(self):
145145
if self.external_movement is not _default_movement:
146146
self.log_info("任务开始,执行外部移动逻辑")
147147
self.external_movement()
148-
self.log_info(f"外部移动执行完毕,等待战斗开始,{DEFAULT_ACTION_TIMEOUT}秒后超时")
148+
self.log_info(f"外部移动执行完毕,等待战斗开始,{DEFAULT_ACTION_TIMEOUT+10}秒后超时")
149149
if not self.wait_until(lambda: self.current_wave != -1, post_action=self.get_wave_info,
150-
time_out=DEFAULT_ACTION_TIMEOUT):
150+
time_out=DEFAULT_ACTION_TIMEOUT+10):
151151
self.log_info("等待战斗开始超时,重开任务")
152152
self.open_in_mission_menu()
153153
else:

src/tasks/AutoHedge.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def handle_in_mission(self):
147147
if self.external_movement_evac is not _default_movement:
148148
self.log_info("任务结束")
149149
self.external_movement_evac()
150-
self.log_info(f"外部移动执行完毕。")
150+
self.log_info("外部移动执行完毕。")
151151
self.wait_until(lambda: not self.in_team(), time_out=30)
152152
return
153153
else:
@@ -159,9 +159,9 @@ def handle_mission_start(self):
159159
if self.external_movement is not _default_movement:
160160
self.log_info("任务开始")
161161
self.external_movement()
162-
self.log_info(f"外部移动执行完毕,等待战斗开始,{DEFAULT_ACTION_TIMEOUT}秒后超时")
162+
self.log_info(f"外部移动执行完毕,等待战斗开始,{DEFAULT_ACTION_TIMEOUT+10}秒后超时")
163163
if not self.wait_until(self.runtime_state["in_progress"], post_action=self.update_mission_status,
164-
time_out=DEFAULT_ACTION_TIMEOUT):
164+
time_out=DEFAULT_ACTION_TIMEOUT+10):
165165
self.log_info("超时重开")
166166
self.open_in_mission_menu()
167167
return
@@ -204,9 +204,11 @@ def get_serum_process_info(self):
204204
if pct > self.last_ocr_result and pct <= 100:
205205
self.last_ocr_result = pct
206206
# self.info_set("进度", f"{pct}%")
207+
return self.last_ocr_result
207208
if self.ocr_future is None:
208209
box = self.box_of_screen_scaled(2560, 1440, 115, 399, 217, 461, name="process_info", hcenter=True)
209-
self.ocr_future = self.thread_pool_executor.submit(self.ocr, box=box, match=re.compile(r"\d+%"))
210+
frame = self.frame.copy()
211+
self.ocr_future = self.thread_pool_executor.submit(self.ocr, frame=frame, box=box, match=re.compile(r"\d+%"))
210212
return self.last_ocr_result
211213

212214
def find_top_right_track_pos(self):

src/tasks/CommissionsTask.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ def get_wave_info(self):
350350
if self.wave_future is None:
351351
mission_info_box = self.box_of_screen_scaled(2560, 1440, 275, 372, 445, 470, name="mission_info",
352352
hcenter=True)
353-
self.wave_future = self.thread_pool_executor.submit(self.ocr, box=mission_info_box,
353+
frame = self.frame.copy()
354+
self.wave_future = self.thread_pool_executor.submit(self.ocr, frame=frame,
355+
box=mission_info_box,
354356
frame_processor=isolate_white_text_to_black,
355357
match=re.compile(r"\d/\d"))
356358

0 commit comments

Comments
 (0)