From 1e142f67b40ab00781525c914659155c0c742c46 Mon Sep 17 00:00:00 2001
From: Mederic Fourmy <mederic.fourmy@gmail.com>
Date: Tue, 3 May 2022 19:24:06 +0200
Subject: [PATCH] Fix: Link with OpenCV using COMPONENTS

---
 CMakeLists.txt                          | 29 +++++++++++++++++++++----
 include/vision/factor/factor_pixel_hp.h |  6 -----
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 86e5e79bf..d0982431a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,8 +83,10 @@ option(_WOLF_TRACE "Enable wolf tracing macro" ON)
 
 # ============ DEPENDENCIES ==================
 FIND_PACKAGE(wolfcore REQUIRED)
-SET(PRINT_INFO_VU false)
-FIND_PACKAGE(OpenCV REQUIRED)
+FIND_PACKAGE(OpenCV REQUIRED 
+  COMPONENTS core imgcodecs highgui features2d calib3d video
+)
+
 
 # ============ config.h ==================
 string(TOUPPER ${PROJECT_NAME} UPPER_NAME)
@@ -184,10 +186,29 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
   # using GCC
 endif()
 
-#Link the created libraries
+# Link the created libraries
 #===============EXAMPLE=========================
 TARGET_LINK_LIBRARIES(${PLUGIN_NAME} wolfcore)
-TARGET_LINK_LIBRARIES(${PLUGIN_NAME} OpenCV)
+# For OpenCV, link with respect to each required components, found in the find_package command
+# The required components have the same name as the include files e.g. <opencv2/core.hpp>
+# or the opencv2 subdirectory in which they are found, e.g. <opencv2/video/tracking.hpp>
+TARGET_LINK_LIBRARIES(${PLUGIN_NAME} 
+  opencv_core
+  opencv_imgcodecs
+  opencv_highgui
+  opencv_features2d
+  opencv_calib3d
+  opencv_video
+)
+
+
+# # TARGET_LINK_LIBRARIES(${PLUGIN_NAME} opencv)
+# get_target_property(toto wolfcore INCLUDE_DIRECTORIES)
+# message(WARNING ${toto})
+# get_target_property(toto wolfcore INTERFACE_INCLUDE_DIRECTORIES)
+# message(WARNING ${toto})
+# get_target_property(toto wolfcore INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
+# message(WARNING ${toto})
 
 #Build demos
 #===============EXAMPLE=========================
diff --git a/include/vision/factor/factor_pixel_hp.h b/include/vision/factor/factor_pixel_hp.h
index 8693b5f72..fc92af152 100644
--- a/include/vision/factor/factor_pixel_hp.h
+++ b/include/vision/factor/factor_pixel_hp.h
@@ -99,15 +99,9 @@ inline FactorPixelHp::FactorPixelHp(const FeatureBasePtr&   _ftr_ptr,
 
 inline Eigen::VectorXd FactorPixelHp::expectation() const
 {
-<<<<<<< HEAD
-    FrameBasePtr    frm = getFeature()->getCapture()->getFrame();
-    SensorBasePtr   sen = getFeature()->getCapture()->getSensor();
-    LandmarkBasePtr lmk = getLandmarkOther();
-=======
     auto frm  = getFeature()->getCapture()->getFrame();
     auto sen  = getFeature()->getCapture()->getSensor();
     auto lmk  = getLandmarkOther();
->>>>>>> devel
 
     const Eigen::MatrixXd frame_pos     = frm->getP()->getState();
     const Eigen::MatrixXd frame_ori     = frm->getO()->getState();
-- 
GitLab