Add WSL Windows cross build script
This commit is contained in:
20
readme.md
20
readme.md
@@ -87,6 +87,26 @@ windeployqt QtOpenCVImageTool.exe
|
||||
|
||||
然后把 OpenCV 的运行库 DLL 一并复制到 exe 所在目录,例如 `opencv_world*.dll` 或相关 `opencv_*.dll`。
|
||||
|
||||
## WSL 中交叉编译 Windows 程序
|
||||
|
||||
WSL 里不能使用 Linux 版 Qt/OpenCV 直接生成 Windows exe,必须准备 Windows 目标库。推荐使用 MinGW-w64 作为交叉编译器,并准备同为 MinGW-w64 目标的 Qt 和 OpenCV。
|
||||
|
||||
需要的组件:
|
||||
|
||||
- `x86_64-w64-mingw32-g++`
|
||||
- Windows/MinGW 目标 Qt,目录中应包含 `Qt6Config.cmake` 或 `Qt5Config.cmake`
|
||||
- Windows/MinGW 目标 OpenCV,目录中应包含 `OpenCVConfig.cmake`
|
||||
|
||||
构建脚本:
|
||||
|
||||
```bash
|
||||
export QT_MINGW_PREFIX=/opt/mxe/usr/x86_64-w64-mingw32.shared/qt6
|
||||
export OpenCV_DIR=/opt/mxe/usr/x86_64-w64-mingw32.shared/lib/cmake/opencv4
|
||||
./build_wsl_windows.sh
|
||||
```
|
||||
|
||||
如果使用的是自己编译或复制来的 Windows 目标 Qt/OpenCV,把上面两个路径换成实际路径即可。
|
||||
|
||||
## 说明
|
||||
|
||||
本示例中的分类属于简单规则分类,适合作为课程作业演示:根据图像整体亮度判断“偏亮/偏暗/亮度适中”,根据 BGR 平均值判断主色。若需要更高精度分类,可替换为训练好的 OpenCV DNN 或传统机器学习模型。
|
||||
|
||||
Reference in New Issue
Block a user