|
|
@@ -99,6 +99,9 @@ class EvidenceV2Params:
|
|
|
# C70 门板立柱 63~185 px(docs/edge_evidence.md §4.1)→ 低于该值不构成门板阵列。
|
|
|
# 没有这条时,"上层箱坐在下层箱上"会把下层箱的瓦楞当成车斗门板 → 误判 1。
|
|
|
min_post_spacing_px: float = 24.0
|
|
|
+ # P0-Q3:门板阵列的 x 跨度下限(占工作宽度)。真实 C70 横跨车体(A 25%~66%),
|
|
|
+ # 平车车轮/制动梁只在窄区给伪立柱(B ~20%)→ 取 0.23(B 挡、A f1100 保留)。
|
|
|
+ min_post_span_ratio: float = 0.23
|
|
|
# P0-Q3:`1`(敞车)还必须有"八"字斜撑/三角撑证据(docs/edge_evidence.md §4.1)。
|
|
|
# 容器侧壁只有瓦楞、没有斜撑 → 防"上层箱坐在下层箱上"被判成敞车。
|
|
|
# 0 = 关闭该门(只用于对照实验,现场不要关)。
|
|
|
@@ -163,6 +166,8 @@ class EvidenceV2Params:
|
|
|
raise ValueError("under_deck_search_h_ratio 必须在 (0,0.5]")
|
|
|
if self.min_post_spacing_px < 0.0:
|
|
|
raise ValueError("min_post_spacing_px 不能为负")
|
|
|
+ if not 0.0 <= self.min_post_span_ratio <= 1.0:
|
|
|
+ raise ValueError("min_post_span_ratio 必须在 [0,1]")
|
|
|
if self.min_diagonal_braces < 0:
|
|
|
raise ValueError("min_diagonal_braces 不能为负")
|
|
|
if self.box_height_m <= 0.0:
|
|
|
@@ -193,6 +198,7 @@ class EvidenceV2Params:
|
|
|
max_post_spacing_cv=float(raw.get("max_post_spacing_cv", 6.0)),
|
|
|
min_post_len_ratio=float(raw.get("min_post_len_ratio", 0.30)),
|
|
|
min_post_spacing_px=float(raw.get("min_post_spacing_px", 24.0)),
|
|
|
+ min_post_span_ratio=float(raw.get("min_post_span_ratio", 0.23)),
|
|
|
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)),
|
|
|
@@ -557,7 +563,7 @@ def detect_structure_v2(
|
|
|
crop = gray[y0:y1, x0:x1]
|
|
|
empty = {
|
|
|
"vertical_lines": 0, "diagonal_lines": 0, "horizontal_lines": 0,
|
|
|
- "rect_doors": 0, "post_count": 0, "post_spacing_median": None,
|
|
|
+ "rect_doors": 0, "post_count": 0, "post_positions": [], "post_spacing_median": None,
|
|
|
"post_spacing_cv": None, "edge_density": 0.0,
|
|
|
"horizontal": [], "lines": [],
|
|
|
}
|
|
|
@@ -634,6 +640,7 @@ def detect_structure_v2(
|
|
|
"horizontal_lines": len(horizontal),
|
|
|
"rect_doors": int(rect_doors),
|
|
|
"post_count": len(post_x),
|
|
|
+ "post_positions": [float(x) for x in post_x],
|
|
|
"post_spacing_median": spacing_median,
|
|
|
"post_spacing_cv": spacing_cv,
|
|
|
"edge_density": float(edges.mean() / 255.0),
|
|
|
@@ -912,6 +919,7 @@ class EvidenceV2:
|
|
|
under_deck: bool = False,
|
|
|
post_spacing_px: Optional[float] = None,
|
|
|
diagonal_braces: int = 0,
|
|
|
+ post_span_ratio: float = 0.0,
|
|
|
) -> Tuple[int, float, float, str]:
|
|
|
"""返回 ``(state, confidence, structure_hits, reason)``。
|
|
|
|
|
|
@@ -930,6 +938,8 @@ class EvidenceV2:
|
|
|
or float(post_spacing_px) <= 0.0
|
|
|
or float(post_spacing_px) >= self.p.min_post_spacing_px
|
|
|
)
|
|
|
+ # P0-Q3:门板阵列必须横跨足够宽;平车的车轮/制动梁伪立柱只在窄区。
|
|
|
+ span_ok = float(post_span_ratio) >= self.p.min_post_span_ratio
|
|
|
# P0-Q3:只在"箱底与车面/箱顶贴合"(gap<=1px)时才要求"八"字斜撑。
|
|
|
# 真实 C70 在 T1 窗口箱底高于墙顶(A ≈25 px),不应因斜撑不可见被弃权;
|
|
|
# 而"上层箱坐在下层箱上/箱直接坐地"是贴合形态,必须有门板结构才判 1。
|
|
|
@@ -944,6 +954,7 @@ class EvidenceV2:
|
|
|
and (spacing_cv is None or spacing_cv <= self.p.max_post_spacing_cv)
|
|
|
and spacing_ok
|
|
|
and doors_ok
|
|
|
+ and span_ok
|
|
|
)
|
|
|
# 平车:没有门板阵列 + 箱底下有可见车面边梁 + 边梁下方有"车底空隙/阴影"。
|
|
|
# `under_deck` 是 P0-Q3 加的硬门:地面/堆场/下层箱顶只有亮面,
|
|
|
@@ -1226,6 +1237,10 @@ class EvidenceV2:
|
|
|
and darkest <= band_mean - self.p.under_deck_dark_delta
|
|
|
)
|
|
|
deck_edge = bool(deck_edge and under_deck)
|
|
|
+ positions = structure.get("post_positions") or []
|
|
|
+ post_span_ratio = 0.0
|
|
|
+ if len(positions) >= 2:
|
|
|
+ post_span_ratio = (max(positions) - min(positions)) / max(1.0, float(ww))
|
|
|
gap_px = None
|
|
|
if bed is not None:
|
|
|
gap_px = max(0.0, (bed.y0 - box.y1) / max(scale, 1e-6))
|
|
|
@@ -1246,6 +1261,7 @@ class EvidenceV2:
|
|
|
else float(spacing_median) / max(scale, 1e-6)
|
|
|
),
|
|
|
diagonal_braces=int(structure["diagonal_lines"]),
|
|
|
+ post_span_ratio=float(post_span_ratio),
|
|
|
)
|
|
|
gap_m = (
|
|
|
None if gap_px is None or px_per_m is None or px_per_m <= 0.0
|