File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,11 @@ def find_cost_bar_roi(width: int, height: int) -> Roi:
4040
4141
4242def _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 :
You can’t perform that action at this time.
0 commit comments