Skip to content

Commit 3e9b10a

Browse files
committed
fix(tick): 遮挡检测——灰色遮挡物截断白色填充返回 None
_contiguous_fill_width 检测到 edge 后仍有白色像素 → 灰色遮挡物截断 → None。 get_filled_pixel_width 在 result==0 且 ROI 左端非灰度 → 遮挡物在左端 → None。 鼠标/部署 UI 遮挡费用条时不再返回偏小宽度或 0,改为 None → TimeSource hold。
1 parent fd9ab67 commit 3e9b10a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

aao/core/timing/tick.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ def find_cost_bar_roi(width: int, height: int) -> Roi:
4040

4141

4242
def _contiguous_fill_width(white: np.ndarray, valid: np.ndarray) -> int | None:
43-
"""左→右扫描:从 x1 起的连续白像素数。无桥接(避免部署 UI 杂散白误判)。"""
43+
"""左→右扫描:从 x1 起的连续白像素数。无桥接(避免部署 UI 杂散白误判)。
44+
45+
如果非白像素之后仍有白色像素(灰色遮挡物夹在白色填充中间)→ 返回 None
46+
(费用条被遮挡,宽度不可信)。
47+
"""
4448
total = len(white)
4549
if not white[0]:
4650
return 0
@@ -50,6 +54,10 @@ def _contiguous_fill_width(white: np.ndarray, valid: np.ndarray) -> int | None:
5054
return total
5155
edge = int(not_white_after[0])
5256
if valid[edge:].all():
57+
# edge 之后全是灰度 → 正常费用条末端,返回 edge
58+
# 但如果 edge 之后还有白色像素 → 灰色遮挡物截断了白色填充 → None
59+
if white[edge:].any():
60+
return None
5361
return edge
5462
return None
5563

@@ -114,6 +122,13 @@ def get_filled_pixel_width(frame: np.ndarray, roi: Roi) -> int | None:
114122
if r is not None:
115123
result = r
116124

125+
# --- 遮挡检测:result==0 但 ROI 左端有遮挡物 → None ---
126+
# 鼠标/部署 UI 遮住费用条左端时,white[0]=False 且 mw[0]=False → result=0。
127+
# 但 ROI 左端像素不是灰度背景(是遮挡物)→ 返回 None(不可信)。
128+
# 正常空费用条:左端是灰色背景(gray[0]=True)→ 返回 0。
129+
if result == 0 and not gray[0]:
130+
return None
131+
117132
# --- 灰色扩展(部署遮罩外费用条是灰色 ~155,继续扫 >150)---
118133
# 只在白色填充接近遮罩边缘时才扩展(避免低填充时把遮罩灰色背景误认为填充)
119134
if result >= _GRAY_EXT_MIN and result < total:

0 commit comments

Comments
 (0)