From 5b1ea48948dc8ac45759955688ddf34580a36c8a Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Tue, 21 Nov 2023 21:36:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E5=A6=82=E6=9E=9C=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E5=85=AC=E6=8B=9B=E6=97=B6=E5=BC=80=E5=8C=85=E4=BC=9A=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=97=A0=E9=99=90=E5=BE=AA=E7=8E=AF=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/utils/solver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arknights_mower/utils/solver.py b/arknights_mower/utils/solver.py index 73755c664..ff903d402 100644 --- a/arknights_mower/utils/solver.py +++ b/arknights_mower/utils/solver.py @@ -324,6 +324,8 @@ def back_to_index(self): self.tap_element('double_confirm', 0.8) elif self.scene() == Scene.NETWORK_CHECK: self.tap_element('double_confirm', 0.2) + elif self.scene() == Scene.RECRUIT_AGENT: + self.tap((self.recog.w // 2, self.recog.h // 2)) elif self.scene() == Scene.MAIL: mail = self.find('mail') mid_y = (mail[0][1] + mail[1][1]) // 2 From 1ec06909bb8342a20fedbac17bbed3778f331c18 Mon Sep 17 00:00:00 2001 From: EightyDollars Date: Tue, 21 Nov 2023 21:44:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E5=BC=80=E5=8C=85?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E6=89=BE=E5=88=B0=E5=BC=80=E5=8C=85=E6=97=B6=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/recruit.py | 57 +++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/arknights_mower/solvers/recruit.py b/arknights_mower/solvers/recruit.py index 8be50dd87..a881bc798 100644 --- a/arknights_mower/solvers/recruit.py +++ b/arknights_mower/solvers/recruit.py @@ -334,32 +334,41 @@ def recruit_tags(self): logger.info(f'第{self.recruit_pos + 1}个位置上的公招预测结果:{"随机三星干员"}') def recruit_result(self): - agent = None - gray_img = cropimg(self.recog.gray, ((800, 600), (1500, 1000))) - - img_binary = cv2.threshold(gray_img, 220, 255, cv2.THRESH_BINARY)[1] - max = 0 - get_path = "" - - for template_name in result_template_list: - tem_path = f"{__rootdir__}/resources/agent_name/{template_name}.png" - template_ = cv2.imdecode(np.fromfile(tem_path.__str__(), dtype=np.uint8), cv2.IMREAD_GRAYSCALE) - res = cv2.matchTemplate(img_binary, template_, cv2.TM_CCORR_NORMED) - min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) - if max < max_val: - get_path = tem_path - max = max_val - if max > 0.7: - break + try: + agent = None + gray_img = cropimg(self.recog.gray, ((800, 600), (1500, 1000))) + + img_binary = cv2.threshold(gray_img, 220, 255, cv2.THRESH_BINARY)[1] + max = 0 + get_path = "" + + for template_name in result_template_list: + tem_path = f"{__rootdir__}/resources/agent_name/{template_name}.png" + template_ = cv2.imdecode(np.fromfile(tem_path.__str__(), dtype=np.uint8), cv2.IMREAD_GRAYSCALE) + res = cv2.matchTemplate(img_binary, template_, cv2.TM_CCORR_NORMED) + min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) + if max < max_val: + get_path = tem_path + max = max_val + if max > 0.7: + break - if max > 0.7: - agent_id = os.path.basename(get_path) - agent_id = agent_id.replace(".png", "") - agent = recruit_agent[agent_id]['name'] + if max > 0.7: + agent_id = os.path.basename(get_path) + agent_id = agent_id.replace(".png", "") + agent = recruit_agent[agent_id]['name'] - if agent is not None: - # 汇总开包结果 - self.result_agent[str(self.recruit_pos + 1)] = agent + if agent is not None: + # 汇总开包结果 + self.result_agent[str(self.recruit_pos + 1)] = agent + except Exception as e: + logger.error(f"公招开包异常{e}") + self.send_message(f"公招开包异常{e}") + except cv2.Error as e: + logger.error(f"公招开包异常{e}") + self.send_message(f"公招开包异常{e}") + except: + pass self.tap((self.recog.w // 2, self.recog.h // 2))