Skip to content

Commit

Permalink
Poisson Surface Reconstruction (#1317)
Browse files Browse the repository at this point in the history
* Poisson Surface Reconstruction

* addressing CI warnings

* disable -Werror

* merge upstream

* remove poisson files to setup submodule

* PoissonRecon as submodule

* Merge remote-tracking branch 'upstream/master' into poisson

* fix and enable warning, and misc

* use /W3 without /WX for windows

* addressing review comments

* added method to remove low density vertices
  • Loading branch information
griegler authored and yxlao committed Nov 26, 2019
1 parent 990ff87 commit a7080f1
Show file tree
Hide file tree
Showing 15 changed files with 1,262 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -41,6 +41,7 @@ compile_commands.json
examples/Python/ReconstructionSystem/dataset/
examples/TestData/Armadillo.ply
examples/TestData/Bunny.ply
examples/TestData/eagle.ply
examples/TestData/voxelized.ply
examples/Python/Basic/voxel_grid_test.ply
examples/Python/Benchmark/testdata/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -28,3 +28,6 @@
[submodule "3rdparty/libjpeg-turbo/libjpeg-turbo"]
path = 3rdparty/libjpeg-turbo/libjpeg-turbo
url = https://github.com/libjpeg-turbo/libjpeg-turbo.git
[submodule "3rdparty/PoissonRecon/Open3D-PoissonRecon"]
path = 3rdparty/PoissonRecon
url = https://github.com/intel-isl/Open3D-PoissonRecon.git
5 changes: 5 additions & 0 deletions 3rdparty/CMakeLists.txt
Expand Up @@ -313,6 +313,10 @@ endif()
set(fmt_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/fmt/include)
INSTALL_HEADERS(fmt)

# PoissonRecon
set(poisson_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/)


list(APPEND 3RDPARTY_INCLUDE_DIRS
# ${dirent_INCLUDE_DIRS} # fails on Linux, seems to require Windows headers
${EIGEN3_INCLUDE_DIRS}
Expand All @@ -333,6 +337,7 @@ list(APPEND 3RDPARTY_INCLUDE_DIRS
${googletest_INCLUDE_DIRS}
${fmt_INCLUDE_DIRS}
${k4a_INCLUDE_DIRS}
${poisson_INCLUDE_DIRS}
)

# set 3RDPARTY_INCLUDE_DIRS_AT_INSTALL
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/PoissonRecon
Submodule PoissonRecon added at fd273e
4 changes: 4 additions & 0 deletions 3rdparty/README.txt
Expand Up @@ -72,3 +72,7 @@ https://github.com/syoyo/tinyobjloader
pybind11 2.2 BSD license
Python binding for C++11
https://github.com/pybind/pybind11
--------------------------------------------------------------------------------
PoissonReco 12.0 BSD license
Poisson Surface Reconstruction
https://github.com/mkazhdan/PoissonRecon
47 changes: 47 additions & 0 deletions examples/Python/Advanced/surface_reconstruction_poisson.py
@@ -0,0 +1,47 @@
# Open3D: www.open3d.org
# The MIT License (MIT)
# See license file or visit www.open3d.org for details

# examples/Python/Advanced/surface_reconstruction_poisson.py

import open3d as o3d
import numpy as np
import matplotlib.pyplot as plt
import os

import sys

sys.path.append(
os.path.join(os.path.dirname(os.path.realpath(__file__)), "../Misc"))
import meshes

if __name__ == "__main__":
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)

pcd = meshes.eagle()
print(pcd)
o3d.visualization.draw_geometries([pcd])

print('run Poisson surface reconstruction')
mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(
pcd, depth=8)
print(mesh)
o3d.visualization.draw_geometries([mesh])

print('visualize densities')
densities = np.asarray(densities)
density_colors = plt.get_cmap('plasma')(
(densities - densities.min()) / (densities.max() - densities.min()))
density_colors = density_colors[:, :3]
density_mesh = o3d.geometry.TriangleMesh()
density_mesh.vertices = mesh.vertices
density_mesh.triangles = mesh.triangles
density_mesh.triangle_normals = mesh.triangle_normals
density_mesh.vertex_colors = o3d.utility.Vector3dVector(density_colors)
o3d.visualization.draw_geometries([density_mesh])

print('remove low density vertices')
vertices_to_remove = densities < np.quantile(densities, 0.1)
mesh.remove_vertices_by_mask(vertices_to_remove)
print(mesh)
o3d.visualization.draw_geometries([mesh])
10 changes: 10 additions & 0 deletions examples/Python/Misc/meshes.py
Expand Up @@ -176,6 +176,16 @@ def bunny():
return mesh


def eagle():
path = _relative_path("../../TestData/eagle.ply")
if not os.path.exists(path):
print("downloading eagle pcl")
url = "http://www.cs.jhu.edu/~misha/Code/PoissonRecon/eagle.points.ply"
urllib.request.urlretrieve(url, path)
pcd = o3d.io.read_point_cloud(path)
return pcd


def center_and_scale(mesh):
vertices = np.asarray(mesh.vertices)
vertices = vertices / max(vertices.max(axis=0) - vertices.min(axis=0))
Expand Down
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
@@ -1,10 +1,10 @@
function(ShowAndAbortOnWarning trgt)
if(MSVC)
# target_compile_options(${trgt} PRIVATE /W4 /WX)
target_compile_options(${trgt} PRIVATE /W3)
# target_compile_options(${trgt} PRIVATE /W4 /WX)
target_compile_options(${trgt} PRIVATE /W3)
else()
# target_compile_options(${trgt} PRIVATE -Wall -Wextra -Werror)
target_compile_options(${trgt} PRIVATE -Wall -Werror)
# target_compile_options(${trgt} PRIVATE -Wall -Wextra -Werror)
target_compile_options(${trgt} PRIVATE -Wall -Werror)
endif()
endfunction()

Expand Down

0 comments on commit a7080f1

Please sign in to comment.