|
@@ -115,8 +115,10 @@ class EvidenceV2Params:
|
|
|
# P0-Q4:空车/无箱兜底(纹理车体 ROI 再数一次门板立柱)
|
|
# P0-Q4:空车/无箱兜底(纹理车体 ROI 再数一次门板立柱)
|
|
|
body_fallback_enable: bool = True
|
|
body_fallback_enable: bool = True
|
|
|
body_bottom_ratio: float = 0.75
|
|
body_bottom_ratio: float = 0.75
|
|
|
- body_min_opacity: float = 0.75
|
|
|
|
|
|
|
+ body_min_opacity: float = 0.50
|
|
|
body_min_roi_px: int = 90
|
|
body_min_roi_px: int = 90
|
|
|
|
|
+ body_x_margin_ratio: float = 0.03
|
|
|
|
|
+ body_min_posts: int = 3
|
|
|
# P0-Q3:`1`(敞车)还必须有"八"字斜撑/三角撑证据(docs/edge_evidence.md §4.1)。
|
|
# P0-Q3:`1`(敞车)还必须有"八"字斜撑/三角撑证据(docs/edge_evidence.md §4.1)。
|
|
|
# 容器侧壁只有瓦楞、没有斜撑 → 防"上层箱坐在下层箱上"被判成敞车。
|
|
# 容器侧壁只有瓦楞、没有斜撑 → 防"上层箱坐在下层箱上"被判成敞车。
|
|
|
# 0 = 关闭该门(只用于对照实验,现场不要关)。
|
|
# 0 = 关闭该门(只用于对照实验,现场不要关)。
|
|
@@ -201,6 +203,10 @@ class EvidenceV2Params:
|
|
|
raise ValueError("body_min_opacity 必须在 [0,1]")
|
|
raise ValueError("body_min_opacity 必须在 [0,1]")
|
|
|
if self.body_min_roi_px < 8:
|
|
if self.body_min_roi_px < 8:
|
|
|
raise ValueError("body_min_roi_px 至少 8")
|
|
raise ValueError("body_min_roi_px 至少 8")
|
|
|
|
|
+ if not 0.0 <= self.body_x_margin_ratio <= 0.5:
|
|
|
|
|
+ raise ValueError("body_x_margin_ratio 必须在 [0,0.5]")
|
|
|
|
|
+ if self.body_min_posts < 1:
|
|
|
|
|
+ raise ValueError("body_min_posts 至少 1")
|
|
|
if self.min_diagonal_braces < 0:
|
|
if self.min_diagonal_braces < 0:
|
|
|
raise ValueError("min_diagonal_braces 不能为负")
|
|
raise ValueError("min_diagonal_braces 不能为负")
|
|
|
if self.box_height_m <= 0.0:
|
|
if self.box_height_m <= 0.0:
|
|
@@ -242,8 +248,10 @@ class EvidenceV2Params:
|
|
|
texture_top_margin_ratio=float(raw.get("texture_top_margin_ratio", 0.02)),
|
|
texture_top_margin_ratio=float(raw.get("texture_top_margin_ratio", 0.02)),
|
|
|
body_fallback_enable=bool(raw.get("body_fallback_enable", True)),
|
|
body_fallback_enable=bool(raw.get("body_fallback_enable", True)),
|
|
|
body_bottom_ratio=float(raw.get("body_bottom_ratio", 0.75)),
|
|
body_bottom_ratio=float(raw.get("body_bottom_ratio", 0.75)),
|
|
|
- body_min_opacity=float(raw.get("body_min_opacity", 0.75)),
|
|
|
|
|
|
|
+ body_min_opacity=float(raw.get("body_min_opacity", 0.50)),
|
|
|
body_min_roi_px=int(raw.get("body_min_roi_px", 90)),
|
|
body_min_roi_px=int(raw.get("body_min_roi_px", 90)),
|
|
|
|
|
+ body_x_margin_ratio=float(raw.get("body_x_margin_ratio", 0.03)),
|
|
|
|
|
+ body_min_posts=int(raw.get("body_min_posts", 3)),
|
|
|
min_diagonal_braces=int(raw.get("min_diagonal_braces", 1)),
|
|
min_diagonal_braces=int(raw.get("min_diagonal_braces", 1)),
|
|
|
min_wall_opacity=float(raw.get("min_wall_opacity", 0.35)),
|
|
min_wall_opacity=float(raw.get("min_wall_opacity", 0.35)),
|
|
|
max_flat_gap_px=float(raw.get("max_flat_gap_px", 40.0)),
|
|
max_flat_gap_px=float(raw.get("max_flat_gap_px", 40.0)),
|
|
@@ -1354,6 +1362,7 @@ class EvidenceV2:
|
|
|
post_span_ratio=float(post_span_ratio),
|
|
post_span_ratio=float(post_span_ratio),
|
|
|
)
|
|
)
|
|
|
body = None
|
|
body = None
|
|
|
|
|
+ body_stats = None
|
|
|
body_roi = None
|
|
body_roi = None
|
|
|
if (self.p.body_fallback_enable and texture_top > 0.0 and state != 1
|
|
if (self.p.body_fallback_enable and texture_top > 0.0 and state != 1
|
|
|
and texture_top > window[1] + 0.05 * wh):
|
|
and texture_top > window[1] + 0.05 * wh):
|
|
@@ -1361,7 +1370,9 @@ class EvidenceV2:
|
|
|
by1 = min(int(window[3]), int(round(
|
|
by1 = min(int(window[3]), int(round(
|
|
|
texture_top + self.p.body_bottom_ratio * (window[3] - texture_top))))
|
|
texture_top + self.p.body_bottom_ratio * (window[3] - texture_top))))
|
|
|
if by1 > by0:
|
|
if by1 > by0:
|
|
|
- body_roi = (window[0], by0, window[2], by1)
|
|
|
|
|
|
|
+ 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)
|
|
|
bst = detect_structure_v2(
|
|
bst = detect_structure_v2(
|
|
|
gray, body_roi,
|
|
gray, body_roi,
|
|
|
min_post_len_ratio=self.p.min_post_len_ratio,
|
|
min_post_len_ratio=self.p.min_post_len_ratio,
|
|
@@ -1380,8 +1391,13 @@ class EvidenceV2:
|
|
|
)
|
|
)
|
|
|
bopacity = 1.0 - bground if bblocks > 0 else 0.0
|
|
bopacity = 1.0 - bground if bblocks > 0 else 0.0
|
|
|
bh = (by1 - by0) / max(scale, 1e-6)
|
|
bh = (by1 - by0) / max(scale, 1e-6)
|
|
|
|
|
+ body_stats = {
|
|
|
|
|
+ "posts": int(bst["post_count"]),
|
|
|
|
|
+ "diagonal": int(bst["diagonal_lines"]),
|
|
|
|
|
+ "opacity": bopacity,
|
|
|
|
|
+ }
|
|
|
if (bh >= self.p.body_min_roi_px
|
|
if (bh >= self.p.body_min_roi_px
|
|
|
- and int(bst["post_count"]) >= self.p.min_door_posts
|
|
|
|
|
|
|
+ and self.p.body_min_posts <= int(bst["post_count"]) <= self.p.max_door_posts
|
|
|
and bspan >= self.p.min_post_span_ratio
|
|
and bspan >= self.p.min_post_span_ratio
|
|
|
and bopacity >= self.p.body_min_opacity
|
|
and bopacity >= self.p.body_min_opacity
|
|
|
and int(bst["diagonal_lines"]) >= self.p.min_diagonal_braces):
|
|
and int(bst["diagonal_lines"]) >= self.p.min_diagonal_braces):
|
|
@@ -1391,11 +1407,7 @@ class EvidenceV2:
|
|
|
hits = min(1.0, 0.40 + 0.05 * bst["post_count"] + 0.20 * bopacity)
|
|
hits = min(1.0, 0.40 + 0.05 * bst["post_count"] + 0.20 * bopacity)
|
|
|
reason = "body_fallback_wall"
|
|
reason = "body_fallback_wall"
|
|
|
gap_px = 0.0
|
|
gap_px = 0.0
|
|
|
- body = {
|
|
|
|
|
- "posts": int(bst["post_count"]),
|
|
|
|
|
- "diagonal": int(bst["diagonal_lines"]),
|
|
|
|
|
- "opacity": bopacity,
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ body = body_stats
|
|
|
gap_m = (
|
|
gap_m = (
|
|
|
None if gap_px is None or px_per_m is None or px_per_m <= 0.0
|
|
None if gap_px is None or px_per_m is None or px_per_m <= 0.0
|
|
|
else gap_px / px_per_m
|
|
else gap_px / px_per_m
|
|
@@ -1403,7 +1415,9 @@ class EvidenceV2:
|
|
|
if body is not None:
|
|
if body is not None:
|
|
|
gap_m = 0.0
|
|
gap_m = 0.0
|
|
|
if (body is None and texture_top > 0.0 and state == 2 and posts == 0
|
|
if (body is None and texture_top > 0.0 and state == 2 and posts == 0
|
|
|
- and box.y1 > texture_top + 0.02 * wh):
|
|
|
|
|
|
|
+ and box.y1 > texture_top + 0.02 * wh
|
|
|
|
|
+ and (body_stats is None
|
|
|
|
|
+ or body_stats["posts"] <= self.p.max_door_posts)):
|
|
|
state = 255
|
|
state = 255
|
|
|
conf = 0.0
|
|
conf = 0.0
|
|
|
hits = 0.0
|
|
hits = 0.0
|