Giter VIP home page Giter VIP logo

Comments (4)

gyy0592 avatar gyy0592 commented on May 13, 2024 1

最后错误得以解决,是把所有文件都丢到根目录运行去找bug,然后发现是
ort_handler.cpp里面
#ifdef LITEHUB_WIN32
#include "ort_utils.h"
#endif
出现问题
手动引入ort_utils.h后解决

以及 onnx_path = _onnx_path.data();的类型错误
改为 onnx_path = (const wchar_t*)_onnx_path.data();成功解决 可能是编译器的问题(vs2019)

不太理解为什么, 是小白,不过还是把这个po出来把,最后非常感谢大佬

from lite.ai.toolkit.

DefTruth avatar DefTruth commented on May 13, 2024

这个是典型的链接错误,编译出来的example在运行时需要找到对应的动态库。我不太好定位你的问题出在哪里。我是用Mac+CLion+CMake开发的,编译器是clang。你可以尝试下Windows+CLion+CMake+MSVC来编译。 你可以看一下这个关于windows下跑lite.ai的讨论 #6

from lite.ai.toolkit.

DefTruth avatar DefTruth commented on May 13, 2024

关于如何链接编好的lite.ai动态库,CMakeLists的设置可以参考下:

cmake_minimum_required(VERSION 3.17)
project(lite.ai-release)

message(">>>> Current project is: ${CMAKE_SOURCE_DIR}")

set(CMAKE_CXX_STANDARD 11)

# link opencv.
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv/lib/cmake/opencv4)
find_package(OpenCV 4 REQUIRED)
if (OpenCV_FOUND)
    include_directories(${OpenCV_INCLUDE_DIRS})
    set(OpenCV_LIBS opencv_highgui opencv_core opencv_imgcodecs opencv_imgproc) # need only
    message("=================================================================================")
    message(STATUS "    OpenCV library status:")
    message(STATUS "    version: ${OpenCV_VERSION}")
    message(STATUS "    libraries: ${OpenCV_LIBS}")
    message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
    message("=================================================================================")
else ()
    message(FATAL_ERROR "OpenCV library not found")
endif()

# link onnxruntime.
set(ONNXRUNTIME_DIR ${CMAKE_SOURCE_DIR}/onnxruntime/)
set(ONNXRUNTIME_INCLUDE_DIR ${ONNXRUNTIME_DIR}/include)
set(ONNXRUNTIME_LIBRARY_DIR ${ONNXRUNTIME_DIR}/lib)
include_directories(${ONNXRUNTIME_INCLUDE_DIR})
link_directories(${ONNXRUNTIME_LIBRARY_DIR})

# link lite.ai.
set(LITEHUB_DIR ${CMAKE_SOURCE_DIR}/lite.ai)
set(LITEHUB_INCLUDE_DIR ${LITEHUB_DIR}/include)
set(LITEHUB_LIBRARY_DIR ${LITEHUB_DIR}/lib)
include_directories(${LITEHUB_INCLUDE_DIR})
link_directories(${LITEHUB_LIBRARY_DIR})

# add your executable
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/examples/build)

add_executable(lite_yolov5 examples/test_lite_yolov5.cpp)
target_link_libraries(lite_yolov5 lite.ai onnxruntime ${OpenCV_LIBS})  # link lite.ai

对应的动态库目录需要修成你自己的。一个在mac上的参考案例 lite.ai-release

from lite.ai.toolkit.

DefTruth avatar DefTruth commented on May 13, 2024

最后错误得以解决,是把所有文件都丢到根目录运行去找bug,然后发现是
ort_handler.cpp里面
#ifdef LITEHUB_WIN32
#include "ort_utils.h"
#endif
出现问题
手动引入ort_utils.h后解决

以及 onnx_path = _onnx_path.data();的类型错误
改为 onnx_path = (const wchar_t*)_onnx_path.data();成功解决 可能是编译器的问题(vs2019)

不太理解为什么, 是小白,不过还是把这个po出来把,最后非常感谢大佬

赞👍🏻 ~, onnxruntime在windows下是用的宽字符,代码了应该已经处理,至于为什么还出现这个bug,emmmm......我也很迷 🤔

#ifdef LITE_WIN32
  std::wstring _w_onnx_path(ortcv::utils::to_wstring(_onnx_path));
  onnx_path = _w_onnx_path.data();
#else
  onnx_path = _onnx_path.data();
#endif
  initialize_handler();

在lite.ai.defs.h里边有做这个宏判断,你可以查下有没有生效。

#if (defined _WIN32 || defined WINCE || defined __CYGWIN__)
#  define LITE_WIN32
#elif defined __GNUC__ && __GNUC__ >= 4 && (defined(__APPLE__))
# define LITE_UNIX
#endif

你试下用最新的代码,旧版本的一些问题已经修复了。
补充下,确实有处宏判断写错了。在ort_handler.cpp原来的代码:

#ifdef LITEHUB_WIN32
#include "ort_utils.h"
#endif

需要修改成

#ifdef LITE_WIN32
#include "ort_utils.h"
#endif

from lite.ai.toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.