- 百度网盘链接 链接: https://pan.baidu.com/s/1x3SUV20z9mPBk_j4Bvj_lw 提取码: 1234
- 双击click_me_to_install.bat安装程序
- 双击click_me_to_run.bat运行程序
- 安装python
- 在Windows Command下安装miniconda
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe
.\miniconda.exe
del miniconda.exe
- 安装环境
- 在Anaconda Prompt下通过conda env安装环境
conda create -n angle-detector
conda activate angle-detector
conda install python=3.10.12
git clone https://github.com/johnson-magic/PrecisionAngleDetectionInference
cd PrecisionAngleDetectionInference
python -m pip install --upgrade pip
pip install -r requirements.txt
- 启动程序
python infer.py
-
安装依赖
- 安装依赖1 cmake version3.31.2
-
下载安装包cmake-3.31.2-windows-x86_64.msi至合适位置。
-
双击cmake-3.31.2-windows-x86_64.msi安装
-
安装依赖2 opencv version4.10.0
- 下载安装包opencv-4.10.0-windows.exe至合适位置。
- 双击opencv-4.10.0-windows.exe安装
-
安装依赖3:onnxruntime version 1.15.1
- 下载安装包onnxruntime-win-x64-1.15.1.zip至合适位置。
- 解压onnxruntime-win-x64-1.15.1.zip
-
运行程序
git clone --recursive https://github.com/johnson-magic/PrecisionAngleDetectionInference.git
cd PrecisionAngleDetectionInference/cpp
打开CMakeLists.txt文件,修改以下三行为对应的路径
include_directories("C:/Users/24601/Desktop/fabu/code/PrecisionAngleDetectionInference/cpp")
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} "C:/Users/24601/Desktop/fabu/software/onnxruntime-win-x64-1.15.1/onnxruntime-win-x64-1.15.1/lib/onnxruntime.lib")
include_directories("C:/Users/24601/Desktop/fabu/software/onnxruntime-win-x64-1.15.1/onnxruntime-win-x64-1.15.1/include")
继续执行如下命令
mkdir build
cmake -B ./build -DCMAKE_BUILD_TYPE=Release
cmake --build ./build/ --config Release
可执行文件,会生成于build\Release\ONNXInference.exe
执行
./ONNXInference.exe best.onnx A-2024-01-03-14-13-09_000032.jpg res.txt vis.png
- 结果展示 会生成两个结果
文本结果res.txt如下:
Centerpoint: 572.353,1074.48
angle: -0.740156
SliderAngle: -120.123
Diameter: 927.943
SliderCenterPoint: 397,1362.01
Position: below
可视化vis.png如下:
如果想测试程序运行的事件消耗,可以执行如下指令:
- c++ version
cmake -B ./build -DCMAKE_BUILD_TYPE=Release -DSPEED_TEST=ON
cmake --build ./build/ --config Release
- python version
# 打开infer.py文件中的speed_test为True
python infer.py
| 模块名称 | c++耗时(ms) | python耗时(ms) |
|---|---|---|
| 总 | 538 | 2023 |
| inferencer总 | 274 | 1316 |
| inferencer-preprocess | 63 | 略 |
| inferencer-inference | 198 | 略 |
| inferencer-postprocess | 13 | 略 |
| angle_detector-总 | 263 | 708 |
| angle_detector-process | 0 | 16 |
| angle_detector-saveres | 2 | 3 |
| angle_detector-savevis | 261 | 689 |
| 类别 | python测试结果 | c++测试结果 |
|---|---|---|
| big_circle | (91, 1551), (1025, 1552), (1027, 617), (92, 616) | (91, 1551), (1025, 1552), (1027, 617), (92, 616) |
| plates | (1038, 1207), (1039, 961), (101, 960), (101, 1205) | (1038, 1207), (1039, 961), (101, 960), (101, 1205) |
| slide | (600, 847), (753, 934), (862, 742), (709, 655) | (600, 847), (753, 934), (862, 742), (709, 655) |
