yolov9 导出onnx 模型,C++ 使用opencv dnn 预测
请自行编译
git clone https://github.com/WeiZhenOoooo/yolov9-onnx-opencv.git
cd yolov9-onnx-opencv
修改CMakeLists.txt,line 6 和 line 7
set(OpenCV_DIR "D:/CredLib_DIR/opencv47/build")
set(Yaml_Cpp_DIR "D:/CredLib_DIR/yaml-cpp")
将OpenCV_DIR和Yaml_Cpp_DIR的路径修改为本机的实际路径,CMake编译
将yaml-cpp.dll复制到可执行文件yolo-onnx-opencv.exe的所在目录,准备执行
E:\code\yolov9-onnx-opencv\cmake-build-release>.\yolo-onnx-opencv.exe -h
yolo onnx opencv dnn pred description
Usage: .\yolo-onnx-opencv.exe [OPTIONS]
Options:
-h,--help Print this help message and exit
-w,--weights TEXT onnx model path
-c,--config TEXT train yolo yaml path, to find classes definition
-i,--input TEXT pred input path
-z,--size INT input size(size * size), default:640 * 640
-t,--threshold FLOAT threshold score, default: 0.5
--image,--no-image{false} Image inference mode
--video,--no-video{false} Video inference mode
--gpu,--no-gpu{false} Cuda inference mode
如果要使用--gpu
参数,请自行编译opencv GPU版本
.\yolo-onnx-opencv.exe --weights ..\weights\yolov9-c.onnx -c ..\example\metadata.yaml -i ..\example\000000000625.jpg --image
.\yolo-onnx-opencv.exe --weights ..\weights\yolov9-c.onnx -c ..\example\metadata.yaml -i ..\example\road.mp4 --video
- YOLOv9 : https://github.com/WongKinYiu/yolov9