主线关卡导航改进
All checks were successful
ci/woodpecker/push/check_format Pipeline was successful

This commit is contained in:
zhbaor 2025-01-03 17:32:45 +08:00
parent d1d9758c61
commit 8eb222b6d3
2 changed files with 34 additions and 12 deletions

View file

@ -6,7 +6,7 @@ import cv2
from mower.solvers.navigation.utils import generate_name from mower.solvers.navigation.utils import generate_name
from mower.utils import config from mower.utils import config
from mower.utils.graph import SceneGraphSolver from mower.utils.graph import SceneGraphSolver
from mower.utils.image import thres2 from mower.utils.image import cropimg, loadres
from mower.utils.log import logger from mower.utils.log import logger
from mower.utils.scene import Scene from mower.utils.scene import Scene
from mower.utils.vector import va, vs from mower.utils.vector import va, vs
@ -531,15 +531,39 @@ class NavigationSolver(SceneGraphSolver):
if not isinstance(self.prefix, int): if not isinstance(self.prefix, int):
self.back() self.back()
return return
act_scope = ((300, 315), (400, 370)) if self.animation():
return
if self.find(f"navigation/act/{self.act}", scope=act_scope): img = cropimg(config.recog.gray, ((300, 315), (405, 370)))
if pos := self.find(f"navigation/main/{self.prefix}"): act, score = 0, 0
self.tap(pos) for i in range(3):
else: result = cv2.matchTemplate(
self.swipe_ext([(932, 554), (1425, 554)], [300], 500, 0.5) img, loadres(f"navigation/act/{i}", True), cv2.TM_CCOEFF_NORMED
else: )
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if max_val > score:
act, score = i, max_val
if self.act > act:
self.ctap((251, 846), 3)
return
elif self.act < act:
self.ctap((230, 175), 3) self.ctap((230, 175), 3)
return
prefix_scope = ((1150, 250), (1700, 780))
img = cropimg(config.recog.gray, prefix_scope)
prefix, score = 0, 0
for i in range(15):
result = cv2.matchTemplate(
img, loadres(f"navigation/main/{i}", True), cv2.TM_CCOEFF_NORMED
)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
if max_val > score:
prefix, score = i, max_val
if self.prefix > prefix:
self.swipe_ext([(1425, 554), (932, 554)], [300], 500)
elif self.prefix < prefix:
self.swipe_ext([(932, 554), (1425, 554)], [300], 500)
else:
self.tap(prefix_scope)
elif scene == Scene.TERMINAL_BIOGRAPHY: elif scene == Scene.TERMINAL_BIOGRAPHY:
if self.prefix not in ["OF"]: if self.prefix not in ["OF"]:
self.back() self.back()

View file

@ -285,9 +285,6 @@ template_matching = {
"mission_daily_on": ((685, 15), (1910, 100)), "mission_daily_on": ((685, 15), (1910, 100)),
"mission_weekly": ((685, 15), (1910, 100)), "mission_weekly": ((685, 15), (1910, 100)),
"mission_weekly_on": ((685, 15), (1910, 100)), "mission_weekly_on": ((685, 15), (1910, 100)),
"navigation/act/0": (309, 318),
"navigation/act/1": (309, 319),
"navigation/act/2": (307, 319),
"navigation/collection/AP_entry": ((0, 170), (1920, 870)), "navigation/collection/AP_entry": ((0, 170), (1920, 870)),
"navigation/collection/CA_entry": ((0, 170), (1920, 870)), "navigation/collection/CA_entry": ((0, 170), (1920, 870)),
"navigation/collection/CE_entry": ((0, 170), (1920, 870)), "navigation/collection/CE_entry": ((0, 170), (1920, 870)),
@ -400,6 +397,7 @@ template_matching_score = {
"connecting": 0.7, "connecting": 0.7,
"fight/pause": 0.8, "fight/pause": 0.8,
"navigation/episode": 0.7, "navigation/episode": 0.7,
"navigation/ope_difficulty": 0.7,
"navigation/ope_hard": 0.7, "navigation/ope_hard": 0.7,
"navigation/ope_hard_small": 0.7, "navigation/ope_hard_small": 0.7,
"navigation/ope_normal": 0.7, "navigation/ope_normal": 0.7,