项目场景:
部署车道线检测算法——LSTR-lane-detect-onnxruntime出现的一个小问题!!
LSTR-lane-detect-onnxrun-cpp-py-main/main.cpp:48:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’
问题描述
make出现了问题:
(base) l@l:~/LSTR-lane-detect-onnxrun-cpp-py-main/build$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ls/LSTR-lane-detect-onnxrun-cpp-py-main/build
[ 50%] Building CXX object CMakeFiles/LSTRLane.dir/main.cpp.o
/home/l/LSTR-lane-detect-onnxrun-cpp-py-main/main.cpp: In constructor ‘LSTR::LSTR()’:
/home/l/LSTR-lane-detect-onnxrun-cpp-py-main/main.cpp:48:64: error: no matching function for call to ‘Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)’
48 | ort_session = new Session(env, widestr.c_str(), sessionOptions);
| ^
In file included from /usr/local/include/onnxruntime/core/session/onnxruntime_cxx_api.h:650,
from /home/ls/LSTR-lane-detect-onnxrun-cpp-py-main/main.cpp:8:
/usr/local/include/onnxruntime/core/session/onnxruntime_cxx_inline.h:522:8: note: candidate: ‘Ort::Session::Session(Ort::Env&, const void*, size_t, const Ort::SessionOptions&)’
。。。。。。
onnxruntime的版本问题:
我用的是1.8.0版本的 onnruntime:
Ort::Session::Session(Ort::Env&, const wchar_t*, Ort::SessionOptions&)
需要对代码中的部分函数进行修改~
解决方案:
原始代码:
LSTR::LSTR()
{
string model_path = "/home/l/LSTR-lane-detect-onnxrun-cpp-py-main/lstr_360x640.onnx";
std::wstring widestr = std::wstring(model_path.begin(), model_path.end());
sessionOptions.SetGraphOptimizationLevel(ORT_ENABLE_BASIC);
ort_session = new Session(env, model_path.c_str(), sessionOptions);
size_t numInputNodes = ort_session->GetInputCount();
size_t numOutputNodes = ort_session->GetOutputCount();
。。。。。
后面进行修改:
LSTR::LSTR()
{
string model_path = "/home/l/LSTR-lane-detect-onnxrun-cpp-py-main/lstr_360x640.onnx";
sessionOptions.SetGraphOptimizationLevel(ORT_ENABLE_BASIC);
ort_session = new Session(env, model_path.c_str(), sessionOptions);
size_t numInputNodes = ort_session->GetInputCount();
size_t numOutputNodes = ort_session->GetOutputCount();
欧克欧克,就这样解决了问题了!!!!