From 68847167ddbdf5d8ef1e946d318eca6a31724bf6 Mon Sep 17 00:00:00 2001 From: yuming Date: Fri, 18 Sep 2026 22:04:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E5=8B=BE=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E5=8A=A8=E6=80=81=E8=A1=8C=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=9B=BA=E5=AE=9A=E6=AD=A5=E9=95=BF?= =?UTF-8?q?=E6=BC=8F=E6=A3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前用固定步长204采样y坐标,与实际行位置不匹配, 只检测到5个角标(实际16个),导致等待逻辑永远超时。 改为每次截图后重新 detect_card_rows 检测实际行位置。 --- automate.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/automate.py b/automate.py index bd2c7cd..9b6625b 100644 --- a/automate.py +++ b/automate.py @@ -347,21 +347,13 @@ def get_checked_cells_dynamic(png_path, row_centers): def count_checked_badges(png_path): - """统计整屏已打勾(蓝色角标)的卡片数量,不依赖行坐标。 - 等待期间列表可能轻微滚动,用绝对坐标检测打勾会偏移, - 改为直接扫描整屏蓝色角标总数,不受行位置漂移影响。""" + """统计整屏已打勾(蓝色角标)的卡片数量。 + 先用 detect_card_rows 检测实际行位置,再逐行逐列检测打勾, + 避免固定步长与实际行位置不匹配导致漏检。""" try: - with Image.open(png_path) as img: - img = img.convert("RGB") - w, h = img.size - cnt = 0 - # 扫描卡片区域内所有可能的角标位置(3列 × 多行) - for gx in THUMB_X: - for cy in range(ROW_Y0 + 100, ROW_Y1, ROW_PITCH): - bx, by = gx + BADGE_OFFSET[0], cy + BADGE_OFFSET[1] - if count_blue_pixels(png_path, bx, by) >= BLUE_THRESHOLD: - cnt += 1 - return cnt + rows = detect_card_rows(png_path) + checked = get_checked_cells_dynamic(png_path, rows) + return sum(1 for v in checked.values() if v) except Exception: return 0