fix: 打勾计数改用动态行检测,修复固定步长漏检
之前用固定步长204采样y坐标,与实际行位置不匹配, 只检测到5个角标(实际16个),导致等待逻辑永远超时。 改为每次截图后重新 detect_card_rows 检测实际行位置。
This commit is contained in:
+6
-14
@@ -347,21 +347,13 @@ def get_checked_cells_dynamic(png_path, row_centers):
|
|||||||
|
|
||||||
|
|
||||||
def count_checked_badges(png_path):
|
def count_checked_badges(png_path):
|
||||||
"""统计整屏已打勾(蓝色角标)的卡片数量,不依赖行坐标。
|
"""统计整屏已打勾(蓝色角标)的卡片数量。
|
||||||
等待期间列表可能轻微滚动,用绝对坐标检测打勾会偏移,
|
先用 detect_card_rows 检测实际行位置,再逐行逐列检测打勾,
|
||||||
改为直接扫描整屏蓝色角标总数,不受行位置漂移影响。"""
|
避免固定步长与实际行位置不匹配导致漏检。"""
|
||||||
try:
|
try:
|
||||||
with Image.open(png_path) as img:
|
rows = detect_card_rows(png_path)
|
||||||
img = img.convert("RGB")
|
checked = get_checked_cells_dynamic(png_path, rows)
|
||||||
w, h = img.size
|
return sum(1 for v in checked.values() if v)
|
||||||
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
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user