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