Skip to content

Commit 52a9c52

Browse files
Update README and make OpenMP a private dependency (#212)
* make openmp private for registration * update docs for pip install * hide linalg header * add missing header * hide default thread call
1 parent e2f6f17 commit 52a9c52

File tree

10 files changed

+35
-33
lines changed

10 files changed

+35
-33
lines changed

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# TEASER++: fast & certifiable 3D registration
1+
# TEASER++: fast & certifiable 3D registration
22
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
[![Documentation Status](https://readthedocs.org/projects/teaser/badge/?version=latest)](https://teaser.readthedocs.io/en/latest/?badge=latest)
44
[<img src="https://github.com/MIT-SPARK/TEASER-plusplus/workflows/build/badge.svg">](https://github.com/MIT-SPARK/TEASER-plusplus/actions)
@@ -97,11 +97,11 @@ sudo apt install cmake libeigen3-dev libboost-all-dev
9797
conda create -n teaser_test python=3.6 numpy
9898
conda activate teaser_test
9999
conda install -c open3d-admin open3d=0.9.0.0
100+
100101
git clone https://github.com/MIT-SPARK/TEASER-plusplus.git
101-
cd TEASER-plusplus && mkdir build && cd build
102-
cmake -DTEASERPP_PYTHON_VERSION=3.6 .. && make teaserpp_python
103-
cd python && pip install .
104-
cd ../.. && cd examples/teaser_python_ply
102+
cd TEASER-plusplus
103+
pip install .
104+
cd examples/teaser_python_ply
105105
python teaser_python_ply.py
106106
```
107107
You should see output similar to this:
@@ -137,19 +137,20 @@ Number of outliers: 1700
137137
Time taken (s): 0.9492652416229248
138138
```
139139

140-
### Reproduce the GIF Above
140+
### Reproduce the GIF Above
141141
Run the following script:
142142
```shell script
143143
sudo apt install cmake libeigen3-dev libboost-all-dev
144144
conda create -n teaser_3dsmooth python=3.6 numpy
145145
conda activate teaser_3dsmooth
146146
conda install -c open3d-admin open3d=0.9.0.0
147-
conda install scikit-learn
147+
conda install scikit-learn
148+
148149
git clone https://github.com/MIT-SPARK/TEASER-plusplus.git
149-
cd TEASER-plusplus && mkdir build && cd build
150-
cmake -DTEASERPP_PYTHON_VERSION=3.6 .. && make teaserpp_python
151-
cd python && pip install .
152-
cd ../.. && cd examples/teaser_python_3dsmooth
150+
cd TEASER-plusplus
151+
pip install .
152+
153+
cd examples/teaser_python_3dsmooth
153154
python teaser_python_3dsmooth.py
154155
```
155156
You should be able to see Open3D windows showing registration results:

cmake/teaserppConfig.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ get_filename_component(TEASERPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
22
include(CMakeFindDependencyMacro)
33

44
find_dependency(Eigen3 3.3 REQUIRED)
5-
find_dependency(OpenMP REQUIRED)
65

76
include("${TEASERPP_CMAKE_DIR}/teaserppTargets.cmake")
8-

doc/installation.rst

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,13 @@ Make sure you have compiled the project, then run:
116116
Installing Python bindings
117117
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118118

119-
TEASER++ uses `pybind11 <https://github.com/pybind/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:
119+
TEASER++ uses `pybind11 <https://github.com/pybind/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:
120120

121121
.. code-block:: sh
122122
123-
cmake -DTEASERPP_PYTHON_VERSION=3.6 ..
124-
make teaserpp_python
125-
126-
You can replace ``3.6`` with the desired Python version you want to use TEASER++ with.
127-
128-
Then, in the `build` folder, there should be a folder named ``python``. You can use the following commands to install the binding with ``pip``:
129-
130-
.. code-block:: sh
131-
132-
cd python
133123
pip install .
134124
135-
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.
125+
If you are using virtual environments or Anaconda, make sure to activate your environment before run ``pip install``.
136126

137127
Installing MATLAB Bindings
138128
^^^^^^^^^^^^^^^^^^^^^^^^^^

teaser/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ target_include_directories(teaser_registration
6565
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
6666
PRIVATE
6767
$<BUILD_INTERFACE:${spectra_SOURCE_DIR}/include>
68+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
6869
)
6970
if(NOT BUILD_SHARED_LIBS)
7071
set_property(TARGET teaser_registration PROPERTY POSITION_INDEPENDENT_CODE 1)
7172
endif()
7273

7374
find_package(OpenMP)
7475
if(OpenMP_CXX_FOUND)
75-
target_link_libraries(teaser_registration PUBLIC OpenMP::OpenMP_CXX)
76-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
76+
target_link_libraries(teaser_registration PRIVATE OpenMP::OpenMP_CXX)
7777
endif()
7878

7979
add_library(teaserpp::teaser_registration ALIAS teaser_registration)

teaser/include/teaser/registration.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <Eigen/SVD>
1717
#include <Eigen/Geometry>
1818

19-
#include "omp.h"
20-
2119
#include "teaser/graph.h"
2220
#include "teaser/geometry.h"
2321

@@ -26,6 +24,8 @@
2624

2725
namespace teaser {
2826

27+
int teaser_default_max_threads();
28+
2929
/**
3030
* Struct to hold solution to a registration problem
3131
*/
@@ -418,7 +418,6 @@ class RobustRegistrationSolver {
418418
* Note: the default values needed to be changed accordingly for best performance.
419419
*/
420420
struct Params {
421-
422421
/**
423422
* A bound on the noise of each provided measurement.
424423
*/
@@ -511,7 +510,7 @@ class RobustRegistrationSolver {
511510
/**
512511
* Number of threads used for the maximum clique solver
513512
*/
514-
int max_clique_num_threads = omp_get_max_threads();
513+
int max_clique_num_threads = teaser_default_max_threads();
515514
};
516515

517516
RobustRegistrationSolver() = default;

teaser/src/certification.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <Spectra/SymEigsShiftSolver.h>
1818

1919
#include "teaser/certification.h"
20-
#include "teaser/linalg.h"
20+
#include "linalg.h" // private header for testing
2121

2222
teaser::CertificationResult
2323
teaser::DRSCertifier::certify(const Eigen::Matrix3d& R_solution,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <iostream>
1212

13+
#include <omp.h>
14+
1315
#include <Eigen/Core>
1416
#include <Eigen/SparseCore>
1517
#include <Eigen/Eigenvalues>

teaser/src/registration.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
#include <limits>
1515
#include <iterator>
1616

17+
#include <omp.h>
18+
1719
#include "teaser/utils.h"
1820
#include "teaser/graph.h"
1921
#include "teaser/macros.h"
2022

23+
int teaser::teaser_default_max_threads() {
24+
return omp_get_max_threads();
25+
}
26+
2127
void teaser::ScalarTLSEstimator::estimate(const Eigen::RowVectorXd& X,
2228
const Eigen::RowVectorXd& ranges, double* estimate,
2329
Eigen::Matrix<bool, 1, Eigen::Dynamic>* inliers) {

test/teaser/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ endif ()
3535
# Executable for running unit tests
3636
add_executable(all_tests ${TEST_SRCS})
3737
target_link_libraries(all_tests ${TEST_LINK_LIBRARIES})
38+
target_include_directories(all_tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../teaser/src)
39+
40+
find_package(OpenMP)
41+
if(OpenMP_CXX_FOUND)
42+
target_link_libraries(all_tests OpenMP::OpenMP_CXX)
43+
endif()
3844

3945
gtest_add_tests(TARGET all_tests
4046
TEST_LIST allTests)

test/teaser/linalg-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <Eigen/Core>
1515

16-
#include "teaser/linalg.h"
16+
#include "linalg.h"
1717

1818
TEST(LinalgTest, HatMap) {
1919
{

0 commit comments

Comments
 (0)