Cpp OpenVino CMake
Python版本导引
CMake工程示例
测试性质的工程结构如下:
Project:
Network
: 存放网络推理相关- DebugTools: 打印网络结构
- DenseGradeWrapper: 推理主结构
- NetworkTools: 部分CV辅助函数
Script
: 存放前面博客中的导出以及验证Py文件CMakeLists.txt
: cmake工程文件main.cpp
: 简单的执行文件
CMake示例
OpenCV和OpenVINO的CMake引入都比较简单,本身框架也比较规范,在后面将会编写Tensorrt版本的博客,相对来说CMake就要复杂一点
CMake只要链接openvino::runtime
就可轻松包含OpenVINO的头文件和lib
相关位置,如果无法编译,请手动链接静态库版本
,这也是Windows的通病了,Linux下推荐链接动态库
如果不需要使用Qt的相关库,可以自行删除,个人使用OpenVINO主要集成于Qt,所以直接使用Qt的默认配置进行了添加修改
cmake_minimum_required(VERSION 3.14)
project(openvino-cpu-win-msvc2019 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# find openvino
set(OpenVINO_DIR "C:/Program Files (x86)/Intel/openvino_2024/runtime/cmake")
set(OpenCV_DIR "C:/Program Files/opencv460/build/x64/vc15/lib")
find_package(OpenCV)
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
# find qt core
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
add_executable(openvino-cpu-win-msvc2019
main.cpp
Network/DebugTools.h Network/DebugTools.cpp
Network/NetworkTools.h Network/NetworkTools.cpp
Network/DenseGradeWrapper.h Network/DenseGradeWrapper.cpp
)
target_include_directories(openvino-cpu-win-msvc2019
PRIVATE
${OpenCV_INCLUDE_DIRS}
.
)
target_link_libraries(openvino-cpu-win-msvc2019
Qt${QT_VERSION_MAJOR}::Core
openvino::runtime
${OpenCV_LIBS}
)
include(GNUInstallDirs)
install(TARGETS openvino-cpu-win-msvc2019
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
标签:openvino,set,CMake,Network,OpenVino,Cpp,CMAKE,DenseNet
From: https://blog.csdn.net/qq_34524246/article/details/140914663