Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
Language: Cpp
Language: Cpp
ColumnLimit: 100
DerivePointerAlignment: false
PointerAlignment: Left
SortIncludes: false
InsertNewlineAtEOF: true
...
41 changes: 16 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
name: build
on:
name: build

on:
push:
branches:
branches:
- master
pull_request:
branches:
- master

jobs:

build-debug:
name: CMake Debug Build
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4
- name: install-dependencies
- uses: actions/checkout@v2
- name: install-eigen
run: sudo apt install libeigen3-dev
- name: configure
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug ..
- name: build
run: cmake --build build

build-release:
name: CMake Release Build
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4
- name: install-dependencies
- uses: actions/checkout@v2
- name: install-eigen
run: sudo apt install libeigen3-dev
- name: configure
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ..
- name: build
run: cmake --build build
- name: test
run: cd build && ctest all
python:
name: Python Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup-python
uses: actions/setup-python@v5
with: {python-version: '3.x'}
- name: install-dependencies
run: sudo apt install libeigen3-dev
- name: upgrade-pip
run: python -m pip install --upgrade pip
- name: build
run: python -m pip install ${{github.workspace}}
- name: test
run: python -c "import teaserpp_python; print('☺')"

64 changes: 56 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.10)
project(teaserpp VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 14)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Check build types
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand All @@ -13,16 +12,11 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
STRING "Choose the type of build." FORCE)
endif ()

if (DEFINED SKBUILD)
message(STATUS "Building with Scikit-Build")
endif ()

# Options
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_TEASER_FPFH "Build TEASER++ wrappers for PCL FPFH estimation." OFF)
option(BUILD_MATLAB_BINDINGS "Build MATLAB bindings" OFF)
option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
option(BUILD_PYTHON_BINDINGS "Build Python bindings" ON)
option(BUILD_DOC "Build documentation" ON)
option(BUILD_WITH_MARCH_NATIVE "Build with flag march=native" OFF)
option(ENABLE_MKL "Try to use Eigen with MKL" OFF)
Expand All @@ -33,6 +27,11 @@ if (ENABLE_DIAGNOSTIC_PRINT)
add_definitions(-DTEASER_DIAG_PRINT)
endif ()

# Cache Variables
if (NOT TEASERPP_PYTHON_VERSION)
set(TEASERPP_PYTHON_VERSION "" CACHE STRING "Python version to use for TEASER++ bindings.")
endif ()

# Find dependencies
# Eigen3
find_package(Eigen3 3.2 QUIET REQUIRED NO_MODULE)
Expand Down Expand Up @@ -74,6 +73,44 @@ if (BUILD_TEASER_FPFH)
endif()
endif ()

# googletest
configure_file(cmake/GoogleTest.CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download")
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src"
"${CMAKE_BINARY_DIR}/googletest-build" EXCLUDE_FROM_ALL)

# pmc (Parallel Maximum Clique)
configure_file(cmake/pmc.CMakeLists.txt.in pmc-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pmc-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pmc-download")
add_subdirectory("${CMAKE_BINARY_DIR}/pmc-src"
"${CMAKE_BINARY_DIR}/pmc-build")

# tinyply
configure_file(cmake/tinyply.CMakeLists.txt.in tinyply-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/tinyply-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/tinyply-download")
add_subdirectory("${CMAKE_BINARY_DIR}/tinyply-src"
"${CMAKE_BINARY_DIR}/tinyply-build")
target_include_directories(tinyply PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/tinyply-src/source>)

# spectra
configure_file(cmake/spectra.CMakeLists.txt.in spectra-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/spectra-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/spectra-download")
set(SPECTRA_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/spectra-src/include")

# Building Targets
set(TEASERPP_ROOT ${CMAKE_CURRENT_LIST_DIR})
add_subdirectory(teaser)
Expand All @@ -93,6 +130,17 @@ if (BUILD_MATLAB_BINDINGS)
endif ()

if (BUILD_PYTHON_BINDINGS)
set(PYBIND11_PYTHON_VERSION ${TEASERPP_PYTHON_VERSION})

# download the pybind11 repo
configure_file(cmake/pybind11.CMakeLists.txt.in pybind11-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pybind11-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/pybind11-download")
add_subdirectory("${CMAKE_BINARY_DIR}/pybind11-src"
"${CMAKE_BINARY_DIR}/pybind11-build")

message(STATUS "TEASER++ Python binding will be built.")
add_subdirectory(python)
endif ()
Expand Down
14 changes: 14 additions & 0 deletions cmake/GoogleTest.CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.10)

project(googletest-download NONE)

include(ExternalProject)
ExternalProject_Add(googletest
URL https://github.com/google/googletest/archive/release-1.8.1.zip
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
15 changes: 15 additions & 0 deletions cmake/pmc.CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)

project(pmc-download NONE)

include(ExternalProject)
# Notice that this project uses a forked version of PMC with minor fixes & changes
ExternalProject_Add(pmc
GIT_REPOSITORY https://github.com/jingnanshi/pmc.git
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pmc-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/pmc-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
4 changes: 2 additions & 2 deletions cmake/pybind11.CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ project(pybind11-download NONE)
include(ExternalProject)
ExternalProject_Add(pmc
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.13.6
GIT_TAG v2.11.1
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pybind11-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/pybind11-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
)
15 changes: 15 additions & 0 deletions cmake/spectra.CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)

project(spectra-download NONE)

include(ExternalProject)
ExternalProject_Add(spectral
GIT_REPOSITORY https://github.com/jingnanshi/spectra
GIT_TAG 5c4fb1de050847988faaaaa50f60e7d3d5f16143
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/spectra-src"
BINARY_DIR ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
15 changes: 15 additions & 0 deletions cmake/tinyply.CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)

project(tinyply-download NONE)

include(ExternalProject)
ExternalProject_Add(pmc
GIT_REPOSITORY https://github.com/jingnanshi/tinyply.git
GIT_TAG 0b9fff8e8bd4d37256554fe40cf76b2f3134377b
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/tinyply-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/tinyply-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
10 changes: 5 additions & 5 deletions examples/teaser_cpp_fpfh/quatro_cpp_fpfh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ inline double getAngularError(Eigen::Matrix3d R_exp, Eigen::Matrix3d R_est) {
return std::abs(std::acos(fmin(fmax(((R_exp.transpose() * R_est).trace() - 1) / 2, -1.0), 1.0)));
}

inline void calcErrors(const Eigen::Matrix4d& T, const Eigen::Matrix3d est_rot,
const Eigen::Vector3d est_ts, double& rot_error, double& ts_error) {
inline void calcErrors(const Eigen::Matrix4d& T, const Eigen::Matrix3d est_rot, const Eigen::Vector3d est_ts,
double &rot_error, double& ts_error) {
rot_error = getAngularError(T.topLeftCorner(3, 3), est_rot);
ts_error = (T.topRightCorner(3, 1) - est_ts).norm();
}
Expand All @@ -32,11 +32,11 @@ inline void getParams(const double noise_bound, const std::string reg_type,
if (reg_type == "Quatro") {
params.rotation_estimation_algorithm =
teaser::RobustRegistrationSolver::ROTATION_ESTIMATION_ALGORITHM::QUATRO;
params.inlier_selection_mode = teaser::RobustRegistrationSolver::INLIER_SELECTION_MODE::PMC_HEU;
} else if (reg_type == "TEASER") {
params.inlier_selection_mode == teaser::RobustRegistrationSolver::INLIER_SELECTION_MODE::PMC_HEU;
} else if (reg_type == "TEASER") {
params.rotation_estimation_algorithm =
teaser::RobustRegistrationSolver::ROTATION_ESTIMATION_ALGORITHM::GNC_TLS;
params.inlier_selection_mode = teaser::RobustRegistrationSolver::INLIER_SELECTION_MODE::PMC_EXACT;
params.inlier_selection_mode == teaser::RobustRegistrationSolver::INLIER_SELECTION_MODE::PMC_EXACT;
} else {
throw std::invalid_argument("Not implemented!");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/teaser_cpp_ply/teaser_cpp_ply.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ int main() {
<< std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count() /
1000000.0
<< std::endl;
}
}
2 changes: 1 addition & 1 deletion examples/teaser_python_3dsmooth/teaser_python_3dsmooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def visualize_correspondences(
frag2_temp.translate(translate)

# estimate normals
vis_list = [target, source, frag1_temp, frag2_temp]
vis_list = [target, source, frag1_temp, frag2_temp];
for ii in vis_list:
ii.estimate_normals()
vis_list.extend([*inlier_line_mesh_geoms, *outlier_line_mesh_geoms])
Expand Down
45 changes: 34 additions & 11 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
find_package(pybind11 REQUIRED)
cmake_minimum_required(VERSION 3.10)

project(teaser_python_bindings)

pybind11_add_module(teaserpp_python teaserpp_python/teaserpp_python.cc)

message(STATUS "Python Interpreter Version: ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
if (NOT (PYTHON_VERSION_MAJOR EQUAL 2 AND PYTHON_VERSION_MINOR EQUAL 7))
# Hack: VTK used in PCL might add /usr/include/python2.7 to all targets'
# INCLUDE_DIRECTORIES properties. We need to remove it.
get_target_property(TEASERPY_NEW_INCLUDE_DIRS teaserpp_python INTERFACE_INCLUDE_DIRECTORIES)
list(FILTER TEASERPY_NEW_INCLUDE_DIRS EXCLUDE REGEX ".*python2.7$")
set_target_properties(teaserpp_python
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${TEASERPY_NEW_INCLUDE_DIRS}")
endif ()

target_link_libraries(teaserpp_python PUBLIC teaser_registration)

# fix for clang
# see: https://github.com/pybind/pybind11/issues/1818
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(teaserpp_python PUBLIC -fno-sized-deallocation)
target_compile_options(teaserpp_python PUBLIC -fno-sized-deallocation)
endif ()

# make sure to output the build file to teaserpp_python folder
SET_TARGET_PROPERTIES(teaserpp_python
PROPERTIES
OUTPUT_NAME "_teaserpp"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python"
)

if (DEFINED SKBUILD)
install(TARGETS teaserpp_python DESTINATION "../teaserpp_python")
endif ()
PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python"
)

# copy package __init__.py file
configure_file(teaserpp_python/__init__.py
${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python/__init__.py
)

# copy setup.py file
configure_file(setup.py.in
${CMAKE_CURRENT_BINARY_DIR}/setup.py
)

file(COPY .
DESTINATION .
FILES_MATCHING
PATTERN *.py)
12 changes: 12 additions & 0 deletions python/setup.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup

setup(
name='teaserpp_python',
version='1.0.0',
author='Jingnan Shi',
author_email='jnshi@mit.edu',
description='Python binding for TEASER++',
package_dir={'': '${CMAKE_CURRENT_BINARY_DIR}'},
packages=['teaserpp_python'],
package_data={'': ['*.so']}
)
Loading