From 4756bae4b35165c300323fa4d0ec3b5f1f358e5f Mon Sep 17 00:00:00 2001
From: jvallve <jvallve@iri.upc.edu>
Date: Mon, 24 Jul 2023 14:27:06 +0200
Subject: [PATCH] [skip ci] wip

---
 CMakeLists.txt                           | 45 ++++++++++++---------
 include/vision/utils/load_vision.h       | 51 ++++++++++++++++++++++++
 src/utils/load_vision.cpp                | 26 ++++++++++++
 test/gtest_capture_image.cpp             |  6 ---
 test/gtest_factor_epipolar.cpp           |  6 ---
 test/gtest_processor_visual_odometry.cpp |  6 ---
 test/gtest_sensor_camera.cpp             |  6 ---
 7 files changed, 104 insertions(+), 42 deletions(-)
 create mode 100644 include/vision/utils/load_vision.h
 create mode 100644 src/utils/load_vision.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c63a28f62..d1471eda4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,19 +111,19 @@ INCLUDE_DIRECTORIES(BEFORE "include")
 
 # ============ HEADERS ============ 
 SET(HDRS_CAPTURE
-include/${PROJECT_NAME}/capture/capture_image.h
+  include/${PROJECT_NAME}/capture/capture_image.h
   )
 SET(HDRS_COMMON
-include/${PROJECT_NAME}/common/vision.h
+  include/${PROJECT_NAME}/common/vision.h
   )
 SET(HDRS_FACTOR
 # include/${PROJECT_NAME}/factor/factor_trifocal.h
 # include/${PROJECT_NAME}/factor/factor_ahp.h
-include/${PROJECT_NAME}/factor/factor_pixel_hp.h
+  include/${PROJECT_NAME}/factor/factor_pixel_hp.h
 # include/${PROJECT_NAME}/factor/factor_epipolar.h
   )
 SET(HDRS_FEATURE
-include/${PROJECT_NAME}/feature/feature_point_image.h
+  include/${PROJECT_NAME}/feature/feature_point_image.h
   )
 SET(HDRS_LANDMARK
   # include/${PROJECT_NAME}/landmark/landmark_ahp.h
@@ -131,38 +131,44 @@ SET(HDRS_LANDMARK
   include/${PROJECT_NAME}/landmark/landmark_point_3d.h
   )
 SET(HDRS_MATH
-include/${PROJECT_NAME}/math/pinhole_tools.h
+  include/${PROJECT_NAME}/math/pinhole_tools.h
   )
 SET(HDRS_PROCESSOR
-include/${PROJECT_NAME}/processor/processor_visual_odometry.h
-include/${PROJECT_NAME}/processor/active_search.h
+  include/${PROJECT_NAME}/processor/processor_visual_odometry.h
+  include/${PROJECT_NAME}/processor/active_search.h
   )
 SET(HDRS_SENSOR
-include/${PROJECT_NAME}/sensor/sensor_camera.h
+  include/${PROJECT_NAME}/sensor/sensor_camera.h
+  )
+SET(HDRS_UTILS
+  include/${PROJECT_NAME}/utils/load_vision.h
   )
 
 # ============ SOURCES ============ 
 SET(SRCS_CAPTURE
-src/capture/capture_image.cpp
+  src/capture/capture_image.cpp
   )
 SET(SRCS_FEATURE
-src/feature/feature_point_image.cpp
+  src/feature/feature_point_image.cpp
   )
 SET(SRCS_LANDMARK
-# src/landmark/landmark_ahp.cpp
-src/landmark/landmark_hp.cpp
-src/landmark/landmark_point_3d.cpp
+  # src/landmark/landmark_ahp.cpp
+  src/landmark/landmark_hp.cpp
+  src/landmark/landmark_point_3d.cpp
   )
 SET(SRCS_PROCESSOR
-src/processor/processor_visual_odometry.cpp
-src/processor/active_search.cpp
+  src/processor/processor_visual_odometry.cpp
+  src/processor/active_search.cpp
   )
 SET(SRCS_SENSOR
-src/sensor/sensor_camera.cpp
+  src/sensor/sensor_camera.cpp
+  )
+SET(SRCS_UTILS
+  src/utils/load_vision.cpp
   )
 SET(SRCS_YAML
-src/yaml/sensor_camera_yaml.cpp
-)
+  src/yaml/sensor_camera_yaml.cpp
+  )
 
 # create the shared library
 ADD_LIBRARY(${PLUGIN_NAME}
@@ -172,6 +178,7 @@ ADD_LIBRARY(${PLUGIN_NAME}
   ${SRCS_LANDMARK}
   ${SRCS_PROCESSOR}
   ${SRCS_SENSOR}
+  ${SRCS_UTILS}
   ${SRCS_YAML}
   )
   
@@ -264,6 +271,8 @@ INSTALL(FILES ${HDRS_PROCESSOR}
   DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/processor)
 INSTALL(FILES ${HDRS_SENSOR}
   DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/sensor)
+INSTALL(FILES ${HDRS_UTILS}
+  DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/utils)
 
 INSTALL(FILES "${WOLF_CONFIG_DIR}/config.h"
   DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/internal)
diff --git a/include/vision/utils/load_vision.h b/include/vision/utils/load_vision.h
new file mode 100644
index 000000000..8089d00cd
--- /dev/null
+++ b/include/vision/utils/load_vision.h
@@ -0,0 +1,51 @@
+// WOLF - Copyright (C) 2020,2021,2022,2023
+// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
+// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
+// Joan Vallvé Navarro (jvallve@iri.upc.edu)
+// All rights reserved.
+//
+// This file is part of WOLF: http://www.iri.upc.edu/wolf
+// WOLF is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+
+namespace wolf
+{
+// This class is just to force the .so to be easily loaded in tests
+class LoadVision
+{
+  public:
+    static bool aux_var;
+};
+
+#ifdef __GNUC__
+#define WOLF_UNUSED __attribute__((used))
+#elif defined _MSC_VER
+#pragma warning(disable : Cxxxxx)
+#define WOLF_UNUSED
+#elif defined(__LCLINT__)
+#define WOLF_UNUSED /*@unused@*/
+#elif defined(__cplusplus)
+#define WOLF_UNUSED
+#else
+#define UNUSED(x) x
+#endif
+
+#define WOLF_LOAD_VISION                                                                                                \
+    namespace                                                                                                         \
+    {                                                                                                                 \
+    const bool WOLF_UNUSED aux_var_gnss = wolf::LoadVision::aux_var;                                                  \
+    }
+
+}  // namespace wolf
diff --git a/src/utils/load_vision.cpp b/src/utils/load_vision.cpp
new file mode 100644
index 000000000..db88acf94
--- /dev/null
+++ b/src/utils/load_vision.cpp
@@ -0,0 +1,26 @@
+// WOLF - Copyright (C) 2020,2021,2022,2023
+// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
+// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
+// Joan Vallvé Navarro (jvallve@iri.upc.edu)
+// All rights reserved.
+//
+// This file is part of WOLF: http://www.iri.upc.edu/wolf
+// WOLF is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "vision/utils/load_vision.h"
+
+namespace wolf
+{
+bool LoadVision::aux_var = true;
+}  // namespace wolf
diff --git a/test/gtest_capture_image.cpp b/test/gtest_capture_image.cpp
index 1c6cc7164..21ca0f255 100644
--- a/test/gtest_capture_image.cpp
+++ b/test/gtest_capture_image.cpp
@@ -17,12 +17,6 @@
 //
 // You should have received a copy of the GNU Lesser General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
-/**
- * \file gtest_capture_image.cpp
- *
- *  Created on: March 31, 2022
- *      \author: mfourmy
- */
 
 #include <string>
 #include <core/utils/utils_gtest.h>
diff --git a/test/gtest_factor_epipolar.cpp b/test/gtest_factor_epipolar.cpp
index 9f606aa95..57c39e5b5 100644
--- a/test/gtest_factor_epipolar.cpp
+++ b/test/gtest_factor_epipolar.cpp
@@ -17,12 +17,6 @@
 //
 // You should have received a copy of the GNU Lesser General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
-/**
- * \file gtest_factor_epipolar.cpp
- *
- *  Created on: Aug 25, 2019
- *      \author: jsola
- */
 
 
 #include "vision/factor/factor_epipolar.h"
diff --git a/test/gtest_processor_visual_odometry.cpp b/test/gtest_processor_visual_odometry.cpp
index 5dbf3b219..b89ed6bab 100644
--- a/test/gtest_processor_visual_odometry.cpp
+++ b/test/gtest_processor_visual_odometry.cpp
@@ -17,12 +17,6 @@
 //
 // You should have received a copy of the GNU Lesser General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
-/**
- * \file gtest_preprocess.cpp
- *
- *  Created on: March 31, 2022
- *      \author: cdebeunne
- */
 
 #include <string>
 #include <core/utils/utils_gtest.h>
diff --git a/test/gtest_sensor_camera.cpp b/test/gtest_sensor_camera.cpp
index d8f9c8cd9..51c826adf 100644
--- a/test/gtest_sensor_camera.cpp
+++ b/test/gtest_sensor_camera.cpp
@@ -17,12 +17,6 @@
 //
 // You should have received a copy of the GNU Lesser General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
-/**
- * \file gtest_sensor_camera.cpp
- *
- *  Created on: Feb 7, 2019
- *      \author: jsola
- */
 
 
 #include <core/utils/utils_gtest.h>
-- 
GitLab