From c47a5d6423068d3fab57483177ee59cbcabe6451 Mon Sep 17 00:00:00 2001
From: Moritz Maxeiner <mm@ucw.sh>
Date: Wed, 14 Aug 2019 14:04:19 +0200
Subject: [PATCH] OpenCV 4 compatibility

---
 CMakeLists.txt                               | 5 +++++
 Src/CMakeLists.txt                           | 1 -
 Src/Interfaces/IModel/IModelAreaDescriptor.h | 2 +-
 cmake/biotracker-interfacesConfig.cmake.in   | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b63f7ec..9f28805 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,11 @@ set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} CACHE STRING
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
 include(Headers)
 
+find_package(OpenCV 4 QUIET)
+if(NOT OpenCV_FOUND)
+    find_package(OpenCV 3 REQUIRED)
+endif()
+
 add_subdirectory(Src)
 
 export(
diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt
index 53a7651..6580775 100644
--- a/Src/CMakeLists.txt
+++ b/Src/CMakeLists.txt
@@ -26,7 +26,6 @@ target_include_directories(${target} PUBLIC
 find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
 target_link_libraries(${target}  Qt5::Core Qt5::Gui Qt5::Widgets)
 
-find_package(OpenCV 3 REQUIRED)
 target_link_libraries(${target} ${OpenCV_LIBS})
 
 set_target_properties(${target} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON)
diff --git a/Src/Interfaces/IModel/IModelAreaDescriptor.h b/Src/Interfaces/IModel/IModelAreaDescriptor.h
index 011668f..5124f90 100644
--- a/Src/Interfaces/IModel/IModelAreaDescriptor.h
+++ b/Src/Interfaces/IModel/IModelAreaDescriptor.h
@@ -2,7 +2,7 @@
 
 #include "IModel.h"
 #include <string.h>
-#include <cv.h>
+#include <opencv2/opencv.hpp>
 
 class BT_INTERFACES_API IModelAreaDescriptor :public IModel
 {
diff --git a/cmake/biotracker-interfacesConfig.cmake.in b/cmake/biotracker-interfacesConfig.cmake.in
index d064abd..6e710da 100644
--- a/cmake/biotracker-interfacesConfig.cmake.in
+++ b/cmake/biotracker-interfacesConfig.cmake.in
@@ -2,7 +2,7 @@
 
 find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
 
-find_package(OpenCV 3 REQUIRED)
+find_package(OpenCV @OpenCV_VERSION_MAJOR@ REQUIRED)
 
 include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
 
-- 
GitLab