yolov5-lite-onnxruntime
yolov5-lite-onnxruntime copied to clipboard
c++版本要怎么运行呢
g++ main.cpp -o main
报错: main.cpp:7:10: fatal error: onnxruntime_cxx_api.h: No such file or directory #include <onnxruntime_cxx_api.h> ^~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
g++ main.cpp -o main
继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
g++ main.cpp -o main
继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
在linux系统和早windows系统,加载onnx文件的路径字符串表示方法,有些不一样的。你是在linux系统编译的,可以参考我的仓库里的这个文件 https://github.com/hpc203/photo2cartoon-onnxrun-cpp-py/blob/main/main.cpp
参考这一段的修改

g++ main.cpp -o main 继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
在linux系统和早windows系统,加载onnx文件的路径字符串表示方法,有些不一样的。你是在linux系统编译的,可以参考我的仓库里的这个文件 https://github.com/hpc203/photo2cartoon-onnxrun-cpp-py/blob/main/main.cpp 参考这一段的修改
谢谢回复,修改后然后运行还是报错
sudo g++ main.cpp -o main
/tmp/cc47TgBQ.o: In function YOLO::resize_image(cv::Mat, int*, int*, int*, int*)': main.cpp:(.text+0xb9f): undefined reference to cv::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Sizecv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xd56): undefined reference to cv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Sizecv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xed8): undefined reference to cv::resize(cv::InputArray const&, cv::OutputArray const&, cv::SizeYOLO::detect(cv::Mat&)': main.cpp:(.text+0x225f): undefined reference to cv::rectangle(cv::InputOutputArray const&, cv::Point
。。。
/tmp/cc47TgBQ.o: In function cv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)'
/tmp/cc47TgBQ.o: In function cv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to cv::Mat::deallocate()'
/tmp/cc47TgBQ.o: In function cv::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': main.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x69): undefined reference to cv::String::allocate(unsigned long)'
collect2: error: ld returned 1 exit status
g++ main.cpp -o main 继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
在linux系统和早windows系统,加载onnx文件的路径字符串表示方法,有些不一样的。你是在linux系统编译的,可以参考我的仓库里的这个文件 https://github.com/hpc203/photo2cartoon-onnxrun-cpp-py/blob/main/main.cpp 参考这一段的修改
谢谢回复,修改后然后运行还是报错
sudo g++ main.cpp -o main
/tmp/cc47TgBQ.o: In function YOLO::resize_image(cv::Mat, int*, int*, int*, int*)': main.cpp:(.text+0xb9f): undefined reference to cv::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Sizecv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xd56): undefined reference to cv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Sizecv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xed8): undefined reference to cv::resize(cv::InputArray const&, cv::OutputArray const&, cv::SizeYOLO::detect(cv::Mat&)': main.cpp:(.text+0x225f): undefined reference to cv::rectangle(cv::InputOutputArray const&, cv::Point
。。。
/tmp/cc47TgBQ.o: In function cv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)'
/tmp/cc47TgBQ.o: In function cv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to cv::Mat::deallocate()'
/tmp/cc47TgBQ.o: In function cv::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': main.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x69): undefined reference to cv::String::allocate(unsigned long)'
collect2: error: ld returned 1 exit status
g++ main.cpp -o main 继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
在linux系统和早windows系统,加载onnx文件的路径字符串表示方法,有些不一样的。你是在linux系统编译的,可以参考我的仓库里的这个文件 https://github.com/hpc203/photo2cartoon-onnxrun-cpp-py/blob/main/main.cpp 参考这一段的修改
谢谢回复,修改后然后运行还是报错
sudo g++ main.cpp -o main
/tmp/cc47TgBQ.o: In function
YOLO::resize_image(cv::Mat, int*, int*, int*, int*)': main.cpp:(.text+0xb9f): undefined reference tocv::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' main.cpp:(.text+0xc7a): undefined reference tocv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xd56): undefined reference tocv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' main.cpp:(.text+0xe32): undefined reference tocv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xed8): undefined reference tocv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' /tmp/cc47TgBQ.o: In functionYOLO::detect(cv::Mat&)': main.cpp:(.text+0x225f): undefined reference tocv::rectangle(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' main.cpp:(.text+0x22af): undefined reference to `cv::format(char const*, ...)'。。。
/tmp/cc47TgBQ.o: In function
cv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference tocv::fastFree(void*)' /tmp/cc47TgBQ.o: In functioncv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference tocv::Mat::deallocate()' /tmp/cc47TgBQ.o: In functioncv::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': main.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x69): undefined reference tocv::String::allocate(unsigned long)' collect2: error: ld returned 1 exit status
这个问题是编译的时候没有链接到opencv导致的。检查一下你的机器里是否安装了opencv,在编译的时候要链接到opencv
g++ main.cpp -o main 继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
在linux系统和早windows系统,加载onnx文件的路径字符串表示方法,有些不一样的。你是在linux系统编译的,可以参考我的仓库里的这个文件 https://github.com/hpc203/photo2cartoon-onnxrun-cpp-py/blob/main/main.cpp 参考这一段的修改
谢谢回复,修改后然后运行还是报错
sudo g++ main.cpp -o main
/tmp/cc47TgBQ.o: In function
YOLO::resize_image(cv::Mat, int*, int*, int*, int*)': main.cpp:(.text+0xb9f): undefined reference tocv::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' main.cpp:(.text+0xc7a): undefined reference tocv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xd56): undefined reference tocv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' main.cpp:(.text+0xe32): undefined reference tocv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xed8): undefined reference tocv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' /tmp/cc47TgBQ.o: In functionYOLO::detect(cv::Mat&)': main.cpp:(.text+0x225f): undefined reference tocv::rectangle(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' main.cpp:(.text+0x22af): undefined reference tocv::format(char const*, ...)' 。。。 /tmp/cc47TgBQ.o: In functioncv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference tocv::fastFree(void*)' /tmp/cc47TgBQ.o: In functioncv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference tocv::Mat::deallocate()' /tmp/cc47TgBQ.o: In functioncv::String::String(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)': main.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x69): undefined reference to `cv::String::allocate(unsigned long)' collect2: error: ld returned 1 exit status 这个问题是编译的时候没有链接到opencv导致的。检查一下你的机器里是否安装了opencv,在编译的时候要链接到opencv
谢谢回复,还是有报错
sudo g++ main.cpp -o main pkg-config --cflags --libs opencv
报错信息:
/tmp/ccWZpjko.o: In function __static_initialization_and_destruction_0(int, int)': main.cpp:(.text+0x4323): undefined reference to OrtGetApiBase'
collect2: error: ld returned 1 exit status
您的编译环境里没有配置onnxruntime
---原始邮件--- 发件人: @.> 发送时间: 2022年7月21日(周四) 下午3:13 收件人: @.>; 抄送: @.***>; 主题: [hpc203/yolov5-lite-onnxruntime] c++版本要怎么运行呢 (Issue #4)
g++ main.cpp -o main
报错: main.cpp:7:10: fatal error: onnxruntime_cxx_api.h: No such file or directory #include <onnxruntime_cxx_api.h> ^~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
g++ main.cpp -o main 继续报错: main.cpp: In constructor ‘YOLO::YOLO(Net_config)’: main.cpp:73:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’ ort_session = new Session(env, widestr.c_str(), sessionOptions); ^ In file included from /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650:0, from main.cpp:8: /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&) inline Session::Session(Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options) { ^~~~~~~ /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate expects 4 arguments, 3 provided /data/loong/onnxruntime/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:517:8: note: candidate: Ort::Session::Session(Ort::Env&, const char*, const Ort::SessionOptions&, OrtPrepackedWeightsContainer*) inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
在linux系统和早windows系统,加载onnx文件的路径字符串表示方法,有些不一样的。你是在linux系统编译的,可以参考我的仓库里的这个文件 https://github.com/hpc203/photo2cartoon-onnxrun-cpp-py/blob/main/main.cpp 参考这一段的修改
谢谢回复,修改后然后运行还是报错
sudo g++ main.cpp -o main
/tmp/cc47TgBQ.o: In function
YOLO::resize_image(cv::Mat, int*, int*, int*, int*)': main.cpp:(.text+0xb9f): undefined reference tocv::resize(cv::_InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' main.cpp:(.text+0xc7a): undefined reference tocv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xd56): undefined reference tocv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' main.cpp:(.text+0xe32): undefined reference tocv::copyMakeBorder(cv::_InputArray const&, cv::_OutputArray const&, int, int, int, int, int, cv::Scalar_<double> const&)' main.cpp:(.text+0xed8): undefined reference tocv::resize(cv::InputArray const&, cv::OutputArray const&, cv::Size,double, double, int)' /tmp/cc47TgBQ.o: In functionYOLO::detect(cv::Mat&)': main.cpp:(.text+0x225f): undefined reference tocv::rectangle(cv::InputOutputArray const&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' main.cpp:(.text+0x22af): undefined reference tocv::format(char const*, ...)' 。。。 /tmp/cc47TgBQ.o: In functioncv::Mat::~Mat()': main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference tocv::fastFree(void*)' /tmp/cc47TgBQ.o: In functioncv::Mat::release()': main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference tocv::Mat::deallocate()' /tmp/cc47TgBQ.o: In functioncv::String::String(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)': main.cpp:(.text._ZN2cv6StringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN2cv6StringC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x69): undefined reference to `cv::String::allocate(unsigned long)' collect2: error: ld returned 1 exit status这个问题是编译的时候没有链接到opencv导致的。检查一下你的机器里是否安装了opencv,在编译的时候要链接到opencv
谢谢回复,还是有报错
sudo g++ main.cpp -o main
pkg-config --cflags --libs opencv报错信息: /tmp/ccWZpjko.o: In function
__static_initialization_and_destruction_0(int, int)': main.cpp:(.text+0x4323): undefined reference toOrtGetApiBase' collect2: error: ld returned 1 exit status
其实可以尝试使用Cmake来进行构建 会方便很多 可以参考一下本小鸭的cmakelist文件
cmake_minimum_required(VERSION 3.10)
project(myyolov5)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(OpenCV_DIR /***/*****/****/opencv-4.5.2/build)
find_package(OpenCV REQUIRED) #找OpenCV 4.5安装路径
include_directories(${OpenCV_INCLUDE_DIRS}) #加载OpenCV 4.5的头文件
set(OnnxDIR /***/*****/****/onnxruntime-linux-x64-gpu-1.10.0)
include_directories(${OnnxDIR}/include)
link_directories(${OnnxDIR}/lib)
add_executable(yolov5 main.cpp)
target_link_libraries(yolov5 ${OpenCV_LIBS})
target_link_libraries(yolov5 ${OnnxDIR}/lib/libonnxruntime.so.1.10.0)
希望能解决你的问题 其中onnxruntime可以直接下载已经编译号的版本 opencv则需要你进行下载源码进行编译