Skip to content

Repository files navigation

PrecisionAngleDetectionInference

以可执行文件的方式运行

以python的方式运行

方式1: 傻瓜式安装、运行

  • 双击click_me_to_install.bat安装程序
  • 双击click_me_to_run.bat运行程序

方式2: 通过指令安装、运行

  1. 安装python
  • 在Windows Command下安装miniconda
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe
.\miniconda.exe
del miniconda.exe
  1. 安装环境
  • 在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
  1. 启动程序
python infer.py

以c++的方式运行

  • 安装依赖

    • 安装依赖1 cmake version3.31.2
    1. 下载安装包cmake-3.31.2-windows-x86_64.msi至合适位置。

    2. 双击cmake-3.31.2-windows-x86_64.msi安装

  • 安装依赖2 opencv version4.10.0

    1. 下载安装包opencv-4.10.0-windows.exe至合适位置。
    2. 双击opencv-4.10.0-windows.exe安装
  • 安装依赖3:onnxruntime version 1.15.1

    1. 下载安装包onnxruntime-win-x64-1.15.1.zip至合适位置。
    2. 解压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)
5382023
inferencer总2741316
inferencer-preprocess63
inferencer-inference198
inferencer-postprocess13
angle_detector-总263708
angle_detector-process016
angle_detector-saveres23
angle_detector-savevis261689

一致性测试

类别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)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages