Просмотр исходного кода

Merge pull request #774 from ljxun/dev_switchsoul

refactor(Component/SwitchSoul): 优化式神录切换操作- 调整了多个图像资源的 ROI 区域,提高匹配准确性
huangrunheng 1 год назад
Родитель
Сommit
a0b3146585

+ 7 - 5
tasks/Component/SwitchSoul/assets.py

@@ -33,15 +33,15 @@ class SwitchSoulAssets:
 	# 退出式神录 
 	I_RECORD_SOUL_BACK = RuleImage(roi_front=(19,9,51,44), roi_back=(19,9,51,44), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_record_soul_back.png")
 	# 预设 
-	I_SOUL_PRESET = RuleImage(roi_front=(332,70,90,51), roi_back=(332,70,90,51), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_soul_preset.png")
+	I_SOUL_PRESET = RuleImage(roi_front=(335,73,90,51), roi_back=(310,57,169,72), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_soul_preset.png")
 	# description 
-	I_SOU_SWITCH_1 = RuleImage(roi_front=(971,148,37,35), roi_back=(971,148,37,35), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_1.png")
+	I_SOU_SWITCH_1 = RuleImage(roi_front=(971,149,34,32), roi_back=(962,141,51,48), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_1.png")
 	# description 
-	I_SOU_SWITCH_2 = RuleImage(roi_front=(978,304,27,29), roi_back=(978,304,27,29), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_2.png")
+	I_SOU_SWITCH_2 = RuleImage(roi_front=(967,296,42,39), roi_back=(961,292,54,49), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_2.png")
 	# description 
-	I_SOU_SWITCH_3 = RuleImage(roi_front=(973,454,26,26), roi_back=(973,454,26,26), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_3.png")
+	I_SOU_SWITCH_3 = RuleImage(roi_front=(968,448,41,38), roi_back=(962,442,52,48), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_3.png")
 	# description 
-	I_SOU_SWITCH_4 = RuleImage(roi_front=(971,600,37,26), roi_back=(971,600,37,26), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_4.png")
+	I_SOU_SWITCH_4 = RuleImage(roi_front=(967,597,42,25), roi_back=(962,592,53,34), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_4.png")
 	# description 
 	I_SOU_SWITCH_SURE = RuleImage(roi_front=(668,401,180,61), roi_back=(668,401,180,61), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_sure.png")
 	# 用于判断是否在式神录里面 
@@ -64,6 +64,8 @@ class SwitchSoulAssets:
 	I_SOU_TEAM_PRESENT = RuleImage(roi_front=(737,82,148,43), roi_back=(727,71,165,63), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_team_present.png")
 	# 需要切换的预设按钮(颜色深一点) 
 	I_SOU_CLICK_PRESENT = RuleImage(roi_front=(967,305,43,22), roi_back=(965,142,48,480), threshold=0.9, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_click_present.png")
+	# 误触点到式神检查 
+	I_CHECK_BLOCK = RuleImage(roi_front=(572,408,137,49), roi_back=(572,408,137,49), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_check_block.png")
 
 
 	# Ocr Rule Assets

+ 19 - 10
tasks/Component/SwitchSoul/ss/image.json

@@ -11,8 +11,8 @@
   {
     "itemName": "soul_preset",
     "imageName": "ss_soul_preset.png",
-    "roiFront": "332,70,90,51",
-    "roiBack": "332,70,90,51",
+    "roiFront": "335,73,90,51",
+    "roiBack": "310,57,169,72",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "预设"
@@ -20,8 +20,8 @@
   {
     "itemName": "sou_switch_1",
     "imageName": "ss_sou_switch_1.png",
-    "roiFront": "971,148,37,35",
-    "roiBack": "971,148,37,35",
+    "roiFront": "971,149,34,32",
+    "roiBack": "962,141,51,48",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -29,8 +29,8 @@
   {
     "itemName": "sou_switch_2",
     "imageName": "ss_sou_switch_2.png",
-    "roiFront": "978,304,27,29",
-    "roiBack": "978,304,27,29",
+    "roiFront": "967,296,42,39",
+    "roiBack": "961,292,54,49",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -38,8 +38,8 @@
   {
     "itemName": "sou_switch_3",
     "imageName": "ss_sou_switch_3.png",
-    "roiFront": "973,454,26,26",
-    "roiBack": "973,454,26,26",
+    "roiFront": "968,448,41,38",
+    "roiBack": "962,442,52,48",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -47,8 +47,8 @@
   {
     "itemName": "sou_switch_4",
     "imageName": "ss_sou_switch_4.png",
-    "roiFront": "971,600,37,26",
-    "roiBack": "971,600,37,26",
+    "roiFront": "967,597,42,25",
+    "roiBack": "962,592,53,34",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -151,5 +151,14 @@
     "method": "Template matching",
     "threshold": 0.9,
     "description": "需要切换的预设按钮(颜色深一点)"
+  },
+  {
+    "itemName": "check_block",
+    "imageName": "ss_check_block.png",
+    "roiFront": "572,408,137,49",
+    "roiBack": "572,408,137,49",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "误触点到式神检查"
   }
 ]

BIN
tasks/Component/SwitchSoul/ss/ss_check_block.png


BIN
tasks/Component/SwitchSoul/ss/ss_sou_switch_1.png


BIN
tasks/Component/SwitchSoul/ss/ss_sou_switch_2.png


BIN
tasks/Component/SwitchSoul/ss/ss_sou_switch_3.png


BIN
tasks/Component/SwitchSoul/ss/ss_sou_switch_4.png


BIN
tasks/Component/SwitchSoul/ss/ss_soul_preset.png


+ 4 - 2
tasks/Component/SwitchSoul/switch_soul.py

@@ -100,7 +100,7 @@ class SwitchSoul(BaseTask, SwitchSoulAssets):
                 break
             cur_text = ocr_text
             # 向上滑动
-            self.swipe(self.S_SS_GROUP_SWIPE_UP, 0.5)
+            self.swipe(self.S_SS_GROUP_SWIPE_UP, 1.5)
             # 等待滑动动画
             sleep(0.5)
 
@@ -129,10 +129,12 @@ class SwitchSoul(BaseTask, SwitchSoulAssets):
                 while 1:
                     self.click(self.I_SOU_SWITCH_SURE, 3)
                     self.screenshot()
+                    if self.appear_then_click(self.I_CHECK_BLOCK, 3):
+                        continue
                     if not self.appear(self.I_SOU_SWITCH_SURE):
                         break
                 continue
-            if not self.appear_then_click(target_team, interval=1):
+            if not self.appear_then_click(target_team, interval=3):
                 logger.warning(f'Click team {team} failed in group {group}')
 
         logger.info(f'Switch soul_one group {group} team {team}')