Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal flann #1495

Merged
merged 10 commits into from
Aug 1, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
build-linux:
runs-on: ubuntu-latest
container:
image: alicevision/alicevision-deps:2023.06.21-centos7-cuda11.3.1
image: alicevision/alicevision-deps:2023.07.31-centos7-cuda11.3.1
env:
DEPS_INSTALL_DIR: /opt/AliceVision_install
BUILD_TYPE: Release
Expand Down
31 changes: 19 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ option(AV_BUILD_VPX "Enable building an embedded libvpx required for ffmpeg" ON)
option(AV_BUILD_COINUTILS "Enable building an embedded CoinUtils" ON)
option(AV_BUILD_OSI "Enable building an embedded Osi" ON)
option(AV_BUILD_CLP "Enable building an embedded Clp" ON)
option(AV_BUILD_PCL "Enable building an embedded PointCloud library" ON)
option(AV_BUILD_FLANN "Enable building an embedded Flann" ON)
option(AV_BUILD_PCL "Enable building an embedded PointCloud library" OFF)
option(AV_BUILD_USD "Enable building an embedded USD library" OFF)
option(AV_BUILD_ALICEVISION "Enable building of AliceVision" ON)
option(AV_EIGEN_MEMORY_ALIGNMENT "Enable Eigen memory alignment" ON)
Expand Down Expand Up @@ -85,6 +86,7 @@ message(STATUS "AV_USE_OPENMP: ${AV_USE_OPENMP}")
message(STATUS "AV_BUILD_COINUTILS: ${AV_BUILD_COINUTILS}")
message(STATUS "AV_BUILD_OSI: ${AV_BUILD_OSI}")
message(STATUS "AV_BUILD_CLP: ${AV_BUILD_CLP}")
message(STATUS "AV_BUILD_FLANN: ${AV_BUILD_FLANN}")
message(STATUS "AV_BUILD_PCL: ${AV_BUILD_PCL}")
message(STATUS "AV_BUILD_USD: ${AV_BUILD_USD}")
message(STATUS "AV_BUILD_DEPENDENCIES_PARALLEL: ${AV_BUILD_DEPENDENCIES_PARALLEL}")
Expand Down Expand Up @@ -976,14 +978,12 @@ ExternalProject_Add(${CLP_TARGET}
set(CLP_CMAKE_FLAGS -DClp_DIR:PATH=${CMAKE_INSTALL_PREFIX}/share/clp)
endif()

# Add PCL
if(AV_BUILD_PCL)
# build other dependencies for pcl
if(AV_BUILD_FLANN)
# add lz4 for flann
set(LZ4_TARGET lz4)
ExternalProject_Add(${LZ4_TARGET}
GIT_REPOSITORY https://github.com/alicevision/lz4
GIT_TAG 47a530e8a8c945ad3bb809e2ce4591a56c5081e2
GIT_REPOSITORY https://github.com/lz4/lz4
GIT_TAG v1.9.4
PREFIX ${BUILD_DIR}
BUILD_IN_SOURCE 0
BUILD_ALWAYS 0
Expand All @@ -993,38 +993,43 @@ if(AV_BUILD_PCL)
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${CMAKE_CORE_BUILD_FLAGS}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
<SOURCE_DIR>
<SOURCE_DIR>/build/cmake/
BUILD_COMMAND $(MAKE) -j${AV_BUILD_DEPENDENCIES_PARALLEL}
INSTALL_COMMAND $(MAKE) -j${AV_BUILD_DEPENDENCIES_PARALLEL} install
)
set(LZ4_CMAKE_FLAGS -Dlz4_DIR:PATH=${CMAKE_INSTALL_PREFIX}/lib/cmake/lz4/)

# @TODO whenever flann will be removed as embedded dependency move this and lz4 out from if(AV_BUILD_PCL) as they will be needed by the library
# add flann
set(FLANN_TARGET flann)
ExternalProject_Add(${FLANN_TARGET}
GIT_REPOSITORY https://github.com/alicevision/flann
GIT_TAG 9e79ca6881b779fb842e83c17aef1f4c816ce058
GIT_TAG 46e72429ef60ce9c413fa926ac7729f8dee96395
PREFIX ${BUILD_DIR}
BUILD_IN_SOURCE 0
BUILD_ALWAYS 0
UPDATE_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/${FLANN_TARGET}
BINARY_DIR ${BUILD_DIR}/${FLANN_TARGET}_build
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${CMAKE_CORE_BUILD_FLAGS}
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig/
${CMAKE_COMMAND} ${CMAKE_CORE_BUILD_FLAGS}
-DBUILD_C_BINDINGS:BOOL=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTS:BOOL=OFF
-DBUILD_DOC:BOOL=OFF
-DBUILD_PYTHON_BINDINGS:BOOL=OFF
-DBUILD_MATLAB_BINDINGS:BOOL=OFF
${LZ4_CMAKE_FLAGS}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> <SOURCE_DIR>
BUILD_COMMAND $(MAKE) -j${AV_BUILD_DEPENDENCIES_PARALLEL}
INSTALL_COMMAND $(MAKE) -j${AV_BUILD_DEPENDENCIES_PARALLEL} install
DEPENDS ${LZ4_TARGET}
)
set(FLANN_CMAKE_FLAGS -Dflann_DIR:PATH=${CMAKE_INSTALL_PREFIX}/lib/cmake/flann/)

endif()

# Add PCL
if(AV_BUILD_PCL)
# add point cloud library
set(PCL_TARGET pcl)
ExternalProject_Add(${PCL_TARGET}
Expand Down Expand Up @@ -1123,6 +1128,8 @@ set(AV_DEPS
${OSI_TARGET}
${CLP_TARGET}
${USD_TARGET}
${FLANN_TARGET}
${LZ4_TARGET}
)

if(AV_BUILD_ALICEVISION)
Expand Down
7 changes: 4 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ AliceVision depends on external libraries:
* CoinUtils >= 2.9.3 use [our fork](https://github.com/alicevision/CoinUtils) with a CMake build system so that it can be easily found
* Coin-or linear programming (Clp) use [our fork](https://github.com/alicevision/Clp) with a CMake build system
* [Eigen >= 3.3.4](https://gitlab.com/libeigen/eigen)
* [Geogram >= 1.7.5](https://github.com/BrunoLevy/geogram)
* [Expat >= 2.4.8](https://libexpat.github.io/)
* Flann >= 1.8.4, use [our fork](https://github.com/alicevision/flann) with a CMake build system
* [Geogram >= 1.7.5](https://github.com/BrunoLevy/geogram)
* [OpenEXR >= 2.5](https://github.com/AcademySoftwareFoundation/openexr)
* [OpenImageIO >= 2.1.0 (recommended >= 2.4.12)](https://github.com/OpenImageIO/oiio)
* Open Solver Interface (Osi) >= 0.106.10 use [our fork](https://github.com/alicevision/Osi)) with a CMake build system
Expand All @@ -52,7 +53,6 @@ Other optional libraries can enable specific features (check "CMake Options" for

AliceVision also depends on some embedded libraries:

* Flann >= 1.8.4 (internal)
* Lemon >= 1.3 (internal)
* MeshSDFilter (internal)
* OpenMesh (internal)
Expand Down Expand Up @@ -90,6 +90,7 @@ vcpkg install ^
geogram ^
eigen3 ^
expat ^
flann ^
onnxruntime-gpu ^
opencv[eigen,ffmpeg,webp,contrib,nonfree,cuda] ^
openimageio[libraw,ffmpeg,freetype,opencv,gif,openjpeg,webp] ^
Expand Down Expand Up @@ -175,7 +176,7 @@ At the end of the cmake process, a report shows for each library which version (
```
-- EIGEN: 3.3.4
-- CERES: 1.10.0
-- FLANN: 1.8.4 (external)
-- FLANN: 1.8.4
-- LEMON: 1.3 (internal)
```

Expand Down
2 changes: 1 addition & 1 deletion docker/build-centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test -e docker/fetch.sh || {
exit 1
}

test -z "$AV_DEPS_VERSION" && AV_DEPS_VERSION=2023.06.21
test -z "$AV_DEPS_VERSION" && AV_DEPS_VERSION=2023.07.31
test -z "$AV_VERSION" && AV_VERSION="$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD)"
test -z "$CUDA_VERSION" && CUDA_VERSION=11.3.1
test -z "$CENTOS_VERSION" && CENTOS_VERSION=7
Expand Down
2 changes: 1 addition & 1 deletion docker/build-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test -e docker/fetch.sh || {
exit 1
}

test -z "$AV_DEPS_VERSION" && AV_DEPS_VERSION=2023.06.21
test -z "$AV_DEPS_VERSION" && AV_DEPS_VERSION=2023.07.31
test -z "$AV_VERSION" && AV_VERSION="$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD)"
test -z "$CUDA_VERSION" && CUDA_VERSION=11.3.1
test -z "$UBUNTU_VERSION" && UBUNTU_VERSION=20.04
Expand Down
2 changes: 1 addition & 1 deletion docker/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cmake -P "external/src/mpfr-stamp/download-mpfr.cmake"
cmake -P "external/src/openexr-stamp/download-openexr.cmake"
# cmake -P "external/src/opengv-stamp/download-opengv.cmake"
cmake -P "external/src/openimageio-stamp/download-openimageio.cmake"
cmake -P "external/src/pcl-stamp/download-pcl.cmake"
# cmake -P "external/src/pcl-stamp/download-pcl.cmake"
cmake -P "external/src/png-stamp/download-png.cmake"
cmake -P "external/src/suitesparse-stamp/download-suitesparse.cmake"
cmake -P "external/src/tbb-stamp/download-tbb.cmake"
Expand Down
32 changes: 13 additions & 19 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ endmacro(add_target_properties)
# ==============================================================================
# Check that submodule have been initialized and updated
# ==============================================================================
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/flann/src)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/MeshSDFilter/external)
message(FATAL_ERROR
"\n submodule(s) are missing, please update your repository:\n"
" > git submodule update -i\n")
Expand Down Expand Up @@ -428,18 +428,18 @@ endif()
# ==============================================================================
# Flann
# ==============================================================================
# - internal by default (flann),
# - external if FLANN_INCLUDE_DIR_HINTS and a valid Flann setup is found
# ==============================================================================
if(ALICEVISION_BUILD_SFM)
if(NOT DEFINED FLANN_INCLUDE_DIR_HINTS)
set(FLANN_INCLUDE_DIR_HINTS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/flann/src/cpp)
set(ALICEVISION_USE_INTERNAL_FLANN ON)
endif()
find_package(Flann QUIET)
if(NOT FLANN_FOUND OR ALICEVISION_USE_INTERNAL_FLANN)
set(FLANN_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/flann/src/cpp)
set(FLANN_LIBRARY flann_cpp_s)
find_package(lz4 REQUIRED)
find_package(flann REQUIRED)

if (TARGET lz4::lz4)
set(FLANN_LIBRARIES flann::flann_cpp lz4::lz4)
elseif (TARGET LZ4::lz4_static)
set(FLANN_LIBRARIES flann::flann_cpp LZ4::lz4_static)
elseif (TARGET LZ4::lz4_shared)
set(FLANN_LIBRARIES flann::flann_cpp LZ4::lz4_shared)
else()
message(FATAL_ERROR "FLANN can not be found")
endif()
endif()

Expand Down Expand Up @@ -947,13 +947,7 @@ message(STATUS "EIGEN: " ${EIGEN_VERSION} "")

if(ALICEVISION_BUILD_SFM)
message(STATUS "CERES: " ${CERES_VERSION} "")

if(ALICEVISION_USE_INTERNAL_FLANN)
message(STATUS "FLANN: " ${FLANN_VERSION} " (internal)")
else()
message(STATUS "FLANN: " ${FLANN_VERSION} " (external)")
endif()

message(STATUS "FLANN: " ${FLANN_VERSION} "")
message(STATUS "CLP: " ${Clp_VERSION} "")
message(STATUS "COINUTILS: " ${CoinUtils_VERSION} "")
message(STATUS "OSI: " ${Osi_VERSION} "")
Expand Down
1 change: 1 addition & 0 deletions src/aliceVision/localization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ alicevision_add_library(aliceVision_localization
aliceVision_matchingImageCollection
Boost::filesystem
Boost::boost
${FLANN_LIBRARIES}
)

if(ALICEVISION_HAVE_CCTAG)
Expand Down
3 changes: 3 additions & 0 deletions src/aliceVision/localization/VoctreeLocalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <aliceVision/matching/svgVisualization.hpp>
#include <aliceVision/matching/RegionsMatcher.hpp>
#include <aliceVision/matchingImageCollection/IImageCollectionMatcher.hpp>
#include <aliceVision/matching/ArrayMatcher_kdtreeFlann.hpp>
#include <aliceVision/matchingImageCollection/GeometricFilterMatrix.hpp>
#include <aliceVision/matching/ArrayMatcher_kdtreeFlann.hpp>
#include <aliceVision/matchingImageCollection/GeometricFilterMatrix_F_AC.hpp>
Expand All @@ -26,6 +27,8 @@
#include <aliceVision/system/ProgressDisplay.hpp>
#include <aliceVision/system/Timer.hpp>

#include <flann/algorithms/dist.h>

#include <boost/filesystem.hpp>

#include <algorithm>
Expand Down
3 changes: 0 additions & 3 deletions src/aliceVision/localization/VoctreeLocalizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
#include <aliceVision/stl/mapUtils.hpp>
#include <aliceVision/voctree/VocabularyTree.hpp>
#include <aliceVision/voctree/Database.hpp>
#include <aliceVision/matching/ArrayMatcher_kdtreeFlann.hpp>
#include <aliceVision/matching/RegionsMatcher.hpp>
#include <aliceVision/localization/reconstructed_regions.hpp>
#include <aliceVision/localization/LocalizationResult.hpp>
#include <aliceVision/localization/ILocalizer.hpp>
#include <aliceVision/localization/BoundedBuffer.hpp>

#include <flann/algorithms/dist.h>

namespace aliceVision {
namespace localization {

Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/matching/ArrayMatcher_kdtreeFlann.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <aliceVision/config.hpp>
#include <aliceVision/alicevision_omp.hpp>

#include "flann/flann.hpp"
#include <flann/flann.hpp>

#include <memory>

Expand Down
5 changes: 3 additions & 2 deletions src/aliceVision/matching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ alicevision_add_library(aliceVision_matching
aliceVision_numeric
aliceVision_stl
aliceVision_system

PRIVATE_LINKS
Boost::filesystem
Boost::boost
${FLANN_LIBRARY}
${FLANN_LIBRARIES}
)

# Unit tests
alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching)
alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching ${FLANN_LIBRARIES})
alicevision_add_test(filters_test.cpp NAME "matching_filters" LINKS aliceVision_matching)
alicevision_add_test(indMatch_test.cpp NAME "matching_indMatch" LINKS aliceVision_matching)

Expand Down
1 change: 1 addition & 0 deletions src/aliceVision/matchingImageCollection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ alicevision_add_library(aliceVision_matchingImageCollection
PRIVATE_LINKS
aliceVision_system
${CERES_LIBRARIES}
${FLANN_LIBRARIES}
)

# Unit tests
Expand Down
50 changes: 0 additions & 50 deletions src/cmake/FindFlann.cmake

This file was deleted.

Loading
Loading