ONNXRuntime部署YOLOV7目标检测

参考

源码 | OpenCV DNN + YOLOv7目标检测 - 腾讯云开发者社区-腾讯云https://cloud.tencent.com/developer/article/2052290

YOLOV7源码: https://github.com/WongKinYiu/yolov7
onnx文件:百度云盘链接: 百度网盘 请输入提取码 密码: 7mhs
使用OpenCV、ONNXRuntime部署YOLOV7目标检测,源码:https://github.com/hpc203/yolov7-opencv-onnxrun-cpp-py

配置
(1)配置onnxruntime 头文件和库,我这边直接把YOLOX.lite.ai.toolkit编译时用的 lite.ai.toolkit 直接拷贝了过来,放在yolov7-opencv-onnxrun-cpp-py/onnxruntime目录下;
(2)创建 CMakeLists.txt

cd yolov7-opencv-onnxrun-cpp-py/onnxruntime
mkdir CMakeLists.txt

CMakeLists.txt内容为:

cmake_minimum_required(VERSION 3.17)
project(yolox.lite.ai.toolkit)

set(CMAKE_CXX_STANDARD 11)

# setting up lite.ai.toolkit
set(LITE_AI_DIR ${CMAKE_SOURCE_DIR}/lite.ai.toolkit)
set(LITE_AI_INCLUDE_DIR ${LITE_AI_DIR}/include)
set(LITE_AI_LIBRARY_DIR ${LITE_AI_DIR}/lib)

include_directories(${LITE_AI_INCLUDE_DIR})
link_directories(${LITE_AI_LIBRARY_DIR})

set(OpenCV_LIBS
        opencv_highgui
        opencv_core
        opencv_imgcodecs
        opencv_imgproc
        opencv_video
        opencv_videoio
        )
# add your executable
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build)

add_executable(yolov7_test main.cpp)
target_link_libraries(yolov7_test
        # lite.ai.toolkit
        onnxruntime
        -lMNN  # need, if built lite.ai.toolkit with ENABLE_MNN=ON,  default OFF
        # ncnn # need, if built lite.ai.toolkit with ENABLE_NCNN=ON, default OFF
        # TNN  # need, if built lite.ai.toolkit with ENABLE_TNN=ON,  default OFF
        ${OpenCV_LIBS})  # link lite.ai.toolkit & other libs.

编译

mkdir build
cd build
cmake ..
make

报错:

ONNXRuntime部署YOLOV7目标检测_第1张图片


解决办法:如下,修改Session的第二个参数


测试

./yolov7_test

你可能感兴趣的:(目标检测,自动驾驶,目标检测,人工智能,计算机视觉)