|
|
@@ -129,6 +129,31 @@ class EvidenceV2Params:
|
|
|
# 通道会把门框/铰链算成多根(C70E 实测 20 根)。
|
|
|
vehicle_min_span_ratio: float = 0.50
|
|
|
vehicle_max_posts: int = 60
|
|
|
+ # P0-Q9:空车(敞车、车斗内无箱)识别 → `state=3`。
|
|
|
+ # 判据只用车体侧墙顶线(texture_top)以下那一片侧墙,要求它是**完整的一节
|
|
|
+ # 敞车侧墙**:门板立柱 3~16 根、横跨 ≥empty_min_span_ratio、侧墙不透明占比
|
|
|
+ # 高、有“八”字斜撑,并且这段侧墙在画面里足够高(≥empty_min_wall_h_ratio)。
|
|
|
+ # 载车为什么过不了:
|
|
|
+ # * 平车 + 集装箱 → 侧墙 ROI 其实是集装箱瓦楞(18~63 根 > max_door_posts);
|
|
|
+ # * 敞车 + 罐箱(箱底被车帮挡住)→ 车帮被箱压到画面底部,可见墙高只有
|
|
|
+ # ~13%(实测 04_container_on_gondola),`empty_min_wall_h_ratio` 挡掉。
|
|
|
+ empty_vehicle_enable: bool = True
|
|
|
+ empty_min_posts: int = 3
|
|
|
+ empty_min_span_ratio: float = 0.60
|
|
|
+ empty_min_opacity: float = 0.55
|
|
|
+ empty_min_wall_h_ratio: float = 0.25
|
|
|
+ # 空车判据专用的“竖棱最短长度 / 侧墙 ROI 高”。必须比 `body_min_post_len_ratio`
|
|
|
+ # (0.15)严:真正敞车门板立柱贯穿侧墙(>0.5×ROI),而平车车面下方的地面/噪声
|
|
|
+ # 只有碎短竖棱;用 0.15 会把地面当成“完整敞车侧墙” → 把 2 压成 3/255。
|
|
|
+ empty_min_post_len_ratio: float = 0.30
|
|
|
+ # 空车判据的斜撑门(与 `min_diagonal_braces` 分开,便于现场按车型单独放宽)。
|
|
|
+ empty_min_diagonal_braces: int = 1
|
|
|
+ # 车体顶相对搜索窗顶的最小余量(×画幅高)。0 = 不设门槛:车把画面填满
|
|
|
+ # (`02_C70E` 实测 texture_top≈2% 画幅)时也用整个窗口做侧墙 ROI,靠
|
|
|
+ # `empty_*` 那组门来判断——否则“空车占满画面”这一类永远进不来。
|
|
|
+ empty_top_margin_ratio: float = 0.0
|
|
|
+ # 空车 `3` 是否允许提交(与 allow_state2 同级;false = 只识别、不提交)。
|
|
|
+ allow_state3: bool = True
|
|
|
# P0-Q3:`1`(敞车)还必须有"八"字斜撑/三角撑证据(docs/edge_evidence.md §4.1)。
|
|
|
# 容器侧壁只有瓦楞、没有斜撑 → 防"上层箱坐在下层箱上"被判成敞车。
|
|
|
# 0 = 关闭该门(只用于对照实验,现场不要关)。
|
|
|
@@ -267,6 +292,15 @@ class EvidenceV2Params:
|
|
|
body_min_posts=int(raw.get("body_min_posts", 3)),
|
|
|
vehicle_min_span_ratio=float(raw.get("vehicle_min_span_ratio", 0.50)),
|
|
|
vehicle_max_posts=int(raw.get("vehicle_max_posts", 60)),
|
|
|
+ empty_vehicle_enable=bool(raw.get("empty_vehicle_enable", True)),
|
|
|
+ empty_min_posts=int(raw.get("empty_min_posts", 3)),
|
|
|
+ empty_min_span_ratio=float(raw.get("empty_min_span_ratio", 0.60)),
|
|
|
+ empty_min_opacity=float(raw.get("empty_min_opacity", 0.55)),
|
|
|
+ empty_min_wall_h_ratio=float(raw.get("empty_min_wall_h_ratio", 0.25)),
|
|
|
+ empty_min_post_len_ratio=float(raw.get("empty_min_post_len_ratio", 0.30)),
|
|
|
+ empty_min_diagonal_braces=int(raw.get("empty_min_diagonal_braces", 1)),
|
|
|
+ empty_top_margin_ratio=float(raw.get("empty_top_margin_ratio", 0.0)),
|
|
|
+ allow_state3=bool(raw.get("allow_state3", True)),
|
|
|
min_diagonal_braces=int(raw.get("min_diagonal_braces", 1)),
|
|
|
min_wall_opacity=float(raw.get("min_wall_opacity", 0.35)),
|
|
|
max_flat_gap_px=float(raw.get("max_flat_gap_px", 40.0)),
|
|
|
@@ -289,7 +323,7 @@ class EvidenceV2Params:
|
|
|
require_commit=bool(raw.get("require_commit", True)),
|
|
|
allow_state2=bool(raw.get("allow_state2", True)),
|
|
|
structure_hits_min=float(raw.get("structure_hits_min", 0.60)),
|
|
|
- min_bed_roi_px=int(raw.get("min_bed_roi_px", 90)),
|
|
|
+ min_bed_roi_px=int(raw.get("min_bed_roi_px", 90)),
|
|
|
reject_hoist_high=bool(raw.get("reject_hoist_high", True)),
|
|
|
hoist_dark_max=int(raw.get("hoist_dark_max", 75)),
|
|
|
hoist_band_frac=float(raw.get("hoist_band_frac", 0.035)),
|
|
|
@@ -341,6 +375,10 @@ class EvidenceV2Result:
|
|
|
body_span: float = 0.0
|
|
|
body_opacity: float = 0.0
|
|
|
body_diagonal: int = 0
|
|
|
+ # P0-Q9:本帧是否按“空车(敞车、车斗内无箱)”判出 `state=3`;
|
|
|
+ # `empty_reason` 记录未通过的那一道门(`empty_span` / `empty_wall_short` …)。
|
|
|
+ empty_vehicle: bool = False
|
|
|
+ empty_reason: str = ""
|
|
|
below_roi: Tuple[int, int, int, int] = (0, 0, 0, 0)
|
|
|
diagnostics: Dict[str, object] = field(default_factory=dict)
|
|
|
|
|
|
@@ -351,7 +389,7 @@ class EvidenceV2Result:
|
|
|
return int(self.state)
|
|
|
|
|
|
def publishable(self, require_commit: bool = True) -> bool:
|
|
|
- if int(self.state) not in (0, 1, 2):
|
|
|
+ if int(self.state) not in (0, 1, 2, 3):
|
|
|
return False
|
|
|
if not require_commit:
|
|
|
return True
|
|
|
@@ -1162,12 +1200,125 @@ class EvidenceV2:
|
|
|
return int(len(np.asarray(circles).reshape(-1, 3)))
|
|
|
|
|
|
# ------------------------------------------------------------ 车体测量
|
|
|
+ def _detect_empty_vehicle(self, gray: np.ndarray,
|
|
|
+ window: Tuple[int, int, int, int],
|
|
|
+ texture_top: float,
|
|
|
+ scale: float,
|
|
|
+ box_bottom: Optional[float] = None,
|
|
|
+ deck_edge: bool = False,
|
|
|
+ main_posts: int = 0,
|
|
|
+ main_post_span: float = 0.0) -> Optional[Dict[str, object]]:
|
|
|
+ """空车(敞车、车斗内无箱)证据 —— P0-Q9,判据见 ``EvidenceV2Params``。
|
|
|
+
|
|
|
+ 与旧 `body_fallback`(“空车歧义帧一律 255”)的区别:这里要求侧墙 ROI
|
|
|
+ 在画面里**足够高**(`empty_min_wall_h_ratio`),并要求门板阵列**横跨
|
|
|
+ 整车**(`empty_min_span_ratio`)。因此它只在“能看见一整节空敞车侧墙”
|
|
|
+ 时成立;罐箱把车帮压到画面底部时侧墙只有十几 % 高,过不了。
|
|
|
+
|
|
|
+ 返回 ``None`` = 没有车体证据;否则返回 dict:
|
|
|
+ * ``ok``:是否满足空车门(严格)
|
|
|
+ * ``basic``:是否满足旧口径的车体结构门(宽松,用于保留“歧义弃权”)
|
|
|
+ * ``reason`` / ``stats`` / ``roi`` / ``confidence`` / ``hits``
|
|
|
+ """
|
|
|
+
|
|
|
+ p = self.p
|
|
|
+ if not p.empty_vehicle_enable:
|
|
|
+ return None
|
|
|
+ wh, ww = gray.shape[:2]
|
|
|
+ if texture_top <= 0.0:
|
|
|
+ return None
|
|
|
+ if texture_top < window[1] + p.empty_top_margin_ratio * wh:
|
|
|
+ return None
|
|
|
+ wy0 = max(int(window[1]), int(round(texture_top)))
|
|
|
+ wy1 = min(int(window[3]), wh - 1)
|
|
|
+ if wy1 <= wy0:
|
|
|
+ return None
|
|
|
+ # 侧墙 ROI 到底多少:用 `body_bottom_ratio`(与旧车体兜底同一口径),
|
|
|
+ # 而“可见墙高”按 到窗口底 的绝对高度算 —— 两者用途不同,不要混。
|
|
|
+ wall_h_ratio = float(wy1 - wy0) / max(1.0, float(wh))
|
|
|
+ wy1 = min(wy1, int(round(texture_top + p.body_bottom_ratio * (wy1 - texture_top))))
|
|
|
+ if wy1 <= wy0:
|
|
|
+ return None
|
|
|
+ bx0 = max(0, int(round(p.body_x_margin_ratio * ww)))
|
|
|
+ bx1 = min(ww - 1, int(round((1.0 - p.body_x_margin_ratio) * ww)))
|
|
|
+ roi = (bx0, wy0, bx1, wy1)
|
|
|
+ b = self._measure_body(gray, roi, scale,
|
|
|
+ post_len_ratio=p.empty_min_post_len_ratio)
|
|
|
+ # 低分辨率/低对比素材上,严格竖棱门可能“一根都数不到”(03_C70EA 512 px
|
|
|
+ # 实测 0 根),而宽松门能数到 3 根;反过来 02_C70E 用宽松门会数到 20 根
|
|
|
+ # (>max_door_posts)。所以**先严格、数不够再回退宽松**,其余门不变。
|
|
|
+ if (int(b["posts"]) < p.empty_min_posts
|
|
|
+ and p.body_min_post_len_ratio < p.empty_min_post_len_ratio):
|
|
|
+ b = self._measure_body(gray, roi, scale,
|
|
|
+ post_len_ratio=p.body_min_post_len_ratio)
|
|
|
+ stats = {
|
|
|
+ "posts": int(b["posts"]),
|
|
|
+ "span": float(b["span"]),
|
|
|
+ "opacity": float(b["opacity"]),
|
|
|
+ "diagonal": int(b["diagonal"]),
|
|
|
+ "height": float(b["height"]),
|
|
|
+ "wall_h_ratio": wall_h_ratio,
|
|
|
+ }
|
|
|
+ out: Dict[str, object] = {"ok": False, "basic": False, "stats": stats, "roi": roi}
|
|
|
+ if b["height"] < p.body_min_roi_px:
|
|
|
+ out["reason"] = "empty_roi_small"
|
|
|
+ return out
|
|
|
+ # 若“薄车面边梁 + 车面下暗带”(平车特征)出现在这段“侧墙”**之上**,
|
|
|
+ # 说明这段“墙”其实是平车车面以下的地面/堆场 —— 不能当敞车侧墙。
|
|
|
+ # (平车 + 集装箱的 texture_top 常落在车面下方的地面上。)
|
|
|
+ if deck_edge and box_bottom is not None and float(box_bottom) <= texture_top:
|
|
|
+ out["reason"] = "empty_wall_below_deck"
|
|
|
+ return out
|
|
|
+ # 正常路径已经在箱底下方看到一簇**窄跨度**竖棱(span < min_post_span_ratio)
|
|
|
+ # → 那是平车的车轮/制动梁/端部结构(实测 B 片段 postx=666..858,span≈0.20),
|
|
|
+ # 不是敞车侧墙。此时整段 ROI 里的"立柱"也只是同一簇结构,不能判空车。
|
|
|
+ if main_posts >= 2 and main_post_span < p.min_post_span_ratio:
|
|
|
+ out["reason"] = "empty_narrow_post_cluster"
|
|
|
+ return out
|
|
|
+ basic = (
|
|
|
+ p.body_min_posts <= b["posts"] <= p.max_door_posts
|
|
|
+ and b["span"] >= p.min_post_span_ratio
|
|
|
+ and b["opacity"] >= p.body_min_opacity
|
|
|
+ and b["diagonal"] >= p.min_diagonal_braces
|
|
|
+ )
|
|
|
+ out["basic"] = bool(basic)
|
|
|
+ if wall_h_ratio < p.empty_min_wall_h_ratio:
|
|
|
+ out["reason"] = "empty_wall_short"
|
|
|
+ return out
|
|
|
+ if not (p.empty_min_posts <= b["posts"] <= p.max_door_posts):
|
|
|
+ out["reason"] = "empty_posts"
|
|
|
+ return out
|
|
|
+ if b["span"] < p.empty_min_span_ratio:
|
|
|
+ out["reason"] = "empty_span"
|
|
|
+ return out
|
|
|
+ if b["opacity"] < p.empty_min_opacity:
|
|
|
+ out["reason"] = "empty_opacity"
|
|
|
+ return out
|
|
|
+ if b["diagonal"] < p.empty_min_diagonal_braces:
|
|
|
+ out["reason"] = "empty_braces"
|
|
|
+ return out
|
|
|
+ out["ok"] = True
|
|
|
+ out["reason"] = "empty_vehicle"
|
|
|
+ out["confidence"] = min(
|
|
|
+ 1.0, 0.60 + 0.10 * min(1.0, b["posts"] / 8.0) + 0.20 * b["opacity"]
|
|
|
+ )
|
|
|
+ out["hits"] = min(1.0, 0.45 + 0.04 * b["posts"] + 0.25 * b["opacity"])
|
|
|
+ return out
|
|
|
+
|
|
|
def _measure_body(self, gray: np.ndarray, roi: Tuple[int, int, int, int],
|
|
|
- scale: float) -> Dict[str, float]:
|
|
|
+ scale: float,
|
|
|
+ post_len_ratio: Optional[float] = None) -> Dict[str, float]:
|
|
|
"""车体 ROI 的结构证据(与 C++ ``measure_body`` 同口径)。
|
|
|
|
|
|
返回 ``posts`` / ``span``(立柱跨度 ÷ ROI 宽)/ ``opacity``(不透明占比)/
|
|
|
``diagonal``(斜撑数)/ ``height``(原图像素高度)。
|
|
|
+
|
|
|
+ ``post_len_ratio`` 覆盖“竖棱最短长度占 ROI 高的比例”:
|
|
|
+ * 默认用 ``body_min_post_len_ratio``(0.15):箱体瓦楞被锈迹/铆钉打断
|
|
|
+ 成短段时也要数得出来(平车兜底/罐箱判 1 用);
|
|
|
+ * 空车判据传 ``empty_min_post_len_ratio``(0.30):要求门板立柱**贯穿
|
|
|
+ 侧墙**,地面/噪声里的碎短竖棱不算立柱(否则平车车面下方的地面会被
|
|
|
+ 当成“完整敞车侧墙”)。
|
|
|
"""
|
|
|
|
|
|
structure = detect_structure_v2(
|
|
|
@@ -1175,7 +1326,10 @@ class EvidenceV2:
|
|
|
# C++ `measure_body` 用的是 `body_min_post_len_ratio`(0.15),
|
|
|
# 不是主判据的 `min_post_len_ratio`(0.30):后者会把集装箱
|
|
|
# 波纹这种"被锈迹/铆钉打断的短竖棱"全部滤掉(1920 宽图上数到 0 根)。
|
|
|
- min_post_len_ratio=self.p.body_min_post_len_ratio,
|
|
|
+ min_post_len_ratio=(
|
|
|
+ float(post_len_ratio) if post_len_ratio is not None
|
|
|
+ else self.p.body_min_post_len_ratio
|
|
|
+ ),
|
|
|
cluster_gap_px=9.0, scale=scale,
|
|
|
)
|
|
|
positions = structure.get("post_positions") or []
|
|
|
@@ -1271,6 +1425,15 @@ class EvidenceV2:
|
|
|
# (门板立柱 + 斜撑 + 不透明侧墙)仍可见。这里退化为“只看车体”:
|
|
|
# 判得出 → 敞车 1(gap 记 0:箱在车斗内,不存在间隙);
|
|
|
# 判不出 → 仍按 `no_box` 弃权,**绝不**因此猜成平车。
|
|
|
+ #
|
|
|
+ # P0-Q9:先看是不是**空车**——若 texture_top 以下是一整节空敞车侧墙
|
|
|
+ # (墙高 ≥25%、门板 3~16 根横跨整车、斜撑在),输出 3 而不是 1。
|
|
|
+ # 罐箱载车只剩画面底部一条薄车帮(实测墙高 ~13%),过不了这道门,
|
|
|
+ # 仍然走下面的 vehicle_wall → 1。
|
|
|
+ empty = self._detect_empty_vehicle(gray, window, texture_top, scale)
|
|
|
+ wall_state, wall_reason = 1, "vehicle_wall"
|
|
|
+ if empty is not None and empty["ok"]:
|
|
|
+ wall_state, wall_reason = 3, "empty_vehicle"
|
|
|
if self.p.body_fallback_enable:
|
|
|
# ROI 用整个搜索窗口:罐箱会把 texture_top 定到车帮上沿,
|
|
|
# 按 texture_top 取 ROI 只剩几十像素,数不到立柱。
|
|
|
@@ -1287,13 +1450,19 @@ class EvidenceV2:
|
|
|
and body["span"] >= self.p.vehicle_min_span_ratio
|
|
|
and body["opacity"] >= self.p.body_min_opacity
|
|
|
and body["diagonal"] >= self.p.min_diagonal_braces):
|
|
|
- conf = min(1.0, 0.55 + 0.25 * min(1.0, body["posts"] / 8.0)
|
|
|
- + 0.15 * body["opacity"])
|
|
|
- hits = min(1.0, 0.40 + 0.05 * body["posts"]
|
|
|
- + 0.20 * body["opacity"])
|
|
|
+ if wall_state == 3:
|
|
|
+ # 空车:证据换成 texture_top 以下那一片侧墙(与 3 的门同一份 ROI)
|
|
|
+ body = dict(empty["stats"]) # type: ignore[arg-type]
|
|
|
+ conf = float(empty["confidence"])
|
|
|
+ hits = float(empty["hits"])
|
|
|
+ else:
|
|
|
+ conf = min(1.0, 0.55 + 0.25 * min(1.0, body["posts"] / 8.0)
|
|
|
+ + 0.15 * body["opacity"])
|
|
|
+ hits = min(1.0, 0.40 + 0.05 * body["posts"]
|
|
|
+ + 0.20 * body["opacity"])
|
|
|
commit = self.tracker.update(
|
|
|
ts,
|
|
|
- state=1,
|
|
|
+ state=wall_state,
|
|
|
gap_m=0.0,
|
|
|
gap_px=0.0,
|
|
|
structure_hits=hits,
|
|
|
@@ -1304,10 +1473,12 @@ class EvidenceV2:
|
|
|
hoist_high=bool(hoist_high),
|
|
|
)
|
|
|
self._last = EvidenceV2Result(
|
|
|
- state=1,
|
|
|
+ state=wall_state,
|
|
|
confidence=conf,
|
|
|
view=self.p.view,
|
|
|
- class_reason="vehicle_wall",
|
|
|
+ class_reason=wall_reason,
|
|
|
+ empty_vehicle=(wall_state == 3),
|
|
|
+ empty_reason=("empty_vehicle" if wall_state == 3 else ""),
|
|
|
texture_top_y=(float(texture_top) / max(scale, 1e-6)
|
|
|
if texture_top > 0.0 else None),
|
|
|
body_posts=int(body["posts"]),
|
|
|
@@ -1562,44 +1733,43 @@ class EvidenceV2:
|
|
|
body = None
|
|
|
body_stats = None
|
|
|
body_roi = None
|
|
|
- # P0-Q6:空车/无箱兜底。旧条件还要求“纹理车体顶明显低于窗口顶”(有天空),
|
|
|
- # 于是“车把画面填满”的空敞车(`02_C70E_shigure03.jpg`,texture_top≈窗口顶)
|
|
|
- # 永远进不来,只能弃权。现在只要找到车体顶就试一次;真正的守门是
|
|
|
- # posts ∈ [body_min_posts, max_door_posts] —— 集装箱侧壁波纹(实测 18~31 根)
|
|
|
- # 会被上限挡掉,不会被误判成门板阵列。
|
|
|
- # 与 C++ 同口径:只有"车体上方能看到天空/背景"(纹理车体顶明显低于窗口顶)
|
|
|
- # 时才试车体兜底;车把画面填满时不做(那是 `ambiguous_empty_vehicle` 的地盘)。
|
|
|
- if (self.p.body_fallback_enable and texture_top > 0.0 and state != 1
|
|
|
- and texture_top > window[1] + 0.05 * wh):
|
|
|
- by0 = max(int(window[1]), int(round(texture_top)))
|
|
|
- by1 = min(int(window[3]), int(round(
|
|
|
- texture_top + self.p.body_bottom_ratio * (window[3] - texture_top))))
|
|
|
- if by1 > by0:
|
|
|
- bx0 = max(0, int(round(self.p.body_x_margin_ratio * ww)))
|
|
|
- bx1 = min(ww - 1, int(round((1.0 - self.p.body_x_margin_ratio) * ww)))
|
|
|
- body_roi = (bx0, by0, bx1, by1)
|
|
|
- b = self._measure_body(gray, body_roi, scale)
|
|
|
- body_stats = {
|
|
|
- "posts": int(b["posts"]),
|
|
|
- "span": float(b["span"]),
|
|
|
- "diagonal": int(b["diagonal"]),
|
|
|
- "opacity": float(b["opacity"]),
|
|
|
- }
|
|
|
- if (b["height"] >= self.p.body_min_roi_px
|
|
|
- and self.p.body_min_posts <= b["posts"] <= self.p.max_door_posts
|
|
|
- and b["span"] >= self.p.min_post_span_ratio
|
|
|
- and b["opacity"] >= self.p.body_min_opacity
|
|
|
- and b["diagonal"] >= self.p.min_diagonal_braces):
|
|
|
- # P0-Q7(2026-11-19 客户口径):**空车(无箱)一律弃权**,不判 1/2。
|
|
|
- # 车体结构说明"这是敞车",但车上没有箱;给 1 会被 PLC 理解成
|
|
|
- # "箱已在车斗内、可以作业",属于危险输出。与
|
|
|
- # `ambiguous_empty_vehicle` 同口径(02/03 两张空车图必须一致)。
|
|
|
+ empty_flag = False
|
|
|
+ empty_reason = ""
|
|
|
+ # P0-Q9:空车识别(state=3)。判据只看 texture_top 以下那一片**敞车侧墙**:
|
|
|
+ # 完整的一节空敞车侧墙 → 3;只是“看得见车体结构但不够完整” → 保持旧的
|
|
|
+ # 弃权口径(255 ambiguous_empty_vehicle),绝不判 1/2。
|
|
|
+ # 载车为什么过不了:平车+集装箱的侧墙 ROI 实为箱体瓦楞(>max_door_posts);
|
|
|
+ # 罐箱载车只剩底部一条薄车帮(墙高 <empty_min_wall_h_ratio)。
|
|
|
+ if texture_top > 0.0 and state != 1:
|
|
|
+ empty = self._detect_empty_vehicle(
|
|
|
+ gray, window, texture_top, scale,
|
|
|
+ box_bottom=float(box.y1) if box is not None else None,
|
|
|
+ deck_edge=bool(deck_edge),
|
|
|
+ main_posts=int(posts),
|
|
|
+ main_post_span=float(post_span_ratio),
|
|
|
+ )
|
|
|
+ if empty is not None:
|
|
|
+ estats = dict(empty["stats"]) # type: ignore[arg-type]
|
|
|
+ empty_reason = str(empty.get("reason") or "")
|
|
|
+ if empty["ok"]:
|
|
|
+ state = 3
|
|
|
+ conf = float(empty["confidence"])
|
|
|
+ hits = float(empty["hits"])
|
|
|
+ reason = "empty_vehicle"
|
|
|
+ gap_px = 0.0
|
|
|
+ body = estats
|
|
|
+ body_stats = estats
|
|
|
+ body_roi = tuple(empty["roi"]) # type: ignore[arg-type]
|
|
|
+ empty_flag = True
|
|
|
+ elif (empty["basic"] and state == 2 and posts <= 1
|
|
|
+ and box.y1 > texture_top + 0.02 * wh):
|
|
|
+ # 车体结构可见、但不足以判空车、且箱底以下几乎没有立柱 →
|
|
|
+ # 保持旧口径(P0-Q4):空车歧义帧弃权,绝不判 2。
|
|
|
state = 255
|
|
|
conf = 0.0
|
|
|
hits = 0.0
|
|
|
reason = "ambiguous_empty_vehicle"
|
|
|
- gap_px = 0.0
|
|
|
- body = body_stats
|
|
|
+ body_stats = estats
|
|
|
gap_m = (
|
|
|
None if gap_px is None or px_per_m is None or px_per_m <= 0.0
|
|
|
else gap_px / px_per_m
|
|
|
@@ -1609,7 +1779,9 @@ class EvidenceV2:
|
|
|
if (body is None and texture_top > 0.0 and state == 2 and posts <= 1
|
|
|
and box.y1 > texture_top + 0.02 * wh
|
|
|
and (body_stats is None
|
|
|
- or body_stats["posts"] <= self.p.max_door_posts)):
|
|
|
+ or (body_stats["posts"] <= self.p.max_door_posts
|
|
|
+ and float(body_stats.get("span", 0.0))
|
|
|
+ >= self.p.min_post_span_ratio))):
|
|
|
state = 255
|
|
|
conf = 0.0
|
|
|
hits = 0.0
|
|
|
@@ -1663,10 +1835,12 @@ class EvidenceV2:
|
|
|
motion_ok=bool(motion_ok),
|
|
|
hoist_high=bool(hoist_flag),
|
|
|
abstain_reason=(
|
|
|
- "hoist_high" if hoist_flag and state in (0, 1, 2)
|
|
|
- else ("" if state in (0, 1, 2) else reason)
|
|
|
+ "hoist_high" if hoist_flag and state in (0, 1, 2, 3)
|
|
|
+ else ("" if state in (0, 1, 2, 3) else reason)
|
|
|
),
|
|
|
class_reason=reason,
|
|
|
+ empty_vehicle=bool(empty_flag),
|
|
|
+ empty_reason=empty_reason,
|
|
|
body_posts=int(body_stats["posts"]) if body_stats else 0,
|
|
|
body_span=float(body_stats.get("span", 0.0)) if body_stats else 0.0,
|
|
|
body_opacity=float(body_stats["opacity"]) if body_stats else 0.0,
|
|
|
@@ -1682,6 +1856,11 @@ class EvidenceV2:
|
|
|
"class_reason": reason,
|
|
|
"texture_top": None if texture_top <= 0.0 else round(texture_top / scale, 2),
|
|
|
"body_fallback": bool(body),
|
|
|
+ "empty_vehicle": bool(empty_flag),
|
|
|
+ "empty_reason": empty_reason,
|
|
|
+ "body_wall_h_ratio": (
|
|
|
+ None if not body_stats else body_stats.get("wall_h_ratio")
|
|
|
+ ),
|
|
|
"box_band": [round(box.y0 / scale, 2), round(box.y1 / scale, 2)],
|
|
|
"bed_band": None if bed is None else [round(bed.y0 / scale, 2), round(bed.y1 / scale, 2)],
|
|
|
"under_deck": bool(under_deck),
|