Chapter 1: 黄金参考系统 — 在 x86 上搭建像素级对齐的 C++ 推理管线

Chapter 1: Building a Golden Reference System

Project AttributeDetails
Project NameHelmsman — Golden Reference System
PhaseFoundation F1
Date2026-01 ~ 2026-02
Key PersonnelPotter White

1. Core Question

2. Goal Review

3. Implementation

|导出 reference_tensor.txt| B[对比]
C[C++ preprocess] -->|导出 cpp_tensor.txt| B
B -->|diff 无差异| D[✅ 对齐成功]

步骤:
1. 预处理对齐:OpenCV resize + normalize [0,255]→[-1,1] + HWC→CHW
2. 推理引擎封装:InferenceEngineONNX 类(Load + Infer)
3. 后处理:pha tensor → alpha matte → alpha blend
4. 验证:md5 逐字节对比
-->

### **4. Key Challenge: 归一化精度 Bug**

<!-- 填入:
- 现象:bitwise 对比失败,Python 和 C++ 的 tensor 数据有微小差异
- 根因:float 精度差异(浮点运算顺序不同导致的舍入误差)
- 解决:统一 normalize 实现,确保逐元素操作顺序一致
- 参考 PKB:bug-F1-normalization-bitwise.md
-->

### **5. Outcome**

<!-- 填入:
- C++ 输出与 Python baseline md5 一致 ✅
- Golden Reference 作为后续所有板端测试的 baseline
- 封装了可复用的模块:TensorData、InferenceEngineONNX、Preprocessor
-->

### **6. Reusable Assets**

<!-- 填入:表格,列出这一阶段产出的可复用代码/工具:

| 资产 | 路径 | 说明 |
|------|------|------|
| TensorData | include/.../tensor-data.h | 统一的 tensor 数据结构 |
| InferenceEngineONNX | src/.../inference/onnx/ | ONNX Runtime 封装 |
| Preprocessor | src/.../frontend/preprocessor.cpp | 预处理模块 |

-->