本文主要是介绍Windows下 CLion中,配置 OpenVINO,运行Yolov8,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
之前我们完成了Windows下 CLion中,配置 OpenCV、LibTorch,下面我们来装OpenVINO
OpenVINO下载与安装
下载并解压OpenVINO Archives
(当前测试了2024.1版本),记住路径,我的是:C:\Libraries\Intel\openvino_2024.1.0
然后下载yolov8_od_ov_infer.cpp 源码(感谢开源!)
自己编写个简单的CMakeList.txt就可以跑啦!
但接下来又会出现类似如下问题:
tbb12_debug.dll not found
这是因为OpenVINO Archives并不提供TBB的编译库。还要另外安装:
参考Intel TBB库+VS2019+WIN10配置 下载已经编译好的TBB库,我解压后的路径是:C:/Libraries/Intel/oneapi-tbb-2021.12.0
安装好后只需在CMakeList.txt中添加一句即可:
file(GLOB TBB_DLLs "C:/Libraries/Intel/oneapi-tbb-2021.12.0/redist/intel64/vc14/*.dll") # OpenVINO依赖TBB
add_custom_command(TARGET yolov8_od_ov_inferPOST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_if_different${TBB_DLLs}$<TARGET_FILE_DIR:yolov8_od_ov_infer>)
完整CMakeList.txt示例
cmake_minimum_required(VERSION 3.12)
project(yolov8_openvino_cpp_main)set(CMAKE_CXX_STANDARD 14)set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3")set(OpenCV_DIR C:/Libraries/opencv-4.8.1/build/install/lib) # 这里要精确到lib!
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV status:" ${OpenCV_FOUND})
message(STATUS "OpenCV Libs:" ${OpenCV_LIBS})
message(STATUS "OpenCV Include Dirs:" ${OpenCV_INCLUDE_DIRS})#list(APPEND CMAKE_PREFIX_PATH C:\\Libraries\\Intel\\openvino_2024.1.0\\runtime)
find_package(OpenVINO REQUIRED)
message(STATUS "OpenVINO Found: ${OpenVINO_FOUND}")
message(STATUS "OpenVINO Inference Engine Found in: ${OpenVINO_DIR}")
set(OpenVINO_INCLUDE_DIRS ${OpenVINO_DIR}/../include)if (CMAKE_BUILD_TYPE STREQUAL "Release")file(GLOB OpenVINO_LIBRARIES "${OpenVINO_DIR}/../lib/intel64/Release/*.lib")
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")file(GLOB OpenVINO_LIBRARIES "${OpenVINO_DIR}/../lib/intel64/Debug/*.lib")
endif()include_directories(${OpenCV_INCLUDE_DIRS}${OpenVINO_INCLUDE_DIRS}
)message(STATUS "OpenVINO Version: ${OpenVINO_VERSION}")
message(STATUS "OpenVINO LIBRARIES: ${OpenVINO_LIBRARIES}")
message(STATUS "OpenVINO INCLUDE_DIRS: ${OpenVINO_INCLUDE_DIRS}")add_executable(yolov8_od_ov_infer yolov8_od_ov_infer.cpp)
target_link_libraries(yolov8_od_ov_infer${OpenCV_LIBS}${OpenVINO_LIBRARIES}
)add_executable(yolov8_ov_infer_hand yolov8_ov_infer_hand.cpp)
target_link_libraries(yolov8_ov_infer_hand${OpenCV_LIBS}${OpenVINO_LIBRARIES}
)if (MSVC)
# file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")file(GLOB OpenCV_DLLS "${OpenCV_DIR}/../bin/*.dll")
# file(GLOB OpenCV_DLLS "C:/Libraries/opencv-4.8.1/build_release/install/bin/*.dll")
# file(GLOB OpenVINO_DLLS "${OpenVINO_DIR}/../bin/intel64/*/*.dll")if (CMAKE_BUILD_TYPE STREQUAL "Release")file(GLOB OpenVINO_DLLS "${OpenVINO_DIR}/../bin/intel64/Release/*.dll")elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")file(GLOB OpenVINO_DLLS "${OpenVINO_DIR}/../bin/intel64/Debug/*.dll")endif()message(STATUS "OpenVINO DLLS: ${OpenVINO_DLLS}")file(GLOB TBB_DLLs "C:/Libraries/Intel/oneapi-tbb-2021.12.0/redist/intel64/vc14/*.dll") # OpenVINO依赖TBBadd_custom_command(TARGET yolov8_od_ov_inferPOST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_if_different
# ${TORCH_DLLS}${OpenCV_DLLS}${OpenVINO_DLLS}${TBB_DLLs}$<TARGET_FILE_DIR:yolov8_od_ov_infer>)add_custom_command(TARGET yolov8_ov_infer_handPOST_BUILDCOMMAND ${CMAKE_COMMAND} -E copy_if_different${OpenCV_DLLS}${OpenVINO_DLLS}${TBB_DLLs}$<TARGET_FILE_DIR:yolov8_ov_infer_hand>)
endif (MSVC)
这篇关于Windows下 CLion中,配置 OpenVINO,运行Yolov8的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!