Skip to content

[ActivityShikigami/爬塔] Boss入口模板尺寸不匹配导致 OpenCV 断言 #1702

Description

@w116525

在提问之前...

  • 我已经搜索了现有的 issues
  • 我在提问题之前至少花费了 5 分钟来思考和准备
  • 我已经阅读了文档中的 常见问题(FAQ)
  • 这个问题出现了至少三次,不是偶发的
  • 我使用 OAS 的 dev 分支

描述你的问题

毗沙门天的爬塔活动正常,不相互产的爬塔出现异常,截屏方案什么的都调过了,不能解决,

如何复现

  1. 前往 '...'
  2. 点击 '....'
  3. 滑动到 '....'
  4. 出现问题

预期行为

No response

相关 Logs

ERROR    2026-07-26 18:59:27.708 │ error: OpenCV(4.7.0)
         D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\templmatch.cpp:1175: error: (-215:Assertion failed)
         _img.size().height <= _templ.size().height && _img.size().width <= _templ.size().width in function
         'cv::matchTemplate'

         ╭───────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────╮
         │ D:\yysoas\OnmyojiAutoScript-easy-install\script.py:562 in run                                               │
         │                                                                                                             │
         │   559 │   │   │   module_path = str(Path.cwd() / 'tasks' / command / (module_name+'.py'))                   │
         │   560 │   │   │   logger.info(f'module_path: {module_path}, module_name: {module_name}')                    │
         │   561 │   │   │   task_module = load_module(module_name, module_path)                                       │
         │ ❱ 562 │   │   │   task_module.ScriptTask(config=self.config, device=self.device).run()                      │
         │   563 │   │   except TaskEnd:                                                                               │
         │   564 │   │   │   return True                                                                               │
         │   565 │   │   except GameNotRunningError as e:                                                              │
         │                                                                                                             │
         │ ╭──────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮ │
         │ │     command = 'ActivityShikigami'                                                                       │ │
         │ │           e = error("OpenCV(4.7.0)                                                                      │ │
         │ │               D:\\a\\opencv-python\\opencv-python\\opencv\\modules\\imgproc\\src\\templmatch.cpp:1175:  │ │
         │ │               error: (-215:Assertion failed) _img.size().height <= _templ.size().height &&              │ │
         │ │               _img.size().width <= _templ.size().width in function 'cv::matchTemplate'\n")              │ │
         │ │ module_name = 'script_task'                                                                             │ │
         │ │ module_path = 'D:\\yysoas\\OnmyojiAutoScript-easy-install\\tasks\\ActivityShikigami\\script_task.py'    │ │
         │ │        self = <script.Script object at 0x000001F338A1D3F0>                                              │ │
         │ │ task_module = <module 'script_task' from                                                                │ │
         │ │               'D:\\yysoas\\OnmyojiAutoScript-easy-install\\tasks\\ActivityShikigami\\script_task.py'>   │ │
         │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
         │                                                                                                             │
         │ D:\yysoas\OnmyojiAutoScript-easy-install\tasks\ActivityShikigami\script_task.py:159 in run                  │
         │                                                                                                             │
         │   156 │   │   │   self.ui_goto(game.page_climb_act)                                                         │
         │   157 │   │   │   try:                                                                                      │
         │   158 │   │   │   │   method_func = getattr(self, f'_run_{climb_type}')                                     │
         │ ❱ 159 │   │   │   │   method_func()                                                                         │
         │   160 │   │   │   except LimitCountOut as e:                                                                │
         │   161 │   │   │   │   self.ui_click(self.I_UI_BACK_YELLOW, stop=self.I_TO_BATTLE_MAIN,                      │
         │       interval=1)                                                                                           │
         │   162 │   │   │   except LimitTimeOut as e:                                                                 │
         │                                                                                                             │
         │ ╭──────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮ │
         │ │  climb_type = 'boss'                                                                                    │ │
         │ │ method_func = <bound method ScriptTask._run_boss of <script_task.ScriptTask object at                   │ │
         │ │               0x000001F33C20FFD0>>                                                                      │ │
         │ │        self = <script_task.ScriptTask object at 0x000001F33C20FFD0>                                     │ │
         │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
         │                                                                                                             │
         │ D:\yysoas\OnmyojiAutoScript-easy-install\tasks\ActivityShikigami\script_task.py:254 in _run_boss            │
         │                                                                                                             │
         │   251 │   │   """                                                                                           │
         │   252 │   │   logger.hr(f'Start run climb type BOSS')                                                       │
         │   253 │   │                                                                                                 │
         │ ❱ 254 │   │   self.ui_clicks([self.I_TO_BATTLE_BOSS],                                                       │
         │   255 │   │   │   │   │      stop=self.I_CHECK_BATTLE_BOSS, interval=1)                                     │
         │   256                                                                                                       │
         │   257                                                                                                       │
         │                                                                                                             │
         │ ╭─────────────────────────── locals ───────────────────────────╮                                            │
         │ │ self = <script_task.ScriptTask object at 0x000001F33C20FFD0> │                                            │
         │ ╰──────────────────────────────────────────────────────────────╯                                            │
         │                                                                                                             │
         │ D:\yysoas\OnmyojiAutoScript-easy-install\tasks\base_task.py:757 in ui_clicks                                │
         │                                                                                                             │
         │   754 │   def ui_clicks(self, clicks: list[RuleImage | RuleOcr | RuleClick], stop: RuleImage,               │
         │       interval=1):                                                                                          │
         │   755 │   │   while 1:                                                                                      │
         │   756 │   │   │   self.screenshot()                                                                         │
         │ ❱ 757 │   │   │   if self.appear(stop):                                                                     │
         │   758 │   │   │   │   break                                                                                 │
         │   759 │   │   │   for click in clicks:                                                                      │
         │   760 │   │   │   │   if isinstance(click, RuleImage) and self.appear_then_click(click,                     │
         │       interval=interval):                                                                                   │
         │                                                                                                             │
         │ ╭───────────────────────────── locals ─────────────────────────────╮                                        │
         │ │   clicks = [AS_TO_BATTLE_BOSS]                                   │                                        │
         │ │ interval = 1                                                     │                                        │
         │ │     self = <script_task.ScriptTask object at 0x000001F33C20FFD0> │                                        │
         │ │     stop = AS_CHECK_BATTLE_BOSS                                  │                                        │
         │ ╰──────────────────────────────────────────────────────────────────╯                                        │
         │                                                                                                             │
         │ D:\yysoas\OnmyojiAutoScript-easy-install\tasks\base_task.py:179 in appear                                   │
         │                                                                                                             │
         │   176 │   │   if isinstance(target, RuleOcr):                                                               │
         │   177 │   │   │   appear = self.ocr_appear(target, interval)                                                │
         │   178 │   │   else:                                                                                         │
         │ ❱ 179 │   │   │   appear = target.match(self.device.image, threshold=threshold)                             │
         │   180 │   │                                                                                                 │
         │   181 │   │   if appear and interval:                                                                       │
         │   182 │   │   │   self.interval_timer[target.name].reset()                                                  │
         │                                                                                                             │
         │ ╭───────────────────────────── locals ──────────────────────────────╮                                       │
         │ │  interval = None                                                  │                                       │
         │ │      self = <script_task.ScriptTask object at 0x000001F33C20FFD0> │                                       │
         │ │    target = AS_CHECK_BATTLE_BOSS                                  │                                       │
         │ │ threshold = None                                                  │                                       │
         │ ╰───────────────────────────────────────────────────────────────────╯                                       │
         │                                                                                                             │
         │ D:\yysoas\OnmyojiAutoScript-easy-install\module\atom\image.py:160 in match                                  │
         │                                                                                                             │
         │   157 │   │   │   logger.error(f"Template image is invalid: {mat.shape}")                                   │
         │   158 │   │   │   return False  # 模板无效,匹配失败                                                        │
         │   159 │   │                                                                                                 │
         │ ❱ 160 │   │   res = cv2.matchTemplate(source, mat, cv2.TM_CCOEFF_NORMED)                                    │
         │   161 │   │   min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)  #                                    │
         │       最小匹配度,最大匹配度,最小匹配度的坐标,最大匹配度的坐标                                            │
         │   162 │   │   if self.debug_mode:                                                                           │
         │   163 │   │   │   logger.attr(self.name, f'matching score {max_val:.5f}')                                   │
         │                                                                                                             │
         │ ╭────────────────────── locals ───────────────────────╮                                                     │
         │ │     image = array([[[209, 182, 181],                │                                                     │
         │ │             │   │   [208, 182, 180],                │                                                     │
         │ │             │   │   [206, 181, 180],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [125, 118, 151],                │                                                     │
         │ │             │   │   [126, 119, 152],                │                                                     │
         │ │             │   │   [125, 118, 151]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[209, 181, 179],                │                                                     │
         │ │             │   │   [210, 181, 180],                │                                                     │
         │ │             │   │   [206, 179, 179],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [125, 119, 152],                │                                                     │
         │ │             │   │   [128, 121, 154],                │                                                     │
         │ │             │   │   [128, 121, 154]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[209, 180, 179],                │                                                     │
         │ │             │   │   [210, 180, 179],                │                                                     │
         │ │             │   │   [208, 179, 178],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [126, 120, 153],                │                                                     │
         │ │             │   │   [128, 121, 154],                │                                                     │
         │ │             │   │   [127, 120, 153]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      ...,                             │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[154,  98, 122],                │                                                     │
         │ │             │   │   [190, 130, 155],                │                                                     │
         │ │             │   │   [190, 127, 153],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [124, 135, 138],                │                                                     │
         │ │             │   │   [124, 135, 138],                │                                                     │
         │ │             │   │   [124, 135, 139]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[143,  89, 112],                │                                                     │
         │ │             │   │   [188, 128, 153],                │                                                     │
         │ │             │   │   [189, 125, 151],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [122, 136, 138],                │                                                     │
         │ │             │   │   [122, 136, 138],                │                                                     │
         │ │             │   │   [122, 136, 139]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[148,  95, 117],                │                                                     │
         │ │             │   │   [176, 117, 141],                │                                                     │
         │ │             │   │   [188, 124, 150],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [121, 136, 139],                │                                                     │
         │ │             │   │   [121, 136, 139],                │                                                     │
         │ │             │   │   [121, 136, 139]]], dtype=uint8) │                                                     │
         │ │       mat = array([[[ 75,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [ 77,  68,  49],                │                                                     │
         │ │             │   │   [ 77,  68,  49],                │                                                     │
         │ │             │   │   [ 77,  68,  49]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[ 77,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [ 77,  68,  49],                │                                                     │
         │ │             │   │   [ 77,  68,  49],                │                                                     │
         │ │             │   │   [ 76,  68,  49]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[ 80,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   [ 77,  69,  49],                │                                                     │
         │ │             │   │   [ 74,  69,  49]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      ...,                             │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[132, 110,  80],                │                                                     │
         │ │             │   │   [128, 109,  75],                │                                                     │
         │ │             │   │   [132, 113,  74],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [132, 113,  74],                │                                                     │
         │ │             │   │   [132, 117,  74],                │                                                     │
         │ │             │   │   [132, 114,  74]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[137, 116,  88],                │                                                     │
         │ │             │   │   [135, 116,  82],                │                                                     │
         │ │             │   │   [132, 113,  74],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [132, 115,  74],                │                                                     │
         │ │             │   │   [132, 117,  74],                │                                                     │
         │ │             │   │   [132, 114,  74]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[140, 120,  93],                │                                                     │
         │ │             │   │   [140, 121,  85],                │                                                     │
         │ │             │   │   [132, 114,  74],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [132, 116,  75],                │                                                     │
         │ │             │   │   [132, 117,  75],                │                                                     │
         │ │             │   │   [132, 114,  74]]], dtype=uint8) │                                                     │
         │ │      self = AS_CHECK_BATTLE_BOSS                    │                                                     │
         │ │    source = array([[[145,  78, 110],                │                                                     │
         │ │             │   │   [139,  71, 103],                │                                                     │
         │ │             │   │   [133,  65,  97],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [161,  91, 118],                │                                                     │
         │ │             │   │   [159,  89, 116],                │                                                     │
         │ │             │   │   [158,  88, 115]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[147,  79, 111],                │                                                     │
         │ │             │   │   [141,  73, 105],                │                                                     │
         │ │             │   │   [132,  65,  97],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [162,  92, 119],                │                                                     │
         │ │             │   │   [160,  90, 117],                │                                                     │
         │ │             │   │   [158,  88, 115]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[149,  81, 113],                │                                                     │
         │ │             │   │   [143,  75, 107],                │                                                     │
         │ │             │   │   [135,  68, 100],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [162,  93, 120],                │                                                     │
         │ │             │   │   [161,  91, 118],                │                                                     │
         │ │             │   │   [161,  91, 118]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      ...,                             │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[218, 200, 225],                │                                                     │
         │ │             │   │   [218, 201, 226],                │                                                     │
         │ │             │   │   [218, 202, 227],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [181,  99, 130],                │                                                     │
         │ │             │   │   [182,  99, 130],                │                                                     │
         │ │             │   │   [182,  98, 130]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[188, 172, 198],                │                                                     │
         │ │             │   │   [189, 173, 199],                │                                                     │
         │ │             │   │   [191, 175, 201],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [181,  99, 130],                │                                                     │
         │ │             │   │   [181,  99, 130],                │                                                     │
         │ │             │   │   [181,  99, 130]],               │                                                     │
         │ │             │                                       │                                                     │
         │ │             │      [[166, 141, 171],                │                                                     │
         │ │             │   │   [166, 142, 171],                │                                                     │
         │ │             │   │   [167, 142, 172],                │                                                     │
         │ │             │   │   ...,                            │                                                     │
         │ │             │   │   [181,  99, 130],                │                                                     │
         │ │             │   │   [181,  99, 130],                │                                                     │
         │ │             │   │   [181,  99, 130]]], dtype=uint8) │                                                     │
         │ │ threshold = 0.8                                     │                                                     │
         │ ╰─────────────────────────────────────────────────────╯                                                     │
         ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
         error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\templmatch.cpp:1175: error:
         (-215:Assertion failed) _img.size().height <= _templ.size().height && _img.size().width <= _templ.size().width
         in function 'cv::matchTemplate'

WARNING  2026-07-26 18:59:31.975 │ Saving error: ./log/error/1785063571975
INFO     2026-07-26 18:59:31.978 │ 保存详细错误的日志和截图到路径:
INFO     2026-07-26 18:59:31.981 │ D:\yysoas\OnmyojiAutoScript-easy-install\log\error\1785063571975
INFO     2026-07-26 18:59:32.274 │ Notifier: OAS1
INFO     2026-07-26 18:59:32.278 │ Script oas1 process exit
ERROR    2026-07-26 18:59:32.280 │ Error: 1

报错时游戏的截图/别的截图

Image

还有别的吗?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions