• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    C++
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python tool for obtaining watertight meshes using TSDF fusion.

Watertight and Simplified Meshes through TSDF Fusion

This repository contains a simply Python pipeline for obtaining watertight and simplified meshes from arbitrary triangular meshes, given in .off format. The approach is largely based on adapted versions of Gernot Riegler's pyrender and pyfusion; it also uses PyMCubes.

If you use any of this code, please make sure to cite the following work:

@article{Stutz2018ARXIV,
    author    = {David Stutz and Andreas Geiger},
    title     = {Learning 3D Shape Completion under Weak Supervision},
    journal   = {CoRR},
    volume    = {abs/1805.07290},
    year      = {2018},
    url       = {http://arxiv.org/abs/1805.07290},
}

See the GitHub repositories above for additional citations. Also check the corresponding project page.

The pipeline consists of three steps:

  1. Scaling using 1_scale.py, which scales the meshes into [-0.5,0.5]^3 with optional padding.
  2. Rendering and fusion using 2_fusion.py which in a first step renders views of each mesh, and uses these to peform TSDF fusion.
  3. Simplification using MeshLab.

The result is illustrated below; note that the shape gets slightly thicker and the axes change (due to marching cubes).

Example of watertight and simplified mesh.

Installation

Update: There are some minor changes necessary for newer MeshLab versions, see #15.

Update: For newer CUDA versions/GPU architectures, the CMAKE file in libfusiongpu needs to be adapted as outlined in this issue.

The pipeline is mostly self-contained, given a working installation of Python. Additionally, it requires MeshLab for simplification.

The used pyfusion library requires CMake and Cython; optionally it uses CUDA or OpenMP for efficiency. pyrender requires Cython, as well. Additionally, it requires OpenGL, GLUT and GLEW, see librender/setup.py for details. PyMCubes requires Cython. All three libraries are included in this repository.

For building follow (illustrated for the GPU version):

# build pyfusion
# use libfusioncpu alternatively!
cd libfusiongpu
mkdir build
cd build
cmake ..
make
cd ..
python setup.py build_ext --inplace

cd ..
# build pyrender
cd librender
python setup.py build_ext --inplace

cd ..
# build PyMCubes
cd libmcubes
python setup.py build_ext --inplace

Usage

Usage is illustrated on the shipped examples in examples/0_in taken from ModelNet.

First, scale the models using:

python 1_scale.py --in_dir=examples/0_in/ --out_dir=examples/1_scaled/

Now the models can be rendered, per default, 100 views (uniformly sampled on a sphere) will be used:

2_fusion.py --mode=render --in_dir=examples/1_scaled/ --depth_dir=examples/2_depth/ --out_dir=examples/2_watertight/

The details of rendering can be controlled using the following options:

--n_views N_VIEWS     Number of views per model.
--image_height IMAGE_HEIGHT
                      Depth image height.
--image_width IMAGE_WIDTH
                      Depth image width.
--focal_length_x FOCAL_LENGTH_X
                      Focal length in x direction.
--focal_length_y FOCAL_LENGTH_Y
                      Focal length in y direction.
--principal_point_x PRINCIPAL_POINT_X
                      Principal point location in x direction.
--principal_point_y PRINCIPAL_POINT_Y
                      Principal point location in y direction.
--depth_offset_factor DEPTH_OFFSET_FACTOR
                      The depth maps are offsetted using
                      depth_offset_factor*voxel_size.
--resolution RESOLUTION
                      Resolution for fusion.
--truncation_factor TRUNCATION_FACTOR
                      Truncation for fusion is derived as
                      truncation_factor*voxel_size.

During rendering, a small offset is added to the depth maps. This is particular important for meshes with thin details, as for example the provided chairs. Essentially, this thickens the structures. In the code, the offset is computed as

voxel_size = 1/resolution
offset = depth_offset_factor*voxel_size

Now, fusion can be run using

python 2_fusion.py --mode=fuse --in_dir=examples/1_scaled/ --depth_dir=examples/2_depth/ --out_dir=examples/2_watertight/

For fusion, the resolution and the truncation factor are most importance. In practice, the truncation factor may be in the range of [0, ..., 15]; then, the truncation threshold is computed as

voxel_size = 1/resolution
truncation = truncatioN_factor*voxel_size

Note that rendering and fusion is splitted as rendering might not work on all machines, especially remotely (e.g. through ssh) on machines without monitor.

Finally, simplification is performed using meshlabserver; make sure to have it installed and run

python 3_1_simplify.py --in_dir=examples/2_watertight/ --out_dir=examples/3_out/

The result of all steps is illustrated in the screenshot above.

Troubleshooting

``pyrender.so'' not found: For fixing OSError: /home/mona/mesh-fusion/librender/pyrender.so: cannot open shared object file: No such file or directory, see issue #10.

Compiling with new versions of Python/Cython: Follow issue #7.

Using with newer GPUs: See issue #13 for changes required to use the code with newer NVidia GPUS.

License

License for source code corresponding to:

D. Stutz, A. Geiger. Learning 3D Shape Completion under Weak Supervision. International Journal of Computer Vision (2018).

Note that the source code and/or data is based on the following projects for which separate licenses apply:

Copyright (c) 2018 David Stutz, Max-Planck-Gesellschaft

Please read carefully the following terms and conditions and any accompanying documentation before you download and/or use this software and associated documentation files (the "Software").

The authors hereby grant you a non-exclusive, non-transferable, free of charge right to copy, modify, merge, publish, distribute, and sublicense the Software for the sole purpose of performing non-commercial scientific research, non-commercial education, or non-commercial artistic projects.

Any other use, in particular any use for commercial purposes, is prohibited. This includes, without limitation, incorporation in a commercial product, use in a commercial service, or production of other artefacts for commercial purposes.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You understand and agree that the authors are under no obligation to provide either maintenance services, update services, notices of latent defects, or corrections of defects with regard to the Software. The authors nevertheless reserve the right to update, modify, or discontinue the Software at any time.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. You agree to cite the corresponding papers (see above) in documents and papers that report on research using the Software.

More Repositories

1

bootstrap-multiselect

JQuery multiselect plugin based on Twitter Bootstrap.
HTML
3,668
star
2

latex-resources

Collection of LaTeX resources and examples.
TeX
475
star
3

superpixel-benchmark

An extensive evaluation and comparison of 28 state-of-the-art superpixel algorithms on 5 datasets.
C++
352
star
4

mesh-voxelization

C++ implementation for computing occupancy grids and signed distance functions (SDFs) from watertight meshes.
C++
298
star
5

superpixels-revisited

Library containing 7 state-of-the-art superpixel algorithms with a total of 9 implementations used for evaluation purposes in [1] utilizing an extended version of the Berkeley Segmentation Benchmark.
C++
252
star
6

bootstrap-strength-meter

Password strength meter based on Twitter Bootstrap and Password Score.
HTML
83
star
7

caffe-tools

Some tools and examples for pyCaffe including LMDB I/O, custom Python layers and monitoring training error and loss.
Python
77
star
8

matlab-mnist-two-layer-perceptron

A two layer perceptron implemented in MatLab to recognize handwritten digits based on the MNIST dataset.
MATLAB
59
star
9

cvpr2018-shape-completion

CVPR 2018 paper "Learning 3D Shape Completion from Laser Scan Data with Weak Supervision".
TeX
59
star
10

password-score

Password scoring library written in Javascript.
JavaScript
56
star
11

pytorch-adversarial-examples-training-articles

PyTorch code corresponding to my blog series on adversarial examples and (confidence-calibrated) adversarial training.
Python
56
star
12

tensorflow-cpp-op-example

Simple example of implementing a new Tensorflow operation and its gradient in C++.
Python
55
star
13

bpy-visualization-utils

Blender/bpy utilities for paper-ready visualizations of meshes, point clouds and occupancy grids.
Python
55
star
14

seeds-revised

Implementation of the superpixel algorithm called SEEDS [1].
C++
52
star
15

mesh-evaluation

Efficient C++ implementation of mesh-to-mesh and mesh-to-point distance.
C++
43
star
16

disentangling-robustness-generalization

CVPR'19 experiments with (on-manifold) adversarial examples.
Python
40
star
17

graph-based-image-segmentation

Implementation of efficient graph-based image segmentation as proposed by Felzenswalb and Huttenlocher [1] that can be used to generate oversegmentations.
C++
40
star
18

extended-berkeley-segmentation-benchmark

Extended version of the Berkeley Segmentation Benchmark [1] used for evaluation in [2].
C++
39
star
19

confidence-calibrated-adversarial-training

Implementation of Confidence-Calibrated Adversarial Training (CCAT).
Python
38
star
20

grosse2009-intrinsic-images

Code from the MIT Intrinsic Images Dataset [1]; Including command line tool for Retinex algorithm.
Python
25
star
21

googlemock-example

An example of using Google Mock inspired by Martin Fowler's "Mocks Aren't Stubs".
C++
25
star
22

hierarchical-graph-based-video-segmentation

Implementation of the hierarchical graph-based video segmentation algorithm proposed by Grundmann et al. [1] based on the image segmentation algorithm by Felzenswalb and Huttenlocher [2].
C++
23
star
23

nyu-depth-v2-tools

Tools used in [2] to pre-process the ground truth segmentations to evaluate superpixel algorithms.
MATLAB
22
star
24

flow-io-opencv

Fork and OpenCV wrapper of the optical flow I/O and visualization code provided as part of the Sintel dataset [1].
C++
20
star
25

daml-shape-completion

CVPR'18 implementation of (deterministic) amortized maximum likelihood (AML) for weakly-supervised shape completion.
C++
20
star
26

sphinx-example

Example and cheat sheet for the Sphinx Python documentation generator.
Python
18
star
27

pointnet-auto-encoder

Torch PointNet auto encoder implementation.
C++
17
star
28

ijcv2018-improved-shape-completion

ArXiv'18 pre-print "Learning 3D Shape Completion under Weak Supervision".
TeX
15
star
29

robust-generalization-flatness

Implementation of average- and worst-case robust flatness measures for adversarial training.
Python
14
star
30

arxiv-submission-sanitizer-flattener

Simple Python scripts to clean up and flatten ArXiv LaTeX submissions.
Python
14
star
31

pytorch-custom-c-cuda-operations

Example of easily implementing custom tensor operations in C and CUDA.
Python
13
star
32

ipiano

Implementation of the iPiano algorithm for non-convex and non-smooth optimization as described in [1].
C++
13
star
33

opencv-2.4-cuda-9-patch

This is a quick patch for compiling OpenCV 2.4.x with CUDA 9.
CMake
13
star
34

cvpr2019-adversarial-robustness

CVPR 2019 paper "Disentangling Adversarial Robustness and Generalization".
TeX
13
star
35

kohana-hooks

Event module for Kohana.
PHP
12
star
36

seminar-convolutional-neural-networks

Seminar paper "Understanding Convolutional Neural Networks".
TeX
12
star
37

probabilistic-pca

Python probabilistic PCA (PPCA) implementation.
Python
11
star
38

bachelor-thesis-superpixels

Bachelor thesis "Superpixel Segmentation using Depth Information", including a thorough comparison of several state-of-the-art superpixel algorithms.
TeX
11
star
39

aml-improved-shape-completion

ArXiv'18 implementation of amortized maximum likelihood (AML) for high-quality, weakly-supervised shape completion.
C++
10
star
40

vlfeat-slic-example

Example of using VLFeat's SLIC implementation from C++.
C++
10
star
41

icml2020-confidence-calibrated-adversarial-training

ICML'20 paper "Confidence-Calibrated Adversarial Training: Generalizing to Unseen Attacks".
TeX
9
star
42

vedaldi2006-siftpp

Fork of SIFT++, a lightweight C++ implementation of the SIFT detector and descriptor.
C++
9
star
43

torch-examples

Collection of Torch examples for deep learning.
Lua
7
star
44

mathematical-image-processing

Implementations and examples of basic mathematical image processing algorithms. Based on the lectures "Mathematical Foundations of Image Processing" and "Variational Methods in Image Processing" by Prof. Berkels.
MATLAB
6
star
45

php-simplex

PHP library implementing the simplex algorithm.
PHP
5
star
46

jasmine-travis-example

Example for continuous integration with Jasmine, GitHub and Travis CI.
JavaScript
5
star
47

php-matrix-decompositions-demonstration

Demonstration of common matrix decompositions in PHP.
PHP
5
star
48

master-thesis-shape-completion

Master thesis "Learning 3D Shape Completion from Bounding Boxes using CAD Shape Priors".
TeX
5
star
49

iccv2021-robust-flatness

ICCV'21 paper "Relating Adversarially Robust Generalization to Flat Minima".
PostScript
5
star
50

banic2012-color-constancy

Fork of the Light Random Spray Retinex Algorithm as discussed in [1].
C++
5
star
51

jquery-pseudocode

Lightweight jQuery plugin to display algorithms similar to LaTeX pseudocode and algorithm packages.
HTML
5
star
52

functional-dependencies

Small demo application for calculating candidate keys of a given relational database schema.
PHP
5
star
53

d3-topological

Topological sort using d3.js.
JavaScript
4
star
54

wordpress-iamdavidstutz

Wordpress theme of my personal webpage.
JavaScript
4
star
55

random-bit-error-robustness

Implementation of robust quantization, weight clipping and random bit error training to improve robustness against bit errors in quantized weights.
Python
4
star
56

superpixel-benchmark-data

Converted datasets for davidstutz/superpixel-benchmark.
4
star
57

php-matrix-decompositions

PHP Library including several common matrix decompositions: LU, QR and Cholesky.
PHP
3
star
58

kohana-red

Kohana authentication module based on Kohana's ORM and Database module.
PHP
3
star
59

cmsimple-pictures

CMSimple plugin for creating different kinds of sliders and galleries.
PHP
3
star
60

gcpr2015-superpixels

GCPR 2015 paper and poster "Superpixel Segmentation: An Evaluation".
TeX
3
star
61

seminar-cnn-image-retrieval

Seminar paper "Neural Codes for Image Retreival".
TeX
3
star
62

kohana-navigation

Navigation generation module for Kohana.
PHP
3
star
63

davidstutz

Personal README.
2
star
64

cmsimple-iamdavidstutz

CMSimple theme of my personal webpage.
CSS
2
star
65

kohana-green

Kohana Access Control List implementation based on Kohana's Red module.
PHP
2
star
66

wordpress-github

Wordpress GitHub plugin.
PHP
2
star
67

cmsimple-news

CMSimple plugin for managing and publishing news.
PHP
2
star
68

matlab-multi-label-connected-components

MEX wrapper for Ali Rahimi's multi-label connected components implementation in C++.
C++
2
star
69

kohana-gaps

Kohana form creation module based on ORM models.
PHP
2
star
70

seminar-neural-networks

Seminar paper "Introduction to Neural Networks".
TeX
2
star
71

project-social-network-analysis-stackexchange

Project of "Social Network Analysis" MOOC by the University of Michigan on analyzing StackExchange sites.
PHP
2
star
72

seminar-ipiano

Seminar paper "iPiano: Inertial Proximal Algorithm for Non-Convex Optimization".
TeX
2
star
73

superpixel-benchmark-nvd3

Interactive plots of results from the superpixel benchmark davidstutz/superpixel-benchmark using NVD3.
JavaScript
2
star
74

nvd3-superpixel-comparison

Interactive compariosn of superpixel algorithms as presented in the bachelor thesis "Superpixel Segmentation using Depth Information" [1].
JavaScript
2
star
75

proseminar-dart

RWTH Aachen University Proseminar 2012 Chair for Data Management and Data Exploration: Dart - A Brief Introduction
TeX
2
star
76

tensorflow-mnist-experiments

CADL course project: different architectures implemented in TensorFlow and tested on MNIST.
Python
1
star
77

cmsimple-youtube

CMSimple plugin for creating youtube video galleries.
PHP
1
star
78

kohana-yellow

Yellow is a logging module for the Kohana Green module based on Green and Red.
PHP
1
star
79

pytorch-pgd-adversarial-examples

PyTorch implementation of projected gradient descent (PGD) to generate L_p adversarial examples.
1
star
80

pytorch-adversarial-robustness-articles

Code corresponding to a series of blog articles on adversarial robustness at davidstutz.de.
1
star
81

pytorch-tensorboard-monitoring

PyTorch example for using TensorBoard logging in a plug-and-play fashion.
1
star
82

cmsimple-bootstrap

A simple CMSimple theme based on Twitter Bootstrap.
CSS
1
star
83

cmsimple-bbclone

BBClone plugin for CMSimple.
PHP
1
star
84

cmsimple-elfinder

CMSimple elFinder filebrowser.
JavaScript
1
star
85

pytorch-loading-models

PyTorch example for loading models without initializing their architectures first.
1
star
86

pytorch-cifar10-autoaugment-cutout

PyTorch Code for getting 2.56% test error on CIFAR-10 using AugoAugment and CutOut.
1
star
87

kohana-media

Simple media/assets module for Kohana.
PHP
1
star
88

jquery-references

Naive jQuery plugin to allow referencing figures, listings, algorithms and references in a BibTex-like style.
HTML
1
star
89

kohana-blue

Blue is a user configuration module based on Kohana's Red module.
PHP
1
star