Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
cmake_minimum_required(VERSION 3.22)
project(map_closures_cpp VERSION 0.1.0 LANGUAGES CXX)

find_package(OpenCV REQUIRED)
# find_package(OpenCV REQUIRED)

option(USE_SYSTEM_EIGEN3 "Use system pre-installed Eigen" ON)
option(USE_SYSTEM_OPENCV "Use system pre-installed OpenCV" ON)

set(CMAKE_BUILD_TYPE Release)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
add_library(core STATIC)
add_library(map_closures::core ALIAS core)
target_sources(core PRIVATE DensityMap.cpp AlignRansac2D.cpp)
target_link_libraries(core PUBLIC Eigen3::Eigen ${OpenCV_LIBS})
target_link_libraries(core PUBLIC Eigen3::Eigen OpenCV4)
set_global_target_properties(core)
1 change: 1 addition & 0 deletions cpp/pipeline/MapClosures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ std::pair<std::vector<int>, cv::Mat> MapClosures::MatchAndAddLocalMap(
config_.hamming_distance_threshold,
srrg_hbst::SplittingStrategy::SplitEven);


const size_t clipped_top_k =
std::min(top_k, static_cast<unsigned int>(descriptor_matches_.size()));
std::vector<int> ref_mapclosure_indices(clipped_top_k);
Expand Down
16 changes: 16 additions & 0 deletions cpp/thirdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ else()
include(${CMAKE_CURRENT_LIST_DIR}/eigen/eigen.cmake)
endif()

if(${USE_SYSTEM_OPENCV})
find_package(OpenCV QUIET)
else()
include(${CMAKE_CURRENT_LIST_DIR}/opencv/opencv.cmake)
endif()
# Taken from a issue in the OpenCv project (https://github.com/opencv/opencv/issues/20548#issuecomment-1325751099)
# for some reason OpenCV does not want to convert to a FetchContent Friendly format so we need to use this trick
add_library(OpenCV4 INTERFACE)
target_link_libraries(OpenCV4 INTERFACE ${OpenCV_LIBS})
target_include_directories(OpenCV4 INTERFACE
${OPENCV_CONFIG_FILE_INCLUDE_DIR}
${OPENCV_MODULE_opencv_core_LOCATION}/include
${OPENCV_MODULE_opencv_highgui_LOCATION}/include
${OpenCV_INCLUDE_DIRS}
)

include(${CMAKE_CURRENT_LIST_DIR}/hbst/hbst.cmake)
34 changes: 34 additions & 0 deletions cpp/thirdparty/opencv/opencv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# MIT License
#
# Copyright (c) 2024 Saurabh Gupta, Tiziano Guadagnino, Benedikt Mersch,
# Ignacio Vizzo, Cyrill Stachniss.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Taken from a issue in the OpenCv project (https://github.com/opencv/opencv/issues/20548#issuecomment-1325751099)
# for some reason OpenCV does not want to convert to a FetchContent Friendly format so we need to use this trick
include(FetchContent)
FetchContent_Declare(
opencv
GIT_REPOSITORY https://github.com/opencv/opencv.git
GIT_TAG 4.x
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(opencv)