Coder Social home page Coder Social logo

jaybro / pico_tree Goto Github PK

View Code? Open in Web Editor NEW
36.0 5.0 7.0 1.78 MB

A C++ header only library for fast nearest neighbor and range searches using a KdTree. It supports interfacing with Eigen, OpenCV, and custom data types and provides optional Python bindings.

License: MIT License

CMake 6.42% C++ 87.91% Python 5.67%
kdtree header-only kd-tree pico-tree eigen python-bindings opencv cpp range-searching approximate-nearest-neighbor-searching

pico_tree's Introduction

PicoTree

build-and-test pip

PicoTree is a C++ header only library with Python bindings for fast nearest neighbor searches and range searches using a KdTree. See the table below to get an impression of the performance provided by the KdTree of this library versus several other implementations:

Build C++ Build Python Knn C++ Knn Python
nanoflann v1.5.0 2.9s ... 3.2s ...
SciPy KDTree 1.11.0 ... 4.5s ... 563.6s
Scikit-learn KDTree 1.2.2 ... 6.2s ... 42.2s
pykdtree 1.3.7 ... 1.0s ... 6.6s
OpenCV FLANN 4.6.0 1.9s ... 4.7s ...
PicoTree KdTree v0.8.3 0.9s 1.0s 2.8s 3.1s

Two LiDAR based point clouds of sizes 7733372 and 7200863 were used to generate these numbers. The first point cloud was the input to the build algorithm and the second to the query algorithm. All benchmarks were run on a single thread with the following parameters: max_leaf_size=10 and knn=1. A more detailed C++ comparison of PicoTree is available with respect to nanoflann.

Available under the MIT license.

Capabilities

KdTree:

  • Nearest neighbor, approximate nearest neighbor, radius, box, and customizable nearest neighbor searches.
  • Different metric spaces:
    • Support for topological spaces with identifications. E.g., points on the circle [-pi, pi].
    • Available distance functions: L1, L2Squared, LInf, SO2, and SE2Squared.
    • Metrics can be customized.
  • Multiple tree splitting rules: kLongestMedian, kMidpoint and kSlidingMidpoint.
  • Compile time and run time known dimensions.
  • Static tree builds.
  • Thread safe queries.
  • Optional Python bindings.

PicoTree can interface with different types of points and point sets through traits classes. These can be custom implementations or one of the pico_tree::SpaceTraits<> and pico_tree::PointTraits<> classes provided by this library.

  • Space type support:
    • std::vector<PointType>.
    • pico_tree::SpaceMap<PointType>.
    • Eigen::Matrix<> and Eigen::Map<Eigen::Matrix<>>.
    • cv::Mat.
  • Point type support:
    • Fixed size arrays and std::array<>.
    • pico_tree::PointMap<>.
    • Eigen::Vector<> and Eigen::Map<Eigen::Vector<>>.
    • cv::Vec<>.
  • pico_tree::SpaceMap<PointType> and pico_tree::PointMap<> allow interfacing with dynamic size arrays. It is assumed that points and their coordinates are laid out contiguously in memory.

Examples

Requirements

Minimum:

  • A compiler that is compliant with the C++17 standard or higher.
  • CMake. It is also possible to just copy and paste the pico_tree directory into an include directory.

Optional:

  • Doxygen. Needed for generating documentation.
  • Google Test. Used for running unit tests.
  • Eigen. To run the example that shows how Eigen data types can be used in combination with PicoTree.
  • OpenCV. To run the OpenCV example that shows how to work with OpenCV data types.
  • Google Benchmark is needed to run any of the benchmarks. The nanoflann and OpenCV benchmarks also require their respective libraries to be installed.

Python bindings:

  • Python. Version 3.7 or higher.
  • pybind11. Used to ease the creation of Python bindings. Available under the BSD license and copyright.
  • OpenMP. For parallelization of queries.
  • numpy. Points and search results are represented by ndarrays.
  • scikit-build. Glue between CMake and setuptools.

Build

Build with CMake:

$ mkdir build && cd build
$ cmake ../
$ cmake --build .
$ cmake --build . --target pico_tree_doc
$ cmake --install .
find_package(PicoTree REQUIRED)

add_executable(myexe main.cpp)
target_link_libraries(myexe PUBLIC PicoTree::PicoTree)

Install with pip:

$ pip install ./pico_tree

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.