11cmake_minimum_required (VERSION 3.5)
2+ project (yolo_onnx_ros)
23
3- set ( PROJECT_NAME Yolov8OnnxRuntimeCPPInference )
4- project ( ${PROJECT_NAME} VERSION 0.0.1 LANGUAGES CXX )
4+ add_compile_options (-Wall -Werror= all )
5+ add_compile_options (-Wextra -Werror=extra )
56
67# -------------- Support C++17 for using filesystem ------------------#
78set (CMAKE_CXX_STANDARD 17)
89set (CMAKE_CXX_STANDARD_REQUIRED ON )
910set (CMAKE_CXX_EXTENSIONS ON )
10- set (CMAKE_INCLUDE_CURRENT_DIR ON )
11+ # set(CMAKE_INCLUDE_CURRENT_DIR ON)
1112
1213# -------------- OpenCV ------------------#
1314find_package (OpenCV REQUIRED)
1415include_directories (${OpenCV_INCLUDE_DIRS} )
1516
17+ find_package (catkin REQUIRED
18+ COMPONENTS
19+ onnxruntime_ros
20+ )
21+
22+
23+ # ------------------------------------------------------------------------------------------------
24+ # CATKIN EXPORT
25+ # ------------------------------------------------------------------------------------------------
26+
27+ catkin_package(
28+ INCLUDE_DIRS include
29+ LIBRARIES ${PROJECT_NAME}
30+ CATKIN_DEPENDS
31+ DEPENDS OpenCV
32+ )
33+
34+ # ------------------------------------------------------------------------------------------------
35+ # BUILD
36+ # ------------------------------------------------------------------------------------------------
37+
38+ include_directories (
39+ include
40+ SYSTEM
41+ ${OpenCV_INCLUDE_DIRS}
42+ ${catkin_INCLUDE_DIRS}
43+ )
44+
1645# -------------- ONNXRuntime ------------------#
17- set (ONNXRUNTIME_VERSION 1.21.0)
18- set (ONNXRUNTIME_ROOT "${CMAKE_CURRENT_SOURCE_DIR} /../onnxruntime-linux-x64-gpu-1.21.1" )
19- include_directories (${ONNXRUNTIME_ROOT} /include )
2046
2147# -------------- Cuda ------------------#
2248add_definitions (-DUSE_CUDA=1)
23- include_directories (/usr/local/cuda/include )
2449
25- set (PROJECT_SOURCES
26- src/main.cpp
27- src/yolo_inference.cpp
50+ add_library (${PROJECT_NAME}
51+ src/yolo_inference.cpp
2852)
53+ target_link_libraries (${PROJECT_NAME} ${OpenCV_LIBRARIES} ${catkin_LIBRARIES} )
2954
30- add_executable (${PROJECT_NAME} ${PROJECT_SOURCES} )
31- include_directories (${CMAKE_CURRENT_SOURCE_DIR} /inc)
32-
33- # Link OpenCV libraries along with ONNX Runtime
34- target_link_libraries (${PROJECT_NAME} ${OpenCV_LIBS} ${ONNXRUNTIME_ROOT} /lib/libonnxruntime.so)
55+ add_executable (test_${PROJECT_NAME}
56+ src/main.cpp
57+ )
58+ target_link_libraries (test_${PROJECT_NAME} ${PROJECT_NAME} ${OpenCV_LIBRARIES} ${catkin_LIBRARIES} )
3559
3660# For Windows system, copy onnxruntime.dll to the same folder of the executable file
3761if (WIN32 )
@@ -46,9 +70,9 @@ endif ()
4670configure_file (data/coco.yaml ${CMAKE_CURRENT_BINARY_DIR} /coco.yaml COPYONLY )
4771
4872# Copy yolov8n.onnx file to the same folder of the executable file
49- configure_file (model/yolo11m.onnx ${CMAKE_CURRENT_BINARY_DIR} /yolo11m.onnx COPYONLY )
73+ # configure_file(model/yolo11m.onnx ${CMAKE_CURRENT_BINARY_DIR}/yolo11m.onnx COPYONLY)
5074
51- # Create folder name images in the same folder of the executable file
52- add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
53- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} /images
54- )
75+ # # Create folder name images in the same folder of the executable file
76+ # add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
77+ # COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/images
78+ # )
0 commit comments