From 137a603ac3cc14db36e0252c7a9d8ea92761a624 Mon Sep 17 00:00:00 2001 From: Nathan Hughes Date: Fri, 5 Dec 2025 10:37:25 -0500 Subject: [PATCH 1/5] make openmp private for registration --- teaser/CMakeLists.txt | 3 +-- teaser/include/teaser/registration.h | 2 -- teaser/src/registration.cc | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/teaser/CMakeLists.txt b/teaser/CMakeLists.txt index b96e2f3..777d6ed 100644 --- a/teaser/CMakeLists.txt +++ b/teaser/CMakeLists.txt @@ -72,8 +72,7 @@ endif() find_package(OpenMP) if(OpenMP_CXX_FOUND) - target_link_libraries(teaser_registration PUBLIC OpenMP::OpenMP_CXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") + target_link_libraries(teaser_registration PRIVATE OpenMP::OpenMP_CXX) endif() add_library(teaserpp::teaser_registration ALIAS teaser_registration) diff --git a/teaser/include/teaser/registration.h b/teaser/include/teaser/registration.h index fb20f5b..79ec162 100644 --- a/teaser/include/teaser/registration.h +++ b/teaser/include/teaser/registration.h @@ -16,8 +16,6 @@ #include #include -#include "omp.h" - #include "teaser/graph.h" #include "teaser/geometry.h" diff --git a/teaser/src/registration.cc b/teaser/src/registration.cc index 01b6174..d88294a 100644 --- a/teaser/src/registration.cc +++ b/teaser/src/registration.cc @@ -14,6 +14,8 @@ #include #include +#include + #include "teaser/utils.h" #include "teaser/graph.h" #include "teaser/macros.h" From b87fa5e08be69645623c57a2bfab6c4289ecabd1 Mon Sep 17 00:00:00 2001 From: Nathan Hughes Date: Tue, 9 Dec 2025 09:31:57 -0500 Subject: [PATCH 2/5] update docs for pip install --- README.md | 23 ++++++++++++----------- doc/installation.rst | 14 ++------------ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a83365e..e73bf4a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TEASER++: fast & certifiable 3D registration +# TEASER++: fast & certifiable 3D registration [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Documentation Status](https://readthedocs.org/projects/teaser/badge/?version=latest)](https://teaser.readthedocs.io/en/latest/?badge=latest) [](https://github.com/MIT-SPARK/TEASER-plusplus/actions) @@ -97,11 +97,11 @@ sudo apt install cmake libeigen3-dev libboost-all-dev conda create -n teaser_test python=3.6 numpy conda activate teaser_test conda install -c open3d-admin open3d=0.9.0.0 + git clone https://github.com/MIT-SPARK/TEASER-plusplus.git -cd TEASER-plusplus && mkdir build && cd build -cmake -DTEASERPP_PYTHON_VERSION=3.6 .. && make teaserpp_python -cd python && pip install . -cd ../.. && cd examples/teaser_python_ply +cd TEASER-plusplus +pip install . +cd examples/teaser_python_ply python teaser_python_ply.py ``` You should see output similar to this: @@ -137,19 +137,20 @@ Number of outliers: 1700 Time taken (s): 0.9492652416229248 ``` -### Reproduce the GIF Above +### Reproduce the GIF Above Run the following script: ```shell script sudo apt install cmake libeigen3-dev libboost-all-dev conda create -n teaser_3dsmooth python=3.6 numpy conda activate teaser_3dsmooth conda install -c open3d-admin open3d=0.9.0.0 -conda install scikit-learn +conda install scikit-learn + git clone https://github.com/MIT-SPARK/TEASER-plusplus.git -cd TEASER-plusplus && mkdir build && cd build -cmake -DTEASERPP_PYTHON_VERSION=3.6 .. && make teaserpp_python -cd python && pip install . -cd ../.. && cd examples/teaser_python_3dsmooth +cd TEASER-plusplus +pip install . + +cd examples/teaser_python_3dsmooth python teaser_python_3dsmooth.py ``` You should be able to see Open3D windows showing registration results: diff --git a/doc/installation.rst b/doc/installation.rst index 41665c3..d06a952 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -116,23 +116,13 @@ Make sure you have compiled the project, then run: Installing Python bindings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -TEASER++ uses `pybind11 `_ to allow for minimal-effort interoperability between C++ and Python. To compile Python binding, run the following in the ``build`` folder you just created: +TEASER++ uses `pybind11 `_ to allow for minimal-effort interoperability between C++ and Python. To compile Python binding, run the following in the cloned repository you just created: .. code-block:: sh - cmake -DTEASERPP_PYTHON_VERSION=3.6 .. - make teaserpp_python - -You can replace ``3.6`` with the desired Python version you want to use TEASER++ with. - -Then, in the `build` folder, there should be a folder named ``python``. You can use the following commands to install the binding with ``pip``: - -.. code-block:: sh - - cd python pip install . -If you are using virtual environments or Anaconda, make sure to activate your environment before compiling and during ``pip install``. Make sure the targeted Python interpreter is the one in your desired environment, or otherwise there might be segmentation faults. +If you are using virtual environments or Anaconda, make sure to activate your environment before run ``pip install``. Installing MATLAB Bindings ^^^^^^^^^^^^^^^^^^^^^^^^^^ From 1e7b29c30ce3d65c41d2baed5bd2eb5430422bba Mon Sep 17 00:00:00 2001 From: Nathan Hughes Date: Tue, 9 Dec 2025 09:39:59 -0500 Subject: [PATCH 3/5] hide linalg header --- teaser/CMakeLists.txt | 1 + teaser/src/certification.cc | 2 +- teaser/{include/teaser => src}/linalg.h | 0 test/teaser/CMakeLists.txt | 6 ++++++ test/teaser/linalg-test.cc | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) rename teaser/{include/teaser => src}/linalg.h (100%) diff --git a/teaser/CMakeLists.txt b/teaser/CMakeLists.txt index 777d6ed..a112f7c 100644 --- a/teaser/CMakeLists.txt +++ b/teaser/CMakeLists.txt @@ -65,6 +65,7 @@ target_include_directories(teaser_registration $ PRIVATE $ + $ ) if(NOT BUILD_SHARED_LIBS) set_property(TARGET teaser_registration PROPERTY POSITION_INDEPENDENT_CODE 1) diff --git a/teaser/src/certification.cc b/teaser/src/certification.cc index cb4cc58..367b20d 100644 --- a/teaser/src/certification.cc +++ b/teaser/src/certification.cc @@ -17,7 +17,7 @@ #include #include "teaser/certification.h" -#include "teaser/linalg.h" +#include "linalg.h" // private header for testing teaser::CertificationResult teaser::DRSCertifier::certify(const Eigen::Matrix3d& R_solution, diff --git a/teaser/include/teaser/linalg.h b/teaser/src/linalg.h similarity index 100% rename from teaser/include/teaser/linalg.h rename to teaser/src/linalg.h diff --git a/test/teaser/CMakeLists.txt b/test/teaser/CMakeLists.txt index d628e94..d0c8ad2 100644 --- a/test/teaser/CMakeLists.txt +++ b/test/teaser/CMakeLists.txt @@ -35,6 +35,12 @@ endif () # Executable for running unit tests add_executable(all_tests ${TEST_SRCS}) target_link_libraries(all_tests ${TEST_LINK_LIBRARIES}) +target_include_directories(all_tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../teaser/src) + +find_package(OpenMP) +if(OpenMP_CXX_FOUND) + target_link_libraries(all_tests OpenMP::OpenMP_CXX) +endif() gtest_add_tests(TARGET all_tests TEST_LIST allTests) diff --git a/test/teaser/linalg-test.cc b/test/teaser/linalg-test.cc index 19af286..b034ce2 100644 --- a/test/teaser/linalg-test.cc +++ b/test/teaser/linalg-test.cc @@ -13,7 +13,7 @@ #include -#include "teaser/linalg.h" +#include "linalg.h" TEST(LinalgTest, HatMap) { { From 1bdc74c9d547cedd4b63eeba43344163023cdd07 Mon Sep 17 00:00:00 2001 From: Nathan Hughes Date: Tue, 9 Dec 2025 09:48:42 -0500 Subject: [PATCH 4/5] add missing header --- teaser/src/linalg.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/teaser/src/linalg.h b/teaser/src/linalg.h index 8ee6963..3fb7024 100644 --- a/teaser/src/linalg.h +++ b/teaser/src/linalg.h @@ -10,6 +10,8 @@ #include +#include + #include #include #include From cbe870913384508b533707d77b1d956e855065c8 Mon Sep 17 00:00:00 2001 From: Nathan Hughes Date: Tue, 9 Dec 2025 10:10:17 -0500 Subject: [PATCH 5/5] hide default thread call --- cmake/teaserppConfig.cmake | 2 -- teaser/include/teaser/registration.h | 5 +++-- teaser/src/registration.cc | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmake/teaserppConfig.cmake b/cmake/teaserppConfig.cmake index 554eab2..cd1967a 100644 --- a/cmake/teaserppConfig.cmake +++ b/cmake/teaserppConfig.cmake @@ -2,7 +2,5 @@ get_filename_component(TEASERPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) include(CMakeFindDependencyMacro) find_dependency(Eigen3 3.3 REQUIRED) -find_dependency(OpenMP REQUIRED) include("${TEASERPP_CMAKE_DIR}/teaserppTargets.cmake") - diff --git a/teaser/include/teaser/registration.h b/teaser/include/teaser/registration.h index 79ec162..0e16f33 100644 --- a/teaser/include/teaser/registration.h +++ b/teaser/include/teaser/registration.h @@ -24,6 +24,8 @@ namespace teaser { +int teaser_default_max_threads(); + /** * Struct to hold solution to a registration problem */ @@ -416,7 +418,6 @@ class RobustRegistrationSolver { * Note: the default values needed to be changed accordingly for best performance. */ struct Params { - /** * A bound on the noise of each provided measurement. */ @@ -509,7 +510,7 @@ class RobustRegistrationSolver { /** * Number of threads used for the maximum clique solver */ - int max_clique_num_threads = omp_get_max_threads(); + int max_clique_num_threads = teaser_default_max_threads(); }; RobustRegistrationSolver() = default; diff --git a/teaser/src/registration.cc b/teaser/src/registration.cc index d88294a..3e88099 100644 --- a/teaser/src/registration.cc +++ b/teaser/src/registration.cc @@ -20,6 +20,10 @@ #include "teaser/graph.h" #include "teaser/macros.h" +int teaser::teaser_default_max_threads() { + return omp_get_max_threads(); +} + void teaser::ScalarTLSEstimator::estimate(const Eigen::RowVectorXd& X, const Eigen::RowVectorXd& ranges, double* estimate, Eigen::Matrix* inliers) {