Преглед изворни кода

fix(portcv): P0-Q11 作业帧硬门——吊具高悬/夹箱时不判车型

实拍 root_test1(正面吊司机视角、吊具吊着箱悬在平车上方)被空车判据当成
敞车侧墙(posts=9 span=0.95)→ 误判 state=3。旧口径"分类仍给 1、只拦
commit"对 PLC 不安全,现在命中吊具信号即 state=255 / reason=hoist_high,
空车(3)与空平车(3)覆写之前统一拦截。C++/Python 同构。

同时补诊断字段(不改变判定):BodyEvidence.spcv(立柱间距变异系数)、
boxh/bedh(箱底暗带/边梁亮带高度)进 C++ summary;Python _measure_body
返回 spcv,便于现场按车型调参。

量化后"未采纳"的两条(写进 docs,避免再次踩坑):
* 39 张 web_cc 广角侧视图上 posts/span/opacity/spcv 无法区分"集装箱侧壁
  vs 敞车侧墙"(载车 body=(3~12,0.64~0.93,0.68~0.85) vs 空车
  (3~14,0.61~0.96,0.59~0.85),分布完全重叠);
* "边梁下方 ground>=0.25" 门实测重叠(载车 0.30~0.38 / 空敞车 0.16~0.47)
  且误伤 5 项合成单测 → 已回退;
* px_per_m 全语料恒为 0,无尺度信号。
结论:域外机位需车型分类器,在此之前保持 allow_state2/allow_state3=false。

验证:Python 全量 362 项 OK(1 skip);test_evidence_v2 47 项(新增
HoistBlocksTypeTests 3 项);C++ ctest 8/8、portcv_edge_v2_selftest
75/0(新增 3 项 + 1 项口径更新);check_configs 8/8;gen_cpp_constants
--check OK;A/B 现场回归不变(A 发布 1×40、B 发布 2×40,无交叉)。
数据集报告同步到 docs/evidence/test_2026-11-20/。
kwass пре 3 дана
родитељ
комит
56f3a3d788

+ 1 - 1
cpp/README.md

@@ -78,7 +78,7 @@ ctest --test-dir build --output-on-failure
 | `portcv_capture_selftest` | **231 通过 / 0 失败** | 帧槽只留最新帧 / synth 源逐字节确定 / **images(PGM 序列)源离线复盘** / 管线拼装 / `redact_uri` / PGM+JSONL 格式 / `source.*` 校验 |
 | `portcv_edge_selftest` | **112 通过 / 0 失败** | 证据链全量(含 C1 置信度下限、`F2` 车底空隙、`C3` ROI 口径、P2/F1 结构上下文);2026-10-27 起 12 项历史失败已清零 |
 | `portcv_v2_selftest` | **54 通过 / 0 失败** | V2 PublishGate 的 12 个契约向量、状态保持/复位、half-up 千分比 |
-| `portcv_edge_v2_selftest` | **56 通过 / 0 失败** | edge-v2 证据链:零间隙接触、侧视 flatbed、`allow_state2` 回退、空帧/无图 abstain;**P0-0 吊具高悬 / 夹箱门**(合成高悬帧 6 帧 0 commit、注入路径、远距 ROI 弃权、门关闭对照);**P0-Q3 地面/堆料/堆叠箱负样本**(不得判 1/2) |
+| `portcv_edge_v2_selftest` | **75 通过 / 0 失败** | edge-v2 证据链:零间隙接触、侧视 flatbed、`allow_state2` 回退、空帧/无图 abstain;**P0-0 吊具高悬 / 夹箱门**(合成高悬帧 6 帧 0 commit、注入路径、远距 ROI 弃权、门关闭对照);**P0-Q3 地面/堆料/堆叠箱负样本**(不得判 1/2) |
 
 > 一条命令跑完全部四层(ctest + Python 单测 + v1 `edge` 现场回放 + v2 `edge-v2` 现场回放):
 > `python scripts/regression_freeze.py --build-dir build-cmake/windows-zig-release`。

+ 3 - 0
cpp/include/portcv/edge_v2.hpp

@@ -260,6 +260,7 @@ struct EvidenceV2Result {
     double body_span = 0.0;      ///< 车体兜底 ROI 的立柱跨度(诊断)
     double body_opacity = 0.0;   ///< 车体兜底 ROI 的不透明占比(诊断)
     int body_diagonal = 0;       ///< 车体兜底 ROI 的斜撑数(诊断)
+    double body_spcv = 0.0;      ///< 车体兜底 ROI 的立柱间距变异系数(诊断,P0-Q11)
     /// P0-Q9:本帧是否按“空车(敞车、车斗内无箱)”判出 `state=3`;
     /// `empty_reason` 记录未通过的那一道门(`empty_span` / `empty_wall_short` …)。
     bool empty_vehicle = false;
@@ -268,6 +269,8 @@ struct EvidenceV2Result {
     std::optional<double> px_per_m;
     bool scale_ok = false;
     std::optional<double> bed_top_y;
+    std::optional<double> box_band_h;  ///< 箱底暗带高度(工作图像素;诊断 P0-Q11)
+    std::optional<double> bed_band_h;  ///< 车面边梁亮带高度(工作图像素;诊断 P0-Q11)
     std::optional<double> gap_px;
     std::optional<double> gap_m;
     int door_posts = 0;

+ 41 - 4
cpp/src/edge_v2.cpp

@@ -230,6 +230,7 @@ struct BodyEvidence {
     double span_ratio = 0.0;
     double opacity = 0.0;
     int diagonal = 0;
+    double spcv = 0.0;   ///< P0-Q11:立柱间距变异系数(门板等距;杂物不等距)
     double height = 0.0;
 };
 
@@ -275,6 +276,24 @@ BodyEvidence measure_body(const GrayImage& work, int x0, int y0, int x1, int y1,
         out.span_ratio = (posts.back() - posts.front()) /
                          std::max(1.0, static_cast<double>(crop.width));
     }
+    // P0-Q11:立柱间距变异系数(门板阵列等距;接触网杆/箱棱/杂物不等距)。
+    // 与 Python `_measure_body` 同口径:>=3 根才算,0 = 无法判定。
+    if (posts.size() >= 3) {
+        double sum_gap = 0.0;
+        for (std::size_t i = 1; i < posts.size(); ++i) {
+            sum_gap += (posts[i] - posts[i - 1]);
+        }
+        const double mean_gap = sum_gap / static_cast<double>(posts.size() - 1);
+        if (mean_gap > 1e-6) {
+            double var = 0.0;
+            for (std::size_t i = 1; i < posts.size(); ++i) {
+                const double d = (posts[i] - posts[i - 1]) - mean_gap;
+                var += d * d;
+            }
+            var /= static_cast<double>(posts.size() - 1);
+            out.spcv = std::sqrt(var) / mean_gap;
+        }
+    }
     const double ground = ground_like_ratio(crop, grad, all_segs, p.ground_block_px,
                                             p.ground_density_lo, p.ground_density_hi);
     out.opacity = std::max(0.0, std::min(1.0, 1.0 - ground));
@@ -672,7 +691,9 @@ std::string EvidenceV2Result::evidence_summary() const {
     out += " under_deck=" + std::string(under_deck ? "1" : "0");
     out += " body=(" + std::to_string(body_posts) + "," +
            fmt("%.2f", body_span) + "," + fmt("%.2f", body_opacity) + "," +
-           std::to_string(body_diagonal) + ")";
+           std::to_string(body_diagonal) + "," + fmt("%.2f", body_spcv) + ")";
+    out += " boxh=" + (box_band_h.has_value() ? fmt("%.1f", *box_band_h) : "n/a") +
+           " bedh=" + (bed_band_h.has_value() ? fmt("%.1f", *bed_band_h) : "n/a");
     out += " gap=" + (gap_px.has_value() ? fmt("%.1f", *gap_px) + "px" : "n/a");
     out += " gap_m=" + (gap_m.has_value() ? fmt("%.3f", *gap_m) : "n/a");
     out += " box=" + (box_bottom_y.has_value() ? fmt("%.1f", *box_bottom_y) : "n/a") +
@@ -1513,7 +1534,7 @@ EvidenceV2Result EdgeV2::analyze(const GrayImage& gray, double ts, bool plc_arri
     std::string empty_reason;
     int body_y0 = 0;
     int body_y1 = 0;
-    if (texture_top > 0.0 && cls.state != 1) {
+    if (!hoist_flag && texture_top > 0.0 && cls.state != 1) {
         const EmptyEvidence empty =
             detect_empty_vehicle(work, window, texture_top, p_, scale, box.y1, deck_edge,
                                  static_cast<int>(posts.size()), post_span_ratio);
@@ -1547,7 +1568,7 @@ EvidenceV2Result EdgeV2::analyze(const GrayImage& gray, double ts, bool plc_arri
     // P0-Q10:空平车(平车、车面裸露)→ 3。与空敞车**互斥**(上面已先判敞车侧墙);
     // 判据:薄车面边梁 + 车底透空 + 边梁上方是一片光滑亮车面(车底板),
     // 且**没有箱底暗带紧贴边梁**(载车实测 gap≈0)。
-    if (!empty_override && final_state != 1) {
+    if (!hoist_flag && !empty_override && final_state != 1) {
         const FlatbedEvidence flat = detect_empty_flatbed(
             work, window, box, bed, deck_edge, under_deck, gap_px, p_);
         if (flat.ok) {
@@ -1580,6 +1601,17 @@ EvidenceV2Result EdgeV2::analyze(const GrayImage& gray, double ts, bool plc_arri
         final_reason = "ambiguous_empty_vehicle";
     }
 
+    // P0-Q11:作业帧(吊具高悬 / 吊具仍夹箱)**绝不判车型**。
+    // 根因:吊具/箱体悬在车体上方时,空车判据会把“吊具横梁 + 箱体侧壁”当成
+    // 敞车侧墙(实测 root_test1:posts=9 span=0.95 → 误判 3)。吊具信号已算好,
+    // 只差在空车/空平车覆写之后、commit 之前拦一道。
+    if (hoist_flag) {
+        final_state = static_cast<int>(SceneState::UNKNOWN);
+        final_conf = 0.0;
+        final_hits = 0.0;
+        final_reason = "hoist_high";
+    }
+
     const V2CommitState commit = tracker_.update(
         ts, final_state, commit_gap_m, commit_gap_px, final_hits, still,
         p_.view != "unknown", plc_arrived, plc_spreader_released, hoist_flag);
@@ -1593,12 +1625,17 @@ EvidenceV2Result EdgeV2::analyze(const GrayImage& gray, double ts, bool plc_arri
     out.body_span = body.span_ratio;
     out.body_opacity = body.opacity;
     out.body_diagonal = body.diagonal;
+    out.body_spcv = body.spcv;
     out.box_bottom_y = box.y1 / std::max(scale, 1e-6);
     out.box_top_y = box_top;
     out.box_h_px = box_h;
     out.px_per_m = px_per_m;
     out.scale_ok = px_per_m.has_value();
-    if (bed.height() > 0.0) { out.bed_top_y = bed.y0 / std::max(scale, 1e-6); }
+    if (box.height() > 0.0) { out.box_band_h = box.height(); }
+    if (bed.height() > 0.0) {
+        out.bed_top_y = bed.y0 / std::max(scale, 1e-6);
+        out.bed_band_h = bed.height();
+    }
     out.gap_px = commit_gap_px;
     out.gap_m = commit_gap_m;
     if (body_override) {

+ 16 - 3
cpp/tests/selftest_edge_v2.cpp

@@ -321,6 +321,17 @@ int main() {
         check(r.gap_px.has_value() && *r.gap_px <= 2.0,
               "contact flatbed gap stays at box bottom (<=2px)");
     }
+    // ---------------- P0-Q11:作业帧(吊具高悬)绝不判车型 ----------------
+    {
+        // 同一幅 B 类平车画面,注入 hoist_high 后必须弃权(不得仍报 2)。
+        EdgeV2 ev(p, fast_commit());
+        const auto r = ev.analyze(flat_scene(4), 0.0, false, false, true);
+        std::printf("       hoist: %s\n", r.evidence_summary().c_str());
+        check(r.state != 2 && r.state != 1 && r.state != 3,
+              "hoist_high blocks flatbed state 2");
+        check(r.hoist_high, "hoist flag reported");
+        check(r.class_reason == "hoist_high", "hoist_high reason recorded");
+    }
     // ---------------- P0-Q3:地面/堆料/堆叠箱负样本 ----------------
     {
         EdgeV2 ev(p, fast_commit());
@@ -472,9 +483,11 @@ int main() {
         check(!r.hoist_injected, "hoist flag came from image (not injected)");
         check(r.hoist_lines >= 1, "hoist scene has >=1 horizontal hit");
         check(!r.committed, "hoist scene never commits");
-        // 分类本身仍是 1(几何证据没坏),安全门只拦 commit —— 对外的 `edge_state`
-        // 走 `to_observation(require_commit=true)`,所以必须是 255(见下一条)。
-        check_eq(r.state, 1, "hoist scene still classifies 1 (geometry intact)");
+        // P0-Q11:作业帧**不判车型**。旧口径是“分类仍给 1、只拦 commit”,但实拍
+        // `root_test1`(司机视角、吊具吊着箱悬在平车上方)证明那样会把“吊具+箱体”
+        // 直接当成空车 3 发给 PLC,所以现在 state 也一并置 255,reason=hoist_high。
+        check(r.state != 1 && r.state != 2 && r.state != 3,
+              "hoist scene never classifies a vehicle type");
         check(r.abstain_reason == "hoist_high", "hoist scene reason=hoist_high");
         check_eq(r.stable_frames, 0, "hoist scene does not accumulate stable frames");
         const auto obs = r.to_observation(0.6, 0, true);

+ 1 - 1
docs/deployment.md

@@ -36,7 +36,7 @@ ctest --test-dir build --output-on-failure
 #   期望:portcv_selftest 200/0、portcv_config_selftest 269/0、portcv_rate_selftest 110/0、
 #        portcv_capture_selftest 231/0(取流层 + 黄金语料导出的守门人,含 images/PGM 序列源)
 #        portcv_edge_selftest 112 通过 / 0 失败
-#        portcv_edge_v2_selftest 56 通过 / 0 失败(含 P0-0 吊具高悬 / 夹箱门、P0-Q3 地面/堆料负样本)
+#        portcv_edge_v2_selftest 75 通过 / 0 失败(含 P0-0 吊具高悬 / 夹箱门、P0-Q3 地面/堆料负样本)
 #
 #   不想逐条敲?一条命令跑完四层(ctest + Python 单测 + v1/v2 现场回放):
 #        python scripts/regression_freeze.py --build-dir build

+ 10 - 2
docs/edge_evidence.md

@@ -632,7 +632,7 @@ python scripts/replay_check.py runs/v2gate_B4.jsonl --images runs/_v2gate_B4
     发布 `2`×40/`0`×10。A f1000~f1049 跨度 ~65%、f1100 ~25%,仍判/发布 `1`。
 * 结果:合成 `ground` 由 `2` → **`255`**(`deck=0 under_deck=0`),
   A/B 合成正样本仍分别 `1/2`;新增 Python 3 项 + C++ 4 项负样本回归
-  (`portcv_edge_v2_selftest` 52/0)。
+  (`portcv_edge_v2_selftest` 75/0)。
 * **代价(必须写进验收)**:远距/遮挡/贴底帧的 `2` 召回会下降(更多 `255`),
   B 现场片段需按新门复跑后再决定 `allow_state2`;`0` 类真实负样本仍缺,
   本修复只保证"地面/堆料不判 1/2",不等于 `0` 的召回验收。
@@ -698,7 +698,15 @@ python scripts/replay_check.py runs/v2gate_B4.jsonl --images runs/_v2gate_B4
   (实测 0.66~0.92),平车上集装箱波纹只占中间(0.36~0.45);`posts` 上限用
   `vehicle_max_posts`(60,C++ 会把门框/铰链算成 20 根)。命中 → `1` 且
   `gap` 记 0;判不出仍 `no_box` 弃权,**绝不**猜平车。
-* 新增回归:Python `TextureTopTests` 3 项、C++ 2 项(`portcv_edge_v2_selftest` 56/0)。
+* 新增回归:Python `TextureTopTests` 3 项、C++ 2 项(`portcv_edge_v2_selftest` 75/0)。
+* **P0-Q11(2026-11-20)作业帧硬门**:吊具高悬 / 仍夹箱时不判 1/2/3(`state=255`、
+  `reason=hoist_high`)。实拍 `root_test1`(司机视角、吊具吊箱悬在平车上方)曾被空车判据
+  当成敞车侧墙(`posts=9 span=0.95`)→ 误判 3。同时把 `BodyEvidence.spcv`(立柱间距
+  变异系数)与 `boxh/bedh` 加进 C++ summary 供现场调参。
+  回归:Python `HoistBlocksTypeTests` 3 项、C++ 3 项。
+  **边界(实测记录)**:39 张 `web_cc` 广角侧视图上,`posts/span/opacity/ground`
+  都无法区分“集装箱侧壁 vs 敞车侧墙”(分布完全重叠),`px_per_m` 恒为 0 亦无尺度信号
+  → 域外机位需车型分类器;在那之前保持 `allow_state2=false` / `allow_state3=false`。
 
 ---
 

+ 40 - 0
docs/evidence/test_2026-11-20/per_image_results.csv

@@ -0,0 +1,40 @@
+stem,name,group,res,note,want,cand,pub,verdict,errtype,pub_hist,evidence
+flatcar_NX70_001,NX70_001.jpg,flatcar,1280x962,空平车,3,2,0,弃权,弃权未判,"{""0"": 20}","reason=deck_edge top=168.0 posts=0 opacity=0.61 deck=1 under_deck=1 gap=20.0px body=(1,0.00,0.71,172,0.00)"
+flatcar_NX70_002,NX70_002.jpg,flatcar,1280x960,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=254.7 posts=3 opacity=0.61 deck=0 under_deck=1 gap=25.3px body=(9,0.93,0.62,196,1.06)"
+flatcar_NX70_003,NX70_003.jpg,flatcar,1280x853,平车坐箱,2,3,3,误判,载车→空车,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=250.7 posts=10 opacity=0.68 deck=0 under_deck=0 gap=0.0px body=(10,0.79,0.68,85,1.50)"
+flatcar_X160_001,X160_001.jpg,flatcar,1280x853,空平车,3,1,1,误判,空车→载车,"{""0"": 10, ""1"": 10}","reason=wall_posts top=16.0 posts=4 opacity=0.73 deck=1 under_deck=1 gap=0.0px body=(0,0.00,0.00,0,0.00)"
+flatcar_X160_002,X160_002.jpg,flatcar,1280x853,空平车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=16.0 posts=10 opacity=0.80 deck=0 under_deck=0 gap=0.0px body=(10,0.81,0.80,485,1.81)"
+flatcar_X160_003,X160_003.jpg,flatcar,1280x853,空平车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=136.0 posts=2 opacity=0.83 deck=1 under_deck=1 gap=289.3px body=(4,0.71,0.74,316,0.96)"
+flatcar_X160_004,X160_004.jpg,flatcar,1280x853,空平车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=16.0 posts=5 opacity=0.78 deck=0 under_deck=0 gap=0.0px body=(5,0.65,0.78,499,1.25)"
+flatcar_X160_005,X160_005.jpg,flatcar,1280x853,空平车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=bed_roi_small top=16.0 posts=5 opacity=0.83 deck=1 under_deck=1 gap=0.0px body=(5,0.33,0.76,435,0.70)"
+flatcar_X160_006,X160_006.jpg,flatcar,1280x853,空平车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=16.0 posts=7 opacity=0.75 deck=0 under_deck=0 gap=0.0px body=(7,0.86,0.75,460,0.94)"
+flatcar_X160_007,X160_007.jpg,flatcar,1280x853,空平车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=16.0 posts=6 opacity=0.77 deck=0 under_deck=0 gap=0.0px body=(6,0.73,0.77,448,1.24)"
+flatcar_X70_001,X70_001.jpg,flatcar,1280x851,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=228.0 posts=16 opacity=0.62 deck=0 under_deck=0 gap=68.0px body=(5,0.28,0.68,20,1.12)"
+flatcar_X70_002,X70_002.jpg,flatcar,1280x853,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=16.0 posts=6 opacity=0.72 deck=1 under_deck=1 gap=162.7px body=(5,0.40,0.72,110,1.28)"
+flatcar_X70_003,X70_003.jpg,flatcar,1280x852,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=361.3 posts=0 opacity=0.71 deck=0 under_deck=0 gap=0.0px body=(2,0.38,0.74,150,0.00)"
+flatcar_X70_004,X70_004.jpg,flatcar,1280x960,平车坐箱,2,3,3,误判,载车→空车,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=245.3 posts=6 opacity=0.72 deck=0 under_deck=0 gap=0.0px body=(6,0.79,0.72,285,1.59)"
+flatcar_X70_005,X70_005.jpg,flatcar,1280x960,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=249.3 posts=4 opacity=0.68 deck=0 under_deck=1 gap=5.3px body=(5,0.59,0.72,211,1.26)"
+flatcar_X70_006,X70_006.jpg,flatcar,1280x852,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=262.7 posts=0 opacity=0.67 deck=0 under_deck=0 gap=0.0px body=(2,0.04,0.63,90,0.00)"
+flatcar_X70_007,X70_007.jpg,flatcar,1280x853,平车坐箱,2,3,3,误判,载车→空车,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=16.0 posts=3 opacity=0.85 deck=0 under_deck=0 gap=0.0px body=(3,0.64,0.85,287,0.75)"
+flatcar_X70_008,X70_008.jpg,flatcar,1280x853,平车坐箱,2,3,3,误判,载车→空车,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=70.7 posts=10 opacity=0.82 deck=0 under_deck=0 gap=0.0px body=(10,0.93,0.82,125,1.20)"
+flatcar_X70_009,X70_009.jpg,flatcar,1280x853,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=16.0 posts=2 opacity=0.65 deck=0 under_deck=1 gap=0.0px body=(10,0.55,0.81,273,0.70)"
+flatcar_X70_010,X70_010.jpg,flatcar,1280x960,平车坐箱,2,3,3,误判,载车→空车,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=406.7 posts=12 opacity=0.78 deck=0 under_deck=0 gap=0.0px body=(12,0.69,0.78,76,0.72)"
+flatcar_X70_011,X70_011.jpg,flatcar,1280x854,平车坐箱,2,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=16.0 posts=15 opacity=0.48 deck=1 under_deck=1 gap=0.0px body=(3,0.57,0.73,65,0.94)"
+gondola_C64K_001,C64K_001.jpg,gondola,1280x852,空敞车,3,2,2,误判,空车→载车,"{""0"": 10, ""2"": 10}","reason=deck_edge top=209.3 posts=1 opacity=0.53 deck=1 under_deck=1 gap=0.0px body=(1,0.00,0.61,69,0.00)"
+gondola_C64K_002,C64K_002.jpg,gondola,1280x853,空敞车,3,1,0,弃权,弃权未判,"{""0"": 20}","reason=wall_posts top=325.3 posts=10 opacity=0.67 deck=1 under_deck=1 gap=2.7px body=(0,0.00,0.00,0,0.00)"
+gondola_C64K_003,C64K_003.jpg,gondola,1280x838,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=228.0 posts=6 opacity=0.71 deck=0 under_deck=0 gap=0.0px body=(6,0.67,0.71,77,0.51)"
+gondola_C64K_004,C64K_004.jpg,gondola,1280x855,空敞车,3,1,0,弃权,弃权未判,"{""0"": 20}","reason=wall_posts top=180.0 posts=12 opacity=0.69 deck=0 under_deck=0 gap=n/a body=(0,0.00,0.00,0,0.00)"
+gondola_C64K_005,C64K_005.jpg,gondola,1280x960,空敞车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=314.7 posts=0 opacity=0.65 deck=1 under_deck=1 gap=46.7px body=(0,0.00,0.69,153,0.00)"
+gondola_C64K_006,C64K_006.jpg,gondola,1280x960,空敞车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=253.3 posts=0 opacity=0.59 deck=0 under_deck=1 gap=26.7px body=(0,0.00,0.68,185,0.00)"
+gondola_C64_001,C64_001.jpg,gondola,1280x853,空敞车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=16.0 posts=4 opacity=0.68 deck=0 under_deck=1 gap=0.0px body=(1,0.00,0.70,125,0.00)"
+gondola_C70E_001,C70E_001.jpg,gondola,1280x853,空敞车,3,1,1,误判,空车→载车,"{""0"": 10, ""1"": 10}","reason=wall_posts top=202.7 posts=7 opacity=0.68 deck=0 under_deck=0 gap=0.0px body=(0,0.00,0.00,0,0.00)"
+gondola_C70E_002,C70E_002.jpg,gondola,1280x852,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=16.0 posts=5 opacity=0.69 deck=0 under_deck=0 gap=0.0px body=(5,0.62,0.69,135,0.31)"
+gondola_C70E_003,C70E_003.jpg,gondola,1280x852,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=254.7 posts=9 opacity=0.78 deck=0 under_deck=0 gap=0.0px body=(9,0.85,0.78,112,0.73)"
+gondola_C70E_004,C70E_004.jpg,gondola,1280x853,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=258.7 posts=14 opacity=0.73 deck=0 under_deck=0 gap=0.0px body=(14,0.86,0.73,152,0.78)"
+gondola_C70H_001,C70H_001.jpg,gondola,1280x960,空敞车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=210.7 posts=3 opacity=0.64 deck=0 under_deck=1 gap=60.0px body=(0,0.00,0.63,119,0.00)"
+gondola_C70_001,C70_001.jpg,gondola,1280x855,空敞车,3,255,0,弃权,弃权未判,"{""0"": 20}","reason=weak_evidence top=16.0 posts=1 opacity=0.57 deck=0 under_deck=1 gap=0.0px body=(2,0.53,0.62,150,0.00)"
+gondola_C70_002,C70_002.jpg,gondola,1280x855,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=236.0 posts=4 opacity=0.67 deck=0 under_deck=0 gap=0.0px body=(4,0.96,0.67,37,0.61)"
+gondola_C70_003,C70_003.jpg,gondola,1280x855,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=177.3 posts=3 opacity=0.76 deck=0 under_deck=0 gap=0.0px body=(3,0.61,0.76,70,0.56)"
+gondola_C80_001,C80_001.jpg,gondola,1280x853,空敞车,3,3,3,命中,,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=246.7 posts=6 opacity=0.74 deck=0 under_deck=0 gap=0.0px body=(6,0.70,0.74,184,0.96)"
+root_test1,test1.png,root,1672x941,作业中(吊具吊箱悬于平车上方),,3,3,风险-作业中被判车型,作业帧被判车型,"{""0"": 10, ""3"": 10}","reason=empty_vehicle top=115.0 posts=9 opacity=0.71 deck=0 under_deck=0 gap=0.0px body=(9,0.95,0.71,37,1.02)"
+root_test2,test2.png,root,1448x1086,作业中(吊具吊箱悬于平车上方),,255,0,OK-作业中不判,,"{""0"": 20}","reason=weak_evidence top=21.1 posts=12 opacity=0.67 deck=0 under_deck=1 gap=7.5px body=(3,0.06,0.67,141,0.54)"

+ 144 - 0
docs/evidence/test_2026-11-20/测试报告.md

@@ -0,0 +1,144 @@
+# 数据集测试报告:dataset_package_20251120
+
+- 生成时间:2026-11-20
+- 被测后端:**C++ `edge-v2`(生产实现)**,`configs/edge-v2-front.json`,commit `1e47922`
+- 素材:`dataset_package_20251120.zip` → 39 张图(平车 21 / 敞车 16 / 司机视角 2)+ 4 段视频
+
+## 一、测试口径
+
+| 口径 | 配置 | 含义 |
+|---|---|---|
+| 本帧候选 | `require_commit=false` | 单帧判据的 `edge_state`,看算法本身判成什么 |
+| 稳定发布 | `require_commit=true` + 同图重复 20 帧 | PLC 实际采信的 `state`(含 commit/投票/保持) |
+
+状态编码:`0` 不在车上/其他;`1` 敞车;`2` 平车;`3` 空车(空敞车或空平车);`255` 内部弃权(不写 PLC,`RESULT_VALID=0`,寄存器保持上一稳定值)。
+
+灰度按 `IMREAD_GRAYSCALE` 解码后转 PGM(与取流一致),走 C++ `source.type=images` 链路。
+
+## 二、汇总(39 张图)
+
+| 人工场景 | 张数 | 命中 | 弃权 | 误判 |
+|---|---|---|---|---|
+| 空平车 | 8 | 4 | 3 | 1 |
+| 平车坐箱 | 13 | 0 | 8 | 5 |
+| 空敞车 | 16 | 7 | 7 | 2 |
+| 作业中(吊具吊箱悬于平车上方) | 2 | 1 | 0 | 1 |
+| **合计** | **39** | **12** | **18** | **9** |
+
+误差类型分布:作业帧被判车型 ×1;弃权未判 ×18;空车→载车 ×3;载车→空车 ×5
+
+## 三、图片逐条结果
+
+| # | 文件 | 人工判读 | 期望 | 本帧候选 | 发布值 | 结论 | 关键证据 |
+|---|---|---|---|---|---|---|---|
+| 1 | `NX70_001.jpg` | 空平车 | 3 | 2 平车 | 0 不在车上 | 弃权 | reason=deck_edge top=168.0 posts=0 opacity=0.61 deck=1 under_deck=1 gap=20.0px body=(1,0.00,0.71,172,0.00) |
+| 2 | `NX70_002.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=254.7 posts=3 opacity=0.61 deck=0 under_deck=1 gap=25.3px body=(9,0.93,0.62,196,1.06) |
+| 3 | `NX70_003.jpg` | 平车坐箱 | 2 | 3 空车 | 3 空车 | 误判 | reason=empty_vehicle top=250.7 posts=10 opacity=0.68 deck=0 under_deck=0 gap=0.0px body=(10,0.79,0.68,85,1.50) |
+| 4 | `X160_001.jpg` | 空平车 | 3 | 1 敞车 | 1 敞车 | 误判 | reason=wall_posts top=16.0 posts=4 opacity=0.73 deck=1 under_deck=1 gap=0.0px body=(0,0.00,0.00,0,0.00) |
+| 5 | `X160_002.jpg` | 空平车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=16.0 posts=10 opacity=0.80 deck=0 under_deck=0 gap=0.0px body=(10,0.81,0.80,485,1.81) |
+| 6 | `X160_003.jpg` | 空平车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=136.0 posts=2 opacity=0.83 deck=1 under_deck=1 gap=289.3px body=(4,0.71,0.74,316,0.96) |
+| 7 | `X160_004.jpg` | 空平车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=16.0 posts=5 opacity=0.78 deck=0 under_deck=0 gap=0.0px body=(5,0.65,0.78,499,1.25) |
+| 8 | `X160_005.jpg` | 空平车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=bed_roi_small top=16.0 posts=5 opacity=0.83 deck=1 under_deck=1 gap=0.0px body=(5,0.33,0.76,435,0.70) |
+| 9 | `X160_006.jpg` | 空平车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=16.0 posts=7 opacity=0.75 deck=0 under_deck=0 gap=0.0px body=(7,0.86,0.75,460,0.94) |
+| 10 | `X160_007.jpg` | 空平车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=16.0 posts=6 opacity=0.77 deck=0 under_deck=0 gap=0.0px body=(6,0.73,0.77,448,1.24) |
+| 11 | `X70_001.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=228.0 posts=16 opacity=0.62 deck=0 under_deck=0 gap=68.0px body=(5,0.28,0.68,20,1.12) |
+| 12 | `X70_002.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=16.0 posts=6 opacity=0.72 deck=1 under_deck=1 gap=162.7px body=(5,0.40,0.72,110,1.28) |
+| 13 | `X70_003.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=361.3 posts=0 opacity=0.71 deck=0 under_deck=0 gap=0.0px body=(2,0.38,0.74,150,0.00) |
+| 14 | `X70_004.jpg` | 平车坐箱 | 2 | 3 空车 | 3 空车 | 误判 | reason=empty_vehicle top=245.3 posts=6 opacity=0.72 deck=0 under_deck=0 gap=0.0px body=(6,0.79,0.72,285,1.59) |
+| 15 | `X70_005.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=249.3 posts=4 opacity=0.68 deck=0 under_deck=1 gap=5.3px body=(5,0.59,0.72,211,1.26) |
+| 16 | `X70_006.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=262.7 posts=0 opacity=0.67 deck=0 under_deck=0 gap=0.0px body=(2,0.04,0.63,90,0.00) |
+| 17 | `X70_007.jpg` | 平车坐箱 | 2 | 3 空车 | 3 空车 | 误判 | reason=empty_vehicle top=16.0 posts=3 opacity=0.85 deck=0 under_deck=0 gap=0.0px body=(3,0.64,0.85,287,0.75) |
+| 18 | `X70_008.jpg` | 平车坐箱 | 2 | 3 空车 | 3 空车 | 误判 | reason=empty_vehicle top=70.7 posts=10 opacity=0.82 deck=0 under_deck=0 gap=0.0px body=(10,0.93,0.82,125,1.20) |
+| 19 | `X70_009.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=16.0 posts=2 opacity=0.65 deck=0 under_deck=1 gap=0.0px body=(10,0.55,0.81,273,0.70) |
+| 20 | `X70_010.jpg` | 平车坐箱 | 2 | 3 空车 | 3 空车 | 误判 | reason=empty_vehicle top=406.7 posts=12 opacity=0.78 deck=0 under_deck=0 gap=0.0px body=(12,0.69,0.78,76,0.72) |
+| 21 | `X70_011.jpg` | 平车坐箱 | 2 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=16.0 posts=15 opacity=0.48 deck=1 under_deck=1 gap=0.0px body=(3,0.57,0.73,65,0.94) |
+| 22 | `C64K_001.jpg` | 空敞车 | 3 | 2 平车 | 2 平车 | 误判 | reason=deck_edge top=209.3 posts=1 opacity=0.53 deck=1 under_deck=1 gap=0.0px body=(1,0.00,0.61,69,0.00) |
+| 23 | `C64K_002.jpg` | 空敞车 | 3 | 1 敞车 | 0 不在车上 | 弃权 | reason=wall_posts top=325.3 posts=10 opacity=0.67 deck=1 under_deck=1 gap=2.7px body=(0,0.00,0.00,0,0.00) |
+| 24 | `C64K_003.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=228.0 posts=6 opacity=0.71 deck=0 under_deck=0 gap=0.0px body=(6,0.67,0.71,77,0.51) |
+| 25 | `C64K_004.jpg` | 空敞车 | 3 | 1 敞车 | 0 不在车上 | 弃权 | reason=wall_posts top=180.0 posts=12 opacity=0.69 deck=0 under_deck=0 gap=n/a body=(0,0.00,0.00,0,0.00) |
+| 26 | `C64K_005.jpg` | 空敞车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=314.7 posts=0 opacity=0.65 deck=1 under_deck=1 gap=46.7px body=(0,0.00,0.69,153,0.00) |
+| 27 | `C64K_006.jpg` | 空敞车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=253.3 posts=0 opacity=0.59 deck=0 under_deck=1 gap=26.7px body=(0,0.00,0.68,185,0.00) |
+| 28 | `C64_001.jpg` | 空敞车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=16.0 posts=4 opacity=0.68 deck=0 under_deck=1 gap=0.0px body=(1,0.00,0.70,125,0.00) |
+| 29 | `C70E_001.jpg` | 空敞车 | 3 | 1 敞车 | 1 敞车 | 误判 | reason=wall_posts top=202.7 posts=7 opacity=0.68 deck=0 under_deck=0 gap=0.0px body=(0,0.00,0.00,0,0.00) |
+| 30 | `C70E_002.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=16.0 posts=5 opacity=0.69 deck=0 under_deck=0 gap=0.0px body=(5,0.62,0.69,135,0.31) |
+| 31 | `C70E_003.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=254.7 posts=9 opacity=0.78 deck=0 under_deck=0 gap=0.0px body=(9,0.85,0.78,112,0.73) |
+| 32 | `C70E_004.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=258.7 posts=14 opacity=0.73 deck=0 under_deck=0 gap=0.0px body=(14,0.86,0.73,152,0.78) |
+| 33 | `C70H_001.jpg` | 空敞车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=210.7 posts=3 opacity=0.64 deck=0 under_deck=1 gap=60.0px body=(0,0.00,0.63,119,0.00) |
+| 34 | `C70_001.jpg` | 空敞车 | 3 | 255 弃权 | 0 不在车上 | 弃权 | reason=weak_evidence top=16.0 posts=1 opacity=0.57 deck=0 under_deck=1 gap=0.0px body=(2,0.53,0.62,150,0.00) |
+| 35 | `C70_002.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=236.0 posts=4 opacity=0.67 deck=0 under_deck=0 gap=0.0px body=(4,0.96,0.67,37,0.61) |
+| 36 | `C70_003.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=177.3 posts=3 opacity=0.76 deck=0 under_deck=0 gap=0.0px body=(3,0.61,0.76,70,0.56) |
+| 37 | `C80_001.jpg` | 空敞车 | 3 | 3 空车 | 3 空车 | 命中 | reason=empty_vehicle top=246.7 posts=6 opacity=0.74 deck=0 under_deck=0 gap=0.0px body=(6,0.70,0.74,184,0.96) |
+| 38 | `test1.png` | 作业中(吊具吊箱悬于平车上方) | 不判 | 3 空车 | 3 空车 | 风险-作业中被判车型 | reason=empty_vehicle top=115.0 posts=9 opacity=0.71 deck=0 under_deck=0 gap=0.0px body=(9,0.95,0.71,37,1.02) |
+| 39 | `test2.png` | 作业中(吊具吊箱悬于平车上方) | 不判 | 255 弃权 | 0 不在车上 | OK-作业中不判 | reason=weak_evidence top=21.1 posts=12 opacity=0.67 deck=0 under_deck=1 gap=7.5px body=(3,0.06,0.67,141,0.54) |
+
+## 四、视频结果
+
+| 视频 | 人工判读 | 期望 | 分辨率 | 时长 | 抽样 | 发布分布 | 末值 | 结论 |
+|---|---|---|---|---|---|---|---|---|
+| `video1.mp4` | 司机视角近距:前方敞车 + 吊具在头顶(作业中) | 不判 | 720x1280 | 29.2s | 60 帧 | 0 不在车上×60 | 0 不在车上 | OK-作业中不判 |
+| `video2.mp4` | 空 C70EH 敞车(近距侧视,前景整车) | 3 | 1280x720 | 148.0s | 60 帧 | 0 不在车上×14, 2 平车×46 | 2 平车 | 误判 |
+| `video3.mp4` | 夜间司机视角:敞车侧墙 + 吊具(作业中) | 不判 | 1080x1920 | 130.0s | 60 帧 | 0 不在车上×60 | 0 不在车上 | OK-作业中不判 |
+| `video4.mp4` | 空 C70E 敞车列(远距侧视,多节) | 3 | 1280x720 | 166.1s | 60 帧 | 0 不在车上×60 | 0 不在车上 | 弃权 |
+
+## 五、对照集(部署机位近距素材)
+
+同一 harness、同一配置,跑之前已人工判读并验证过的近距/前视素材:
+
+| 文件 | 内部编号 | 期望 | 本帧候选 | 发布值 | 结论 |
+|---|---|---|---|---|---|
+| `01_flatcar_0022.jpg` | `ctl_01_flatcar` | 2 | 2 平车 | 2 平车 | 命中 |
+| `02_C70E_shigure03.jpg` | `ctl_02_C70E` | 3 | 3 空车 | 3 空车 | 命中 |
+| `03_C70EA_DF10.jpg` | `ctl_03_C70EA` | 3 | 3 空车 | 3 空车 | 命中 |
+| `04_container_on_gondola.png` | `ctl_04_gondola_box` | 1 | 1 敞车 | 1 敞车 | 命中 |
+| `32660093_235242226126_2.jpg` | `ctl_05_flat_white` | 2 | 2 平车 | 2 平车 | 命中 |
+| `32660093_235245226128_2.jpg` | `ctl_06_flat_blue` | 2 | 255 弃权 | 0 不在车上 | 弃权 |
+| `bb449ffa5831d520132a6dc9a2d059da.png` | `ctl_07_gondola_tank` | 1 | 1 敞车 | 1 敞车 | 命中 |
+
+## 六、P0-Q11 迭代结论(2026-11-20 第二轮修钉)
+
+**已实现(安全方向,纯收紧)**:作业帧硬门 —— 吊具高悬 / 吊具仍夹箱时**不判 1/2/3**,
+直接 `state=255, reason=hoist_high`。诱因是 `root_test1`(司机视角、吊具吊着箱悬在平车上方)
+曾被空车判据当成敞车侧墙(`posts=9 span=0.95` → 误判 3)。C++/Python 两侧同构,
+`selftest_edge_v2` 与 `test_evidence_v2` 均已加断言。
+
+本批素材的图像侧吊具检测未触发(`root_test1` 仍 `hoist=false`),所以上表数值不变;
+接入 PLC「到位 / 吊具松开」信号(`plc_interface §7 #11`)后,这类帧会稳定弃权。
+
+**已量化但未采纳的两条**(数据不支持,采纳会破坏域内表现):
+
+| 设想 | 实测结果 |
+|---|---|
+| 载车→空车:用 `posts/span/opacity/spcv` 区分箱壁与敞车侧墙 | 载车 `body=(3~12, 0.64~0.93, 0.68~0.85)`;空车 `body=(3~14, 0.61~0.96, 0.59~0.85)` → **完全重叠** |
+| 空车→平车:用边梁下方 `ground` 区分 | 载车 `ground 0.30~0.38`;空敞车 `0.16~0.47` → 重叠,且 5 项合成单测因该门失败 → **已回退** |
+| 用估箱高 / 自标尺区分远近 | 全语料 `px_per_m=0`(自标尺未建立)→ **无信号** |
+
+**结论**:这批 `web_cc` 素材属**域外**(广角侧视/远景图库照片),几何判据无法分辨
+“集装箱侧壁”与“敞车侧墙”。正解是引入**车型小分类器**(用这 39 张 + `video2` 训练/验证),
+而不是继续调阈值;在此之前,广角/远景机位部署应保持 `allow_state2=false` / `allow_state3=false`。
+
+## 七、失效机理
+
+1. **域内(部署机位近距素材)表现正常**:对照集 7 张里 6 张命中(含两张空敞车→3、罐箱敞车→1),
+   唯一弃权的是 NX70A 平车+蓝箱(车面边梁偏暗,`deck_edge` 不成立,属已在文档记录的已知漏报)。
+2. **域外(广角侧视/远景图库)偏差明显**,机理可定位到具体判据:
+
+| 失效 | 触发判据 | 机理 |
+|---|---|---|
+| 载箱→空车 3 | `empty_vehicle` | body ROI 取**全宽**后,任意 3 根竖线(接触网杆、车帮、箱棱)满足 `posts∈[3,16]` + `span≥0.6` + `opacity≥0.55` 即判空车;例:`flatcar_X70_007`(载 COSCO 箱)`body=(3,0.64,0.85,287)` → 3 |
+| 空车→平车 2 | `deck_edge` + `under_deck` | 空敞车**车帮顶面亮边**被当成「薄车面边梁」,车帮下方暗带被当成「车下透空」;例:`video2`(空 C70EH)46/60 帧判 2 |
+| 空车→敞车 1 | `wall_posts` | 车帮/端墙竖棱被数成门板立柱;例:`flatcar_X160_001`(空平车)`posts=4 deck=1 under_deck=1` → 1 |
+| 大量弃权 255 | `gap`/`posts` 门 | 远景下箱底—车面间隙 25~163 px 远超 `max_bed_gap_px=40`,或立柱数不足 |
+
+3. **根因**:v2 的几何判据是按部署机位(相机在车角外侧、近距、箱底与车面位于画面中部)整定的;
+   广角侧视把「整车」压成一条横带,`window=[0.24,0.02,0.78,0.95]` 与「箱底以下 ROI」的几何前提不再成立。
+
+## 八、建议
+
+1. `empty_vehicle` / `empty_flatbed` 必须加**车体强证据**(车轮/转向架、车体上下边界同时可见),
+   并把 body ROI 从「全宽」限制到「箱体下方 ±1 箱宽」,禁止跨整幅画面找「立柱」。
+2. `2` 的 `deck_edge` 需加互斥:若亮边**上方是不透明竖直墙**(敞车车帮),不得判平车;
+   并把「边梁下方」从「更暗的行」升级为「透空 + 地面/道砟」。
+3. 若要覆盖广角/远景(高点监控、图库素材),需单独 `view=high` / `preset` 参数组,不与近距参数混用。
+4. **本 zip 的 web_cc 39 张不能作为现场精度依据**;验收仍以现场机位片段(A/B + 对照集)为准,
+   但这些图正好暴露了 `3` 与 `2` 的边界问题,建议纳入回归负样本池(断言「载车不得 3」)。
+

+ 13 - 0
docs/route_v2.md

@@ -328,6 +328,18 @@ PLC 若只看 `state`,会把“保持的 0”误当成“已确认不在车上
 > 竖向/横向边缘块覆盖率 ≤ `empty_flatbed_max_plane_edge`(0.12),且灰度不低于
 > 边梁 `empty_flatbed_max_gray_drop`(80)—— 排除集装箱侧壁(瓦楞/立柱)与阴影。
 > 命中 → `state=3`、`class_reason=empty_flatbed`、`gap=0`。
+> **[P0-Q11] 作业帧硬门(2026-11-20 第二轮修钉)**:吊具高悬 / 吊具仍夹箱时
+> **不判 1/2/3**,直接 `state=255, reason=hoist_high`(C++/Python 同构)。
+> 诱因是实拍 `root_test1`(正面吊司机视角、吊具吊着箱悬在平车上方):吊具横梁 +
+> 箱体侧壁被空车判据当成“敞车侧墙”(`posts=9 span=0.95`)→ 误判 `3`。
+> 旧口径是“分类仍给 1、只拦 commit”,对 PLC 不安全;现在 `state` 也一并置 255。
+> 触发源:PLC 注入(`plc_arrived` / 吊具松开位,`plc_interface §7 #11`)或图像侧
+> `detect_hoist_high`,任一命中即生效(`reject_hoist_high` / `reject_spreader_contact`)。
+> **同时记录一条“做不到”的边界**:在 39 张广角侧视图库素材上,`posts/span/opacity`
+> 与 `ground` 都**无法**区分“集装箱侧壁”与“敞车侧墙”(载车 `body=(3~12,0.64~0.93,0.68~0.85)`
+> vs 空车 `body=(3~14,0.61~0.96,0.59~0.85)`,分布完全重叠;`ground` 亦重叠且会误伤合成单测),
+> 因此没有采纳按阈值区分;这类域外机位需要车型分类器,在此之前保持
+> `allow_state2=false` / `allow_state3=false`。详见 `docs/evidence/test_2026-11-20/`(桌面报告)。
 > **与空敞车互斥**:先判敞车侧墙(P0-Q9),未命中才判空平车。
 > 实测:合成空平车场景 → `3` 且 6 帧内 commit;`flat_scene`(平车+箱)→ `2`;
 > `ground`/`thick_contact`/`stacked` → 不判 3;A 发布 `1×43/0×7`、B 发布
@@ -815,6 +827,7 @@ else:
 
 | 日期 | 变更 |
 | --- | --- |
+| 2026-11-20 | **P0-Q11 作业帧硬门(吊具高悬/夹箱时绝不判车型)+ 记录一条"做不到"的边界**:① 空车/空平车判据的覆写一律先过 `hoist_flag`:命中即 `state=255 / class_reason=hoist_high`(旧口径"分类仍给 1、只拦 commit"会把 `root_test1` 的"吊具横梁+箱体侧壁"当成空车 3 发给 PLC)。C++/Python 同构,`selftest_edge_v2` 75/0(新增 3 项)、Python `HoistBlocksTypeTests` 3 项。② 顺带补诊断:`BodyEvidence.spcv`(立柱间距变异系数)与 `boxh/bedh`(箱底暗带/边梁亮带高度)进 C++ summary,Python `_measure_body` 返回 `spcv`。③ 量化后**未采纳**:39 张 `web_cc` 广角侧视图上,`posts/span/opacity` 与 `ground` 均无法区分"集装箱侧壁 vs 敞车侧墙"(载车 `body=(3~12,0.64~0.93,0.68~0.85)` vs 空车 `(3~14,0.61~0.96,0.59~0.85)`,完全重叠;`ground` 门实测会误伤 5 项合成单测,已回退),`px_per_m` 全为 0 亦无尺度信号 → 域外机位需车型分类器,暂保持 `allow_state2/3=false`。A/B 回归不变(A 发布 `1×40`、B 发布 `2×40`) |
 | 2026-11-20 | **P0-Q10 空平车也输出 `state=3`(并修掉一个危险误判)**:① 先删掉"严格竖棱门数不够就回退宽松"的兜底——实测 `img01`(NX70A 平车+蓝箱,真值 2)在宽松门下会被聚成 7 根"立柱"→ 越过空车门变成 **3**(载车被判空车);空 C70/C70EA 在严格门下本来就够数(9/5 根),回退无收益。② 新增空平车判据 `evidence_v2.empty_flatbed_*`:`under_deck` + 薄边梁 + **箱底不贴边梁**(`gap_px ≥ 16 px`;载车三样本实测 gap≈0)+ 边梁上方是光滑亮车面(`vcov/hcov ≤ 0.12`,灰度降 ≤80)→ `state=3`、`class_reason=empty_flatbed`。与空敞车互斥(先判侧墙)。③ 实测:合成空平车 → 3(6 帧 commit);`flat_scene` → 2;`ground/thick_contact/stacked` → 不判 3;七张实测图 = `2/3/3/1 + 255/255/1`(img01 由 3 修正为 255);A 发布 `1×43/0×7`、B 发布 `2×18/0×32` 与基线逐帧一致。**空平车真机素材仍缺**,阈值由合成 + 载车 gap≈0 支撑 |
 | 2026-11-20 | **P0-Q9 空车单独输出 `state=3`(取代 P0-Q7 的"空车一律 255")**:把空车逻辑从 255 里摘干净,做成独立判据 `evidence_v2.empty_*`:`texture_top` 以下侧墙 ROI 必须满足 门板立柱∈[3,16] / 跨度≥0.60 / 不透明≥0.55 / 斜撑≥1 / **可见墙高≥0.25 画幅** / **竖棱长度≥0.30×墙高**,命中→`3`(`gap=0`);只"看得见车体结构但不够完整"仍按旧口径 `255 ambiguous_empty_vehicle`。两道安全门:①`empty_wall_below_deck`(平车"薄车面边梁+车面下暗带"出现在候选墙之上 ⇒ 那是车面以下的地面,不判空车);②空车专用竖棱门(0.30 vs 兜底的 0.15,防止平车车面下方的地面碎竖棱被当成门板)。实测:`02_C70E`、`03_C70EA` 两张空车图 **255 → 3**;`01_flatcar`(posts=63)/`04_container_on_gondola`(墙高 13%) 保持 **2 / 1** 不变;`00` 合成地面/堆料仍不判 3。状态码全线放开到 `{0,1,2,3}`(schema/STATE_LABELS/PublishGate/commit/check_contract_v2/replay_check/plc_interface);新增 `allow_state3`(顶层与 `commit` 串联)。Python `test_evidence_v2.EmptyVehicleTests` 5 项 + C++ `selftest_edge_v2` 4 项 |
 | 2026-11-19 | **P0-Q8 Python/C++ 判据对齐(四张图两侧同为 2/255/255/1)**:① `_measure_body` 改用 `body_min_post_len_ratio`(0.15) —— 原用主判据的 0.30,1920 宽平车图竖棱被打断成 ≤121 px,**一根都数不到**→误判“空车歧义”;② 空车歧义的“箱底以下无立柱”由 `==0` 放宽到 `<=1`(`02_C70E`:C++ 0 根 / Python 1 根,用 0 结论不同);③ Python 补回“必须有天空”的车体兜底门(与 C++ 一致);④ **回放脚本必须按灰度解码**(`imread(..., IMREAD_GRAYSCALE)`):JPEG 经 BGR→gray 差 ±1 灰阶,`find_texture_top` 从 404 跳到 636 → 平车被判空车。`scripts/vis_evidence_v2_steps.py` 同步修好并补 NO_BOX 4 宫格 |

+ 1 - 1
docs/runtime_route_decision.md

@@ -169,7 +169,7 @@ python scripts/replay_check.py runs/field_B/dump.jsonl --report runs/field_B/rep
 | 配置自检 | `portcv_config_selftest` | 269 通过 / 0 失败(含 `source.*` 默认值与 10 条非法值、`evidence_v2` 安全门参数校验) |
 | 帧率自检 | `portcv_rate_selftest` | 110 通过 / 0 失败 |
 | 证据自检 | `portcv_edge_selftest` | **112 通过 / 0 失败**(2026-10-27:C1/F2/F3/G2 等 12 项历史失败清零;A/B 现场片段同步通过,见 `docs/edge_evidence.md` §7.1) |
-| v2 证据自检 | `portcv_edge_v2_selftest` | **56 通过 / 0 失败**(含 P0-0 吊具高悬 / 夹箱门、远距 ROI 弃权、`allow_state2` 回退、P0-Q3 地面/堆料/堆叠箱负样本) |
+| v2 证据自检 | `portcv_edge_v2_selftest` | **75 通过 / 0 失败**(含 P0-0 吊具高悬 / 夹箱门、远距 ROI 弃权、`allow_state2` 回退、P0-Q3 地面/堆料/堆叠箱负样本) |
 | 端到端导出 | `portcv_run --backend edge --source-type synth --source-uri gondola --dump-frames runs/dump/dump.jsonl --max-frames 12 --no-plc` | 退出码 0,产出 12 帧 PGM + 12 行 JSONL |
 | 回放断言 | `python scripts/replay_check.py runs/dump/dump.jsonl` | **322 项断言通过 / 0 FAIL / 0 WARN**,12 帧像素逐字节校验(`gray_crc32` = `zlib.crc32`) |
 | 负向对照 ① | 篡改 1 个像素字节后回放 | 1 FAIL:`frame 3: gray_crc32=95890003 与像素实算 1924143813 不符` |

+ 1 - 1
docs/standard_gbt45163_5_review.md

@@ -184,7 +184,7 @@ a) 传感器标定;b) 目标识别(被吊物、位置、抓取特征、装
 
 | 项 | 状态 | 代码/证据 |
 | --- | --- | --- |
-| P0-0 时序/commit 安全 | **已完成(Python + C++ 全链路,含 C++ 图像高悬门)** | `TemporalVoter` 去掉 UNKNOWN 冷启动直通,首帧/复位首帧必须过 `min_dwell_s`;`CommitTracker` 新增 `hoist_high` 安全门(不累计窗口);Python `detect_spreader_contact` / `detect_hoist_high` ↔ C++ `cpp/src/edge_v2_gates.cpp`(同判据、零依赖,`extract_segments` 代替 Hough);C++ 侧命中即 `abstain_reason=hoist_high/spreader_contact`、`edge_state=255`;回归 `portcv_edge_v2_selftest` 56/0(合成高悬帧 6 帧 0 commit、注入路径、门关闭对照;P0-Q3 地面/堆料/堆叠箱负样本)+ `replay_check.py` 新增"高悬命中 ⇒ 必须 255"断言。**负样本原片(TP-SAFE-001 mp4)仍缺失**,`i=668` 用等价合成帧覆盖 |
+| P0-0 时序/commit 安全 | **已完成(Python + C++ 全链路,含 C++ 图像高悬门)** | `TemporalVoter` 去掉 UNKNOWN 冷启动直通,首帧/复位首帧必须过 `min_dwell_s`;`CommitTracker` 新增 `hoist_high` 安全门(不累计窗口);Python `detect_spreader_contact` / `detect_hoist_high` ↔ C++ `cpp/src/edge_v2_gates.cpp`(同判据、零依赖,`extract_segments` 代替 Hough);C++ 侧命中即 `abstain_reason=hoist_high/spreader_contact`、`edge_state=255`;回归 `portcv_edge_v2_selftest` 75/0(合成高悬帧 6 帧 0 commit、注入路径、门关闭对照;P0-Q3 地面/堆料/堆叠箱负样本)+ `replay_check.py` 新增"高悬命中 ⇒ 必须 255"断言。**负样本原片(TP-SAFE-001 mp4)仍缺失**,`i=668` 用等价合成帧覆盖 |
 | P0-1 识别结果对象 | **已完成** | `portcv/recognition.py`:`RecognitionResult` / `ObjectType` / `results_from_observation`;`schema.recognition_results()` 兼容入口;JSON 往返测试 |
 | P0-2 flags 扩展 | **已完成(Python + C++ 位定义/契约)** | `StatusBits` bit8~12;`PublishGate.perception_uncertain`;`PERCEPTION_UNCERTAIN ⇒ RESULT_VALID=0`;`DATA_LOSS` 随 `FRAME_TIMEOUT`;契约向量与寄存器说明同步 |
 | P0-3 自监测 | **已完成(Python 运行时)** | `portcv/health.py`:清晰度/削顶/低纹理/时域差 + 迟滞;`runner` 输出 `SENSOR_DEGRADED`、`PERCEPTION_UNCERTAIN`、`MRC_REQUEST` 与健康日志 |

+ 19 - 0
portcv/logic/evidence_v2.py

@@ -1491,11 +1491,21 @@ class EvidenceV2:
             density_hi=self.p.ground_density_hi,
         )
         opacity = 1.0 - ground if blocks > 0 else 0.0
+        # P0-Q11:立柱间距变异系数(门板阵列等距;接触网杆/箱棱/杂物不等距)。
+        spcv = 0.0
+        if len(positions) >= 3:
+            gaps = [positions[i + 1] - positions[i]
+                    for i in range(len(positions) - 1)]
+            mean_gap = sum(gaps) / float(len(gaps))
+            if mean_gap > 1e-6:
+                var = sum((g - mean_gap) ** 2 for g in gaps) / float(len(gaps))
+                spcv = float(np.sqrt(var) / mean_gap)
         return {
             "posts": int(structure["post_count"]),
             "span": float(span),
             "opacity": float(opacity),
             "diagonal": int(structure["diagonal_lines"]),
+            "spcv": float(spcv),
             "height": float(roi[3] - roi[1]) / max(scale, 1e-6),
         }
 
@@ -1958,6 +1968,15 @@ class EvidenceV2:
             conf = 0.0
             hits = 0.0
             reason = "ambiguous_empty_vehicle"
+        # P0-Q11:作业帧(吊具高悬 / 吊具仍夹箱)**绝不判车型**。
+        # 根因:吊具/箱体悬在车体上方时,空车判据会把“吊具横梁 + 箱体侧壁”当成
+        # 敞车侧墙(实测 root_test1:posts=9 span=0.95 → 误判 3)。hoist_flag 已算好,
+        # 这里在空车/空平车覆写之后、commit 之前拦一道。
+        if hoist_flag and state in (1, 2, 3):
+            state = int(SceneState.UNKNOWN)
+            conf = 0.0
+            hits = 0.0
+            reason = "hoist_high"
         commit = self.tracker.update(
             ts,
             state=state,

+ 27 - 0
tests/test_evidence_v2.py

@@ -415,6 +415,33 @@ class EmptyFlatbedTests(unittest.TestCase):
                          result.diagnostics)
 
 
+class HoistBlocksTypeTests(unittest.TestCase):
+    """P0-Q11:作业帧(吊具高悬 / 吊具仍夹箱)**绝不判车型**。
+
+    实拍根因:`root_test1`(正面吊司机视角,吊具吊着箱悬在平车上方)里
+    “吊具横梁 + 箱体侧壁”被空车判据当成敞车侧墙(posts=9 span=0.95)→ 误判 3。
+    """
+
+    def test_hoist_high_blocks_empty_vehicle_state3(self):
+        ev = make(EvidenceV2Params(px_per_m=115.6, require_commit=False))
+        result = ev.analyze(sky_wire_scene(), ts=0.0, hoist_high=True)
+        self.assertNotEqual(result.state, 3, result.to_dict())
+        self.assertTrue(result.hoist_high, result.to_dict())
+        self.assertEqual(result.class_reason, "hoist_high", result.to_dict())
+
+    def test_hoist_high_blocks_flatbed_state2(self):
+        ev = make(EvidenceV2Params(px_per_m=115.6, require_commit=False))
+        result = ev.analyze(flat_scene(), ts=0.0, hoist_high=True)
+        self.assertNotEqual(result.state, 2, result.to_dict())
+        self.assertTrue(result.hoist_high, result.to_dict())
+
+    def test_without_hoist_same_scene_still_judges(self):
+        # 同样的画面,没有吊具信号时仍应正常判 3(门只拦作业帧,不误伤空车)
+        ev = make(EvidenceV2Params(px_per_m=115.6, require_commit=False))
+        result = ev.analyze(sky_wire_scene(), ts=0.0)
+        self.assertEqual(result.state, 3, result.to_dict())
+
+
 class GroundStackSafetyTests(unittest.TestCase):
     """P0-Q3:地面/堆料/堆叠箱不得被判成 1(敞车)或 2(平车)。"""