# C++ 管线编译脚本 # 前置条件: Visual Studio 2022 + C++ workload + OpenCV # OpenCV 安装: 下载 https://opencv.org/releases/ 解压到 C:\opencv param( [string]$OpenCVDir = "C:\opencv\build" ) $ErrorActionPreference = "Stop" Write-Host "=== ICE C++ Plate Swap 编译 ===" -ForegroundColor Cyan # 检查 OpenCV if (-not (Test-Path "$OpenCVDir\OpenCVConfig.cmake")) { Write-Host "[ERROR] OpenCV 未找到: $OpenCVDir" -ForegroundColor Red Write-Host " 请从 https://opencv.org/releases/ 下载 Windows 版" Write-Host " 解压到 C:\opencv 或使用 -OpenCVDir 指定路径" exit 1 } # 创建 build 目录 $buildDir = "build" if (Test-Path $buildDir) { Remove-Item -Recurse -Force $buildDir } New-Item -ItemType Directory $buildDir | Out-Null # CMake 配置 (使用 VS 2022 生成器) Write-Host "CMake 配置..." cmake -B $buildDir -G "Visual Studio 17 2022" -A x64 ` -DOpenCV_DIR="$OpenCVDir" # 编译 Release Write-Host "编译 Release..." cmake --build $buildDir --config Release --parallel Write-Host "" Write-Host "=== 编译完成 ===" -ForegroundColor Green Write-Host "可执行文件: $buildDir\Release\plate_swap.exe" # 使用示例 Write-Host "" Write-Host "用法示例:" Write-Host " .\build\Release\plate_swap.exe --ccpd-dir ./CCPD/CCPD2019/ccpd_base --plate-type police --plate-pool ./output/plate_pool --num 500 --workers 32"