基础算法算子库 – KD-Tree

发布于 2023-04-03  146 次阅读


libnabo

简介

libnabo 是一个用于低维空间的快速 K 最近邻库。得益于 C++ 模板,它提供了一个干净、无遗留问题、与标量类型无关的 API。它当前的 CPU 实现受到ANN的强烈启发,但具有更紧凑的数据类型。平均而言,libnabo 比ANN快 5% 到 20% 。

libnabo 依赖于Eigen,一个现代 C++ 矩阵和线性代数库。libnabo 适用于 Eigen 的版本 2 或 3。libnabo 还可以选择依赖Boost,这是一个用于 Python 绑定的 C++ 通用库。

installion

download

git clone git@github.com:ethz-asl/libnabo.git

prerequisites

install

SRC_DIR=pwd
BUILD_DIR=${SRC_DIR}/build
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ${SRC_DIR}
# if Eigen or Boost are not available system-wide, run at that point:
#   cmake-gui .
# cmake-gui allows you to tell the location of Eigen or Boost
make
sudo make install

CmakeLists.txt

#--------------------
# DEPENDENCY: nabo
#--------------------
if (NOT TARGET nabo)
  # Find libnabo:
  find_package(libnabo REQUIRED PATHS ${LIBNABO_INSTALL_DIR})
  message(STATUS "libnabo found, version ${libnabo_VERSION} (include=${libnabo_INCLUDE_DIRS} libs=${libnabo_LIBRARIES})")
else()
  # libnabo already part of this project (e.g. as a git submodule)
  # (This, plus the use of cmake target properties in libnabo, will also
  # introduce the required include directories, flags, etc.)
endif()
# This cmake target alias will be defined by either: 
# a) libnabo sources if built as a git submodule in the same project than this library, or
# b) by libnabo-targets.cmake, included by find_package(libnabo) above.
set(libnabo_LIBRARIES libnabo::nabo)

# target_link_libraries THIRD_PARTY_LIBS is ok
set(THIRD_PARTY_LIBS
        ${libnabo_LIBRARIES}
        )

# ############## dependencies ######################
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
include_directories(${NABO_INCLUDE_DIR})

flann

简介

FLANN(近似近邻快速库)是一个用于执行快速近似近邻搜索的库。FLANN是用C++编写的,该库提供的C、MATLAB和Python接口。

Installion

download

git clone https://github.com/flann-lib/flann.git 

install

cd flann
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON_BINDINGS=OFF -DBUILD_MATLAB_BINDINGS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_D
OC=OFF ..
make -j5
sudo make install

CMakeLists.txt

find_package(flann REQUIRED)
set(THIRD_PARTY_LIBS
        ${libflann_LIBRARIES}
        )

本当の声を響かせてよ