Skip to content

Commit 770eaac

Browse files
authored
fix(ui): 修复章节导航时 OCR 稳定判定缺陷导致切过头 (#430) (#433)
将 _read_chapter_stable 的稳定策略从3次采样取众数>=2票改为最后连续两次一致。这样在章节切换动画期间,[旧, 旧, 新] 的采样结果会被正确判定为不稳定,避免在已到达目标章节时因误判旧值而多点一次,导致切过头。 Fixes #430
1 parent 3d7e4f4 commit 770eaac

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

autowsgr/ui/map/panels/sortie.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,16 @@ def _read_chapter_stable(samples: int = 3) -> tuple[int | None, np.ndarray | Non
210210
if not chapters:
211211
return None, last_screen, False
212212

213-
candidate = max(set(chapters), key=chapters.count)
214-
votes = chapters.count(candidate)
215-
stable = votes >= 2
216-
if not stable:
213+
# 稳定策略:优先以“最后连续两次一致”为准,防止过渡态旧值占多数
214+
if len(chapters) >= 2 and chapters[-1] == chapters[-2]:
215+
candidate = chapters[-1]
216+
stable = True
217+
elif len(chapters) == samples and len(set(chapters)) == 1:
218+
candidate = chapters[0]
219+
stable = True
220+
else:
221+
candidate = max(set(chapters), key=chapters.count) if chapters else None
222+
stable = False
217223
_log.warning('[UI] 章节导航: OCR 抖动 {},本轮不点击', chapters)
218224
return candidate, last_screen, stable
219225

0 commit comments

Comments
 (0)