summaryrefslogtreecommitdiffhomepage
path: root/cv
diff options
context:
space:
mode:
Diffstat (limited to 'cv')
-rw-r--r--cv/CMakeLists.txt9
-rw-r--r--cv/init.cpp23
-rw-r--r--cv/init.hpp2
-rw-r--r--cv/ocv-check.cxx7
4 files changed, 41 insertions, 0 deletions
diff --git a/cv/CMakeLists.txt b/cv/CMakeLists.txt
index 12935f1b..6c693acb 100644
--- a/cv/CMakeLists.txt
+++ b/cv/CMakeLists.txt
@@ -1,7 +1,16 @@
include(opentrack-opencv)
find_package(OpenCV QUIET)
if(OpenCV_FOUND)
+ try_compile(cv_use-ipp "${CMAKE_CURRENT_BINARY_DIR}"
+ SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ocv-check.cxx"
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${OpenCV_INCLUDE_DIRS}"
+ "-DCXX_STANDARD=17" "-DCXX_STANDARD_REQUIRED=1"
+ COMPILE_DEFINITIONS "-D_HAS_EXCEPTIONS=0"
+ OUTPUT_VARIABLE krap)
otr_module(cv STATIC)
target_link_libraries(${self} opencv_videoio opencv_core opentrack-video)
target_include_directories(${self} SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS})
+ if(cv_use-ipp)
+ target_compile_definitions(${self} PUBLIC -DOTR_HAS_CV_IPP)
+ endif()
endif()
diff --git a/cv/init.cpp b/cv/init.cpp
new file mode 100644
index 00000000..c9c4650f
--- /dev/null
+++ b/cv/init.cpp
@@ -0,0 +1,23 @@
+#include "init.hpp"
+#include <type_traits>
+#include <opencv2/core.hpp>
+
+[[noreturn]]
+static
+int error_handler(int, const char* fn, const char* msg, const char* filename, int line, void*)
+{
+ fprintf(stderr, "[%s:%d] opencv: %s at %s\n", filename, line, msg, fn);
+ fflush(stderr);
+ std::abort();
+}
+
+void opencv_init()
+{
+ cv::redirectError(error_handler);
+ cv::setBreakOnError(false);
+ cv::setNumThreads(1);
+#ifdef OTR_HAS_CV_IPP
+ cv::ipp::setUseIPP(true);
+ cv::ipp::setUseIPP_NotExact(true);
+#endif
+}
diff --git a/cv/init.hpp b/cv/init.hpp
new file mode 100644
index 00000000..4c529549
--- /dev/null
+++ b/cv/init.hpp
@@ -0,0 +1,2 @@
+#pragma once
+void opencv_init();
diff --git a/cv/ocv-check.cxx b/cv/ocv-check.cxx
new file mode 100644
index 00000000..9efe3610
--- /dev/null
+++ b/cv/ocv-check.cxx
@@ -0,0 +1,7 @@
+#include <opencv2/core.hpp>
+
+void check1()
+{
+ cv::ipp::setUseIPP(true);
+ cv::ipp::setUseIPP_NotExact(true);
+}