summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2021-08-03 08:04:30 +0000
committerGitHub <noreply@github.com>2021-08-03 08:04:30 +0000
commit6a5954197ef5671b5cc9159377e83ef15bf43373 (patch)
treec4ea500f2b42636464b844bd831b6382f931e0ba
parentfef1936f3c320ec026a0fdf65f103494385e15e3 (diff)
parent1e3d62e04f78e2d0e22b3ceb67aaf20a03f18bbc (diff)
Merge pull request #1306 from gdolle/tracker-neuralnet-cmake
Tracker neuralnet update onnxrt cmake (linux)
-rw-r--r--cmake/FindONNXRuntime.cmake42
-rw-r--r--tracker-neuralnet/CMakeLists.txt29
-rw-r--r--tracker-neuralnet/ftnoir_tracker_neuralnet.h2
3 files changed, 56 insertions, 17 deletions
diff --git a/cmake/FindONNXRuntime.cmake b/cmake/FindONNXRuntime.cmake
new file mode 100644
index 00000000..7350ec0d
--- /dev/null
+++ b/cmake/FindONNXRuntime.cmake
@@ -0,0 +1,42 @@
+# FindONNXRuntime
+# ===============
+#
+# Find an ONNX Runtime installation.
+# ONNX Runtime is a cross-platform inference and training machine-learning
+# accelerator.
+#
+# Input variables
+# ---------------
+#
+# ONNXRuntime_ROOT Set root installation.
+#
+# Output variable
+# ---------------
+#
+# ONNXRuntime_FOUND True if headers and requested libraries were found
+# ONNXRuntime_LIBRARIES Component libraries to be linked.
+# ONNXRuntime_INCLUDE_DIRS Include directories.
+
+find_library(ORT_LIB onnxruntime
+ CMAKE_FIND_ROOT_PATH_BOTH)
+
+find_path(ORT_INCLUDE onnxruntime_cxx_api.h
+ PATH_SUFFIXES onnxruntime/core/session
+ CMAKE_FIND_ROOT_PATH_BOTH)
+
+if(ORT_LIB AND ORT_INCLUDE)
+ set(ONNXRuntime_FOUND TRUE)
+ set(ONNXRuntime_INCLUDE_DIRS "${ORT_INCLUDE}")
+
+ if(NOT TARGET onnxruntime)
+ add_library(onnxruntime UNKNOWN IMPORTED)
+ set_target_properties(onnxruntime PROPERTIES
+ IMPORTED_LOCATION "${ORT_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${ORT_INCLUDE}"
+ INTERFACE_LINK_LIBRARIES "onnxruntime")
+ list(APPEND ONNXRuntime_LIBRARIES onnxruntime)
+ endif()
+endif()
+
+unset(ORT_LIB CACHE)
+unset(ORT_INCLUDE CACHE)
diff --git a/tracker-neuralnet/CMakeLists.txt b/tracker-neuralnet/CMakeLists.txt
index d06f0c83..bcdbbc81 100644
--- a/tracker-neuralnet/CMakeLists.txt
+++ b/tracker-neuralnet/CMakeLists.txt
@@ -1,23 +1,20 @@
include(opentrack-opencv)
-find_package(OpenCV QUIET)
+find_package(OpenCV QUIET COMPONENTS imgproc core imgcodecs calib3d)
find_package(OpenMP QUIET) # Used to control number of onnx threads.
-set(SDK_ONNX_LIBPATH "" CACHE FILEPATH "Full path of onnx library")
-
-if(OpenCV_FOUND AND SDK_ONNX_LIBPATH AND OpenMP_FOUND)
- get_filename_component(ONNX_INCLUDE_DIR "${SDK_ONNX_LIBPATH}" DIRECTORY)
- get_filename_component(ONNX_INCLUDE_DIR "${ONNX_INCLUDE_DIR}" ABSOLUTE)
- set(ONNX_INCLUDE_DIR "${ONNX_INCLUDE_DIR}/../include")
+find_package(ONNXRuntime QUIET)
+if(OpenCV_FOUND AND ONNXRuntime_FOUND AND OpenMP_FOUND)
otr_module(tracker-neuralnet)
- target_include_directories(${self} SYSTEM PUBLIC
- ${OpenCV_INCLUDE_DIRS} "${ONNX_INCLUDE_DIR}")
target_link_libraries(${self}
- opentrack-cv "${SDK_ONNX_LIBPATH}" opencv_imgproc opencv_core
- opencv_imgcodecs opencv_calib3d
- OpenMP::OpenMP_C)
-
+ opentrack-cv
+ onnxruntime
+ ${OpenCV_LIBS}
+ OpenMP::OpenMP_C
+ )
install(
- FILES "models/head-localizer.onnx" "models/head-pose.onnx"
+ FILES "models/head-localizer.onnx"
+ "models/head-pose.onnx"
DESTINATION "${opentrack-libexec}/models"
- PERMISSIONS ${opentrack-perms-file})
-endif() \ No newline at end of file
+ PERMISSIONS ${opentrack-perms-file}
+ )
+endif()
diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.h b/tracker-neuralnet/ftnoir_tracker_neuralnet.h
index b2eca6e3..7f496dc6 100644
--- a/tracker-neuralnet/ftnoir_tracker_neuralnet.h
+++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.h
@@ -230,4 +230,4 @@ class neuralnet_metadata : public Metadata
using neuralnet_tracker_ns::neuralnet_tracker;
using neuralnet_tracker_ns::neuralnet_dialog;
-using neuralnet_tracker_ns::neuralnet_metadata; \ No newline at end of file
+using neuralnet_tracker_ns::neuralnet_metadata;