feat: 特殊车牌生成管线 + C++/多进程/色温校正

This commit is contained in:
kirl committed 2026-06-21 10:32:37 +08:00
1 parent 3808b9f035
commit 3101992f51
29 files changed
+2336 -80

No files matched your search

+145
View File
@@ -0,0 +1,145 @@
# ICE Plate Swap — C++ 高性能特殊车牌替换引擎
基于 CCPD 真实街景照片,将普通蓝牌替换为 9 种特殊车牌。
C++ / OpenCV 实现,32 线程满血,~53 张/秒。
---
## 快速开始
### 1. 环境要求
| 组件 | 说明 |
|------|------|
| Windows 10/11 x64 | — |
| [Visual Studio 2022 BuildTools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) | 含 C++ 桌面开发 workload |
| [OpenCV 4.10.0](https://github.com/opencv/opencv/releases/tag/4.10.0) | 解压到 `C:\opencv` |
### 2. 预编译版 (推荐)
直接下载 `plate_swap.exe`(已通过 Git LFS 管理):
```powershell
# 设置 OpenCV DLL 路径
$env:PATH = "C:\opencv\build\x64\vc16\bin;$env:PATH"
# 运行
.\install\plate_swap.exe --help
```
### 3. 从源码编译
```powershell
# 打开 VS Developer Command Prompt
# 然后:
cd CCPD_SPE_GEN\cpp_pipeline
cmake -B build -G "Visual Studio 17 2022" -A x64 -DOpenCV_DIR=C:\opencv\build
cmake --build build --config Release --parallel
```
---
## 用法
```powershell
$env:PATH = "C:\opencv\build\x64\vc16\bin;$env:PATH"
.\plate_swap.exe `
--ccpd-dir ./CCPD/CCPD2019/ccpd_base,./CCPD/CCPD2019/ccpd_tilt `
--plate-type police `
--plate-pool ./output/plate_pool_v2 `
--output ./CCPD_SPE `
--num 1000 `
--workers 24
```
### 参数
| 参数 | 必需 | 默认 | 说明 |
|------|------|------|------|
| `--ccpd-dir` | ✅ | — | CCPD 图片目录,多个用逗号分隔 |
| `--plate-type` | ✅ | — | 特殊车牌类型 |
| `--plate-pool` | ✅ | — | 预生成车牌池路径(含 `pool.bin`) |
| `--output` | ✅ | — | 输出根目录 |
| `--num` | | 500 | 生成图片数量 |
| `--workers` | | 全部核心 | 并行线程数 |
| `--seed` | | 42 | 随机种子 |
| `--fast` | | false | 快速模式(跳过退化模拟,不建议) |
| `--h-shift` | | 0 | 底板色相偏移 (GUI调色) |
| `--s-scale` | | 100 | 底板饱和度缩放% |
| `--v-scale` | | 100 | 底板明度缩放% |
### 支持的类型
```
police 警用车牌 (白底, JING)
army 军车/武警 (白底)
gangao 港澳入出境 (黑底, GANG/AO)
shiguan_old 使馆旧版 (黑底, SHI)
shiguan_new 使馆新版 (黑底)
lingguan_old 领馆旧版 (黑底, LING)
lingguan_new 领馆新版 (黑底)
coach 教练车 (黄底, XUE)
new_energy 大型新能源 (黄绿双拼, 8位)
```
---
## 预生成车牌池
```powershell
cd ICE_Dataset
python CCPD_SPE_GEN\cpp_pipeline\gen_plate_pool.py --num 1000 --output ./output/plate_pool_v2
```
生成 `pool.bin` (~1.6GB),含 9 种类型各 1000 张 + 车牌号元数据。
---
## 输出结构
```
CCPD_SPE/
├── ccpd_base/
│ ├── police/
│ ├── gangao/
│ └── ...
├── ccpd_tilt/
└── ...
```
文件名: `{CCPD原名}__{类型}__{车牌号拼音}.jpg`
---
## 性能
| 指标 | 值 |
|------|-----|
| 单线程 | ~7 张/秒 |
| 24 线程 | ~53 张/秒 |
| 35.5 万张全量 | ~1.9 小时 |
---
## 调色 GUI
```powershell
python CCPD_SPE_GEN\cv_pipeline\color_tuner.py
```
H/S/V 滑块实时预览 → 按 `S` 保存 → `plate_color_profile.py` → C++ 管线 `--h-shift` `--s-scale` `--v-scale` 读取。
---
## 构建
```powershell
# 安装 OpenCV
Invoke-WebRequest "https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-windows.exe" -OutFile "$env:TEMP\opencv.exe"
Start-Process "$env:TEMP\opencv.exe" -Args "-oC:\opencv -y" -Wait
# 编译
cd CCPD_SPE_GEN\cpp_pipeline
.\build.ps1
```