PB 标定文件反序列化校验、解析为 YAML、从 YAML 组装为 .pb.txt
Project description
pb-calibration
PB 标定文件(.pb.txt)反序列化校验、解析为 YAML、从 YAML 按顺序组装为 .pb.txt。
输出位置与组合位置一致,且可指定。
安装
pip install pb-calibration
功能
- 反序列化检查:检查
pb.txt是否存在格式问题(能否正常解析)。 - 解析为 YAML:将
pb.txt解析为每个单独的 yaml 文件,输出到指定目录;该目录与后续「组合」时使用的目录一致。 - 从 YAML 组装:按顺序将指定目录中的单独 yaml 文件组装成
pb.txt(输入目录与解析输出目录一致,可指定)。
命令行
# 1. 检查 pb.txt 格式
pb-calibration check -i /path/to/vehicle_config.pb.txt
# 2. 解析 pb.txt 为 yaml,输出到指定目录(该目录即后续 build 的输入)
pb-calibration parse -i /path/to/vehicle_config.pb.txt -o /path/to/yaml_dir
# 3. 从指定目录按顺序组装为 pb.txt(目录与 parse 的 -o 一致)
pb-calibration build -i /path/to/yaml_dir -o /path/to/vehicle_config_out.pb.txt
可选参数:--templates /path/to/proto_templates 指定模板目录,不指定则使用包内模板。
Python API
接口说明
| 接口 | 签名 | 说明 |
|---|---|---|
| check | check(pb_path, proto_templates_dir=None) -> (bool, str | None) |
反序列化校验 .pb.txt 格式;返回 (是否通过, 错误信息),通过时错误信息为 None。 |
| parse | parse(pb_path, yaml_dir, proto_templates_dir=None) -> (dict, dict) |
将 .pb.txt 解析为多份 YAML 并写入 yaml_dir;返回 (解析后的结构化数据, 缺项/漏项报告);失败会抛异常。 |
| build | build(yaml_dir, output_pb_path, proto_templates_dir=None) -> None |
按顺序将 yaml_dir 中的 YAML 组装成 .pb.txt;无返回值,失败抛异常。 |
参数说明:
-
check
pb_path(str, 必填):.pb.txt文件路径。proto_templates_dir(str | None, 可选):proto 模板目录,不传则使用包内模板。
-
parse
pb_path(str, 必填):.pb.txt文件路径。yaml_dir(str, 必填):YAML 输出目录,应与后续build的输入目录一致。proto_templates_dir(str | None, 可选):proto 模板目录。
-
build
yaml_dir(str, 必填):包含order_manifest.yaml及分组 YAML 的目录(即parse的输出目录)。output_pb_path(str, 必填):输出的.pb.txt路径。proto_templates_dir(str | None, 可选):proto 模板目录。
使用方法
from pb_calibration import check, parse, build
# 1. 反序列化检查
ok, err = check("vehicle_config.pb.txt")
if not ok:
print("格式错误:", err)
# 2. 解析为 yaml,输出到指定目录(与 build 输入一致)
yaml_dir = "./output/yaml" # 可任意指定
data, missing_report = parse("vehicle_config.pb.txt", yaml_dir)
# data: 解析后的结构化数据;missing_report: 与模板对比的缺项报告
# 3. 从同一目录按顺序组装为 pb.txt
build(yaml_dir, "vehicle_config_rebuilt.pb.txt")
典型流程:
- 只校验:
check(pb_path)→ 根据ok和err判断格式是否正常。 - PB → 可编辑 YAML:
parse(pb_path, yaml_dir)→ 在yaml_dir中修改 YAML。 - YAML → 新 PB:
build(yaml_dir, output_pb_path)。
- 输出位置与组合位置一致:
parse(..., yaml_dir)与build(yaml_dir, ...)使用同一个yaml_dir,可任意指定路径。
YAML 目录结构
解析后目录内包含:
order_manifest.yaml:顺序清单vehicle_info.yaml、vehicle_param.yamlextrinsics/000.yaml、001.yaml、…intrinsics/<frame_id>.yaml、…
组装时从同一目录按 order_manifest.yaml 顺序读取并生成 .pb.txt。
依赖
- Python >= 3.8
- PyYAML >= 6.0
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pb_calibration-0.0.1.tar.gz
(12.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pb_calibration-0.0.1.tar.gz.
File metadata
- Download URL: pb_calibration-0.0.1.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb22f43c720b6d3e871c4c0039533b1b6825ce99328e92c8330b7994ec61b76a
|
|
| MD5 |
eec45e322a97012e0c905c0961787b83
|
|
| BLAKE2b-256 |
e5e84f41a45844ed11760bef7d712827a11081519332f50bb6fe030c41e6e0b8
|
File details
Details for the file pb_calibration-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pb_calibration-0.0.1-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7827f412d61436e769995e8426f3758c44ab9d82be4c681bec0b39534f4da1b8
|
|
| MD5 |
32f17350b71574915afeebc200ea8b09
|
|
| BLAKE2b-256 |
d3985de5996de7a3b547daa36572f67285f5108bd3c15a49cb629d78d90feae1
|