# 雷达检测系统 - 快速Windows打包脚本 Write-Host "🚀 快速创建Windows软件包..." -ForegroundColor Green # 检查是否在正确的目录 if (!(Test-Path "CMakeLists.txt") -or !(Test-Path "src")) { Write-Host "❌ 请在项目根目录运行此脚本" -ForegroundColor Red exit 1 } # 创建简单的软件包 $PACKAGE_DIR = "yushu-radar-windows" if (Test-Path $PACKAGE_DIR) { Remove-Item -Recurse -Force $PACKAGE_DIR } New-Item -ItemType Directory -Path $PACKAGE_DIR | Out-Null Write-Host "🔨 检查编译程序..." -ForegroundColor Yellow # 检查编译结果 $buildPaths = @( "build\Release\yushu_leida_fixed.exe", "build\Debug\yushu_leida_fixed.exe", "cmake-build-debug\yushu_leida_fixed.exe", "cmake-build-release\yushu_leida_fixed.exe" ) $executablePath = $null foreach ($path in $buildPaths) { if (Test-Path $path) { $executablePath = $path break } } if (!$executablePath) { Write-Host "❌ 未找到编译好的程序文件" -ForegroundColor Red Write-Host "请先编译程序,可能的位置:" -ForegroundColor Yellow foreach ($path in $buildPaths) { Write-Host " - $path" -ForegroundColor Gray } exit 1 } Write-Host "✅ 找到程序文件: $executablePath" -ForegroundColor Green Write-Host "📦 打包文件..." -ForegroundColor Yellow # 复制主程序 Copy-Item $executablePath "$PACKAGE_DIR\yushu_leida_fixed.exe" # 复制配置文件 if (Test-Path "config") { Copy-Item -Recurse "config" "$PACKAGE_DIR\" } # 创建启动脚本 $startScript = @" @echo off chcp 65001 >nul echo 🚀 启动雷达检测系统... echo. REM 检查程序文件 if not exist "yushu_leida_fixed.exe" ( echo ❌ 找不到程序文件 yushu_leida_fixed.exe pause exit /b 1 ) echo 🎯 启动主程序... yushu_leida_fixed.exe pause "@ $startScript | Out-File -FilePath "$PACKAGE_DIR\start.bat" -Encoding UTF8 # 创建安装脚本 $installScript = @" @echo off chcp 65001 >nul echo 📦 安装雷达检测系统... echo. echo 🔍 检查系统环境... REM 检查Visual C++ Redistributable echo 检查 Visual C++ 运行库... where vcruntime140.dll >nul 2>&1 if errorlevel 1 ( echo ⚠️ 可能缺少 Visual C++ Redistributable echo 请从微软官网下载安装 Visual C++ Redistributable ) echo. set /p choice="是否创建桌面快捷方式?(Y/n): " if /i "%choice%" neq "n" ( echo 🔗 创建桌面快捷方式... call create_shortcuts.bat ) echo. echo 🎉 安装完成! echo. echo 📋 使用方法: echo 1. 双击 start.bat 启动程序 echo 2. 双击桌面快捷方式(如果已创建) echo 3. 直接运行 yushu_leida_fixed.exe echo. pause "@ $installScript | Out-File -FilePath "$PACKAGE_DIR\install.bat" -Encoding UTF8 # 创建快捷方式创建脚本 $shortcutScript = @" @echo off chcp 65001 >nul echo 🔗 创建雷达检测系统快捷方式... set "INSTALL_DIR=%~dp0" set "DESKTOP=%USERPROFILE%\Desktop" echo 📁 安装目录: %INSTALL_DIR% REM 创建桌面快捷方式 echo 🖥️ 创建桌面快捷方式... powershell -Command "& {` `$WshShell = New-Object -comObject WScript.Shell; ` `$Shortcut = `$WshShell.CreateShortcut('%DESKTOP%\雷达检测系统.lnk'); ` `$Shortcut.TargetPath = '%INSTALL_DIR%start.bat'; ` `$Shortcut.WorkingDirectory = '%INSTALL_DIR%'; ` `$Shortcut.Description = '雷达检测系统'; ` `$Shortcut.Save() ` }" if exist "%DESKTOP%\雷达检测系统.lnk" ( echo ✅ 桌面快捷方式已创建: %DESKTOP%\雷达检测系统.lnk ) else ( echo ❌ 桌面快捷方式创建失败 ) echo. echo 🎉 快捷方式创建完成! echo. echo 📋 使用方法: echo 1. 双击桌面 "雷达检测系统" 图标 echo 2. 双击 start.bat echo 3. 直接运行 yushu_leida_fixed.exe echo. pause "@ $shortcutScript | Out-File -FilePath "$PACKAGE_DIR\create_shortcuts.bat" -Encoding UTF8 # 创建使用说明 $readme = @" 雷达检测系统 - Windows版本 📋 功能特点: - 实时3D点云显示 - 坐标轴和网格显示 - 遮挡物检测 (20厘米预警) - 裂缝检测 (100米阈值) - 声音预警系统 📦 使用方法: 1. 运行安装脚本: 双击 install.bat 2. 启动程序: 双击 start.bat 或桌面快捷方式 3. 如果遇到问题: - 确保雷达设备已正确连接 - 检查串口设备(通常是COM端口) - 确保安装了Visual C++ Redistributable 🔗 快捷方式: 安装后可通过以下方式启动: - 桌面快捷方式: 双击"雷达检测系统"图标 - 手动创建快捷方式: 双击 create_shortcuts.bat 📁 文件说明: - yushu_leida_fixed.exe: 主程序 - config/: 配置文件目录 - start.bat: 启动脚本 - install.bat: 安装脚本 - create_shortcuts.bat: 快捷方式创建脚本 🔧 配置文件: 主要配置在 config/config.yaml 中: - port: 串口设备路径 (Windows下通常是COM1, COM2等) - occlusion_detection.alert_distance: 遮挡物预警距离 (默认 0.20m) - slope_detection.crack_threshold: 裂缝检测阈值 (默认 100.0m) ❓ 故障排除: 1. 找不到设备:检查雷达连接,查看设备管理器中的COM端口 2. 程序无法启动:确保安装了Visual C++ Redistributable 3. 缺少DLL:可能需要安装相关的运行库 4. 权限问题:以管理员身份运行 系统要求: - Windows 10/11 (64位) - Visual C++ Redistributable 2019或更新版本 - 至少4GB内存 - 支持OpenGL的显卡 版本:1.0.0 "@ $readme | Out-File -FilePath "$PACKAGE_DIR\README.txt" -Encoding UTF8 # 创建压缩包 Write-Host "🗜️ 创建压缩包..." -ForegroundColor Yellow if (Get-Command Compress-Archive -ErrorAction SilentlyContinue) { Compress-Archive -Path $PACKAGE_DIR -DestinationPath "yushu-radar-windows.zip" -Force Write-Host "✅ 压缩包创建成功: yushu-radar-windows.zip" -ForegroundColor Green } else { Write-Host "⚠️ PowerShell版本较旧,无法自动创建压缩包" -ForegroundColor Yellow Write-Host "请手动将 $PACKAGE_DIR 文件夹压缩为zip文件" -ForegroundColor Yellow } Write-Host "" Write-Host "🎉 Windows软件包创建完成!" -ForegroundColor Green Write-Host "" Write-Host "📁 软件包目录: $PACKAGE_DIR\" -ForegroundColor Cyan Write-Host "📦 压缩包: yushu-radar-windows.zip" -ForegroundColor Cyan Write-Host "" Write-Host "🔗 新增功能:" -ForegroundColor Yellow Write-Host "✅ Windows批处理脚本" -ForegroundColor Green Write-Host "✅ 桌面快捷方式支持" -ForegroundColor Green Write-Host "✅ 自动环境检查" -ForegroundColor Green Write-Host "✅ 中文界面支持" -ForegroundColor Green Write-Host "" Write-Host "📋 分发方法:" -ForegroundColor Yellow Write-Host "1. 直接使用目录: 进入 $PACKAGE_DIR 运行 install.bat" -ForegroundColor White Write-Host "2. 分发压缩包: 解压后运行 install.bat" -ForegroundColor White Write-Host "" Write-Host "✅ 用户只需要:" -ForegroundColor Yellow Write-Host " 1. 解压 yushu-radar-windows.zip" -ForegroundColor White Write-Host " 2. 进入 yushu-radar-windows 文件夹" -ForegroundColor White Write-Host " 3. 双击 install.bat" -ForegroundColor White Write-Host " 4. 双击 start.bat 或桌面快捷方式启动程序" -ForegroundColor White Write-Host ""