Skip to content

Commit b5b5ec1

Browse files
committed
WIP: not compiling yet because of dependency
1 parent 918db59 commit b5b5ec1

File tree

5 files changed

+77
-24
lines changed

5 files changed

+77
-24
lines changed

CMakeLists.txt

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,61 @@
11
cmake_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 ------------------#
78
set(CMAKE_CXX_STANDARD 17)
89
set(CMAKE_CXX_STANDARD_REQUIRED ON)
910
set(CMAKE_CXX_EXTENSIONS ON)
10-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
11+
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
1112

1213
# -------------- OpenCV ------------------#
1314
find_package(OpenCV REQUIRED)
1415
include_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 ------------------#
2248
add_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
3761
if (WIN32)
@@ -46,9 +70,9 @@ endif ()
4670
configure_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+
# )
File renamed without changes.

package.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<?xml-model
3+
href="http://download.ros.org/schema/package_format3.xsd"
4+
schematypens="http://www.w3.org/2001/XMLSchema"?>
5+
<package format="3">
6+
<name>yolo_onnx_ros</name>
7+
<version>0.0.0</version>
8+
<description>Yolo inference</description>
9+
10+
<maintainer email="[email protected]">Iason Theodorou</maintainer>
11+
12+
<license>ToDo</license>
13+
14+
<buildtool_depend>catkin</buildtool_depend>
15+
16+
<build_depend>libopencv-dev</build_depend>
17+
<exec_depend>libopencv-dev</exec_depend>
18+
<build_depend>onnxruntime_ros</build_depend>
19+
<exec_depend>onnxruntime_ros</exec_depend>
20+
21+
<test_depend>catkin_lint_cmake</test_depend>
22+
23+
<doc_depend>doxygen</doc_depend>
24+
25+
<export>
26+
<rosdoc config="rosdoc.yaml" />
27+
</export>
28+
29+
</package>

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <iostream>
22
#include <iomanip>
3-
#include "yolo_inference.h"
3+
#include "yolo_onnx_ros/yolo_inference.h"
44
#include <filesystem>
55
#include <fstream>
66
#include <random>
@@ -192,4 +192,4 @@ int main()
192192
{
193193
DetectTest();
194194
//ClsTest();
195-
}
195+
}

src/yolo_inference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "yolo_inference.h"
1+
#include "yolo_onnx_ros/yolo_inference.h"
22
#include <regex>
33

44
#define benchmark
@@ -383,4 +383,4 @@ char* YOLO_V8::WarmUpSession() {
383383
#endif
384384
}
385385
return RET_OK;
386-
}
386+
}

0 commit comments

Comments
 (0)