Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Documentation - Fix code links and improve tutorial layout #6321

Merged
merged 33 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bf4509e
Correct code tagging in interactive_visualization tutorial.
saurabheights Aug 17, 2023
6fe1f9e
Highlight the methods that are being introduced at the start.
saurabheights Aug 17, 2023
dfd76a7
Non-Blocking VIZ - Add add_geometry step which is not optional.
saurabheights Aug 18, 2023
efabadf
Non-Blocking VIZ - Split main code to simpler function and fix code b…
saurabheights Aug 18, 2023
a4ea39e
Fix Typos
saurabheights Aug 18, 2023
3a9da1f
Update docs with new argument values.
saurabheights Aug 18, 2023
9fc5a68
Fix grammar and dedent for overly indented code
saurabheights Aug 18, 2023
4f88a16
Integrate_Custom - Optimize imports, add early return, use f-strings …
saurabheights Aug 18, 2023
91778f2
Fix default value and remove BooleanOptionalAction, its only availabl…
saurabheights Aug 18, 2023
de4f46a
Disable use of cuda for tensor based reconstruction
saurabheights Aug 18, 2023
e968505
Customized Integration - Fix code lines
saurabheights Aug 18, 2023
ee7b6ae
Ray Casting - Fix code lines
saurabheights Aug 18, 2023
5ba3035
Dense Slam - Fix code lines and slight grammar.
saurabheights Aug 18, 2023
e1ed485
Fix some f-strings and extra parantheses
saurabheights Aug 18, 2023
8295331
Make Fragments - Fix code lines
saurabheights Aug 18, 2023
d65fb67
Code for batch processing was removed long back in #521 in 2018
saurabheights Aug 18, 2023
776bb99
Register Fragments - Fix code docs
saurabheights Aug 18, 2023
9ae5d23
Register fragments - Fix code lines
saurabheights Aug 18, 2023
9f405b3
Integrate Scene - Fix code lines
saurabheights Aug 18, 2023
0724b5a
Change layout of tutorials - only done at top level.
saurabheights Aug 18, 2023
22de7e3
Add new lines before bullet/numbered list, else list rendering fails.
saurabheights Aug 18, 2023
2f9d0c2
Bugfix - Fix code lines for Integration and add filename as done in v…
saurabheights Aug 28, 2023
a522ed8
Remove python version 3.6 as supported versions by open3d.
saurabheights Aug 28, 2023
fc04d88
Fix line number using lineno-match directive.
saurabheights Aug 30, 2023
cd5cc98
Fix some typos detected automatically.
saurabheights Aug 30, 2023
0f2439d
Replace prepend with lineno-match
saurabheights Aug 30, 2023
80427df
Correct filename documented in the files
saurabheights Aug 31, 2023
9c2840e
Fix lineno-start.
saurabheights Aug 31, 2023
43ededc
Merge branch 'master' into khanduja/fix_docs_2
ssheorey Sep 13, 2023
3f10bb3
Fix PR comments
saurabheights Sep 16, 2023
3a0a6e9
Revert "Code for batch processing was removed long back in #521 in 2018"
saurabheights Sep 17, 2023
a5b5aff
Correct batch processing section documentation and native multiproces…
saurabheights Sep 20, 2023
3d345e6
Use native multiprocessing for register fragments and refinement of r…
saurabheights Sep 22, 2023
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
4 changes: 2 additions & 2 deletions docs/tutorial/reconstruction_system/system_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Getting the example code

.. code-block:: sh

# Activate your conda enviroment, where you have installed open3d pip package.
# Activate your conda environment, where you have installed open3d pip package.
# Clone the Open3D github repository and go to the example.
cd examples/python/reconstruction_system/

Expand All @@ -69,7 +69,7 @@ Running the example with default dataset.
python run_system.py --make --register --refine --integrate

Changing the default dataset.
One may change the default dataset to other avaialble datasets.
One may change the default dataset to other available datasets.
saurabheights marked this conversation as resolved.
Show resolved Hide resolved
Currently the following datasets are available:

1. Lounge (keyword: ``lounge``) (Default)
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial/t_reconstruction_system/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Getting the example code

.. code-block:: sh

# Activate your conda enviroment, where you have installed open3d pip package.
# Activate your conda environment, where you have installed open3d pip package.
# Clone the Open3D github repository and go to the example.
cd examples/python/t_reconstruction_system/

Expand All @@ -40,7 +40,7 @@ Running the example with default dataset.
# which is ``lounge`` dataset from stanford.
python dense_slam_gui.py

It is recommended to use CUDA if avaialble.
It is recommended to use CUDA if available.

.. code-block:: sh

Expand All @@ -49,7 +49,7 @@ It is recommended to use CUDA if avaialble.
python dense_slam_gui.py --device 'cuda:0'

Changing the default dataset.
One may change the default dataset to other avaialble datasets.
One may change the default dataset to other available datasets.
Currently the following datasets are available:

1. Lounge (keyword: ``lounge``) (Default)
Expand Down
18 changes: 9 additions & 9 deletions docs/tutorial/t_reconstruction_system/voxel_block_grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ A voxel block grid can be constructed by:

.. literalinclude:: ../../../examples/python/t_reconstruction_system/integrate.py
:language: python
:lineno-start: 56
:lines: 27,57-74
:lineno-start: 27
:lines: 8,28-45

In this example, the multi-value hash map has key shape shape ``(3,)`` and dtype ``int32``. The hash map values are organized as a structure of array (SoA). The hash map values include:
In this example, the multi-value hash map has key of shape ``(3,)`` and dtype ``float32``. The hash map values are organized as a structure of array (SoA). The hash map values include:

By default it contains:

- Truncated Signed Distance Function (TSDF) of element shape ``(8, 8, 8, 1)``
- Weight of element shape ``(8, 8, 8, 1)``
- (Optionally) RGB color of element shape ``(8, 8, 8, 3)``
- Truncated Signed Distance Function (TSDF) of element shape ``(16, 16, 16, 1)``
- Weight of element shape ``(16, 16, 16, 1)``
- (Optionally) RGB color of element shape ``(16, 16, 16, 3)``

where ``8`` stands for the local voxel block grid resolution.
where ``16`` stands for the local voxel block grid resolution.

By convention, we use ``3.0 / 512`` as the voxel resolution. This spatial resolution is equivalent to representing a ``3m x 3m x 3m`` (m = meter) room with a dense ``512 x 512 x 512`` voxel grid.

The voxel block grid is optimized to run fast on GPU. On CPU the it runs slower. Empirically, we reserve ``100000`` such blocks for a living room-scale scene to avoid frequent rehashing.
The voxel block grid is optimized to run fast on GPU. On CPU, it runs slower. Empirically, we reserve ``50000`` such blocks for a living room-scale scene to avoid frequent rehashing.

You can always customize your own properties, e.g., ``intensity`` of element shape ``(8, 8, 8, 1)`` in ``float32``, ``label`` of element shape ``(8, 8, 8, 1)`` in ``int32``, etc. To know how to process the data, please refer to :ref:`customized_integration`.
You can always customize your own properties, e.g., ``intensity`` of element shape ``(16, 16, 16, 1)`` in ``float32``, ``label`` of element shape ``(16, 16, 16, 1)`` in ``int32``, etc. To know how to process the data, please refer to :ref:`customized_integration`.
saurabheights marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion docs/tutorial/visualization/cpu_rendering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Here are the different ways to do that:

# In Python code
import os
os.environ['EGL_PLATFORM'] = 'surfaceless' # Ubunu 20.04+
os.environ['EGL_PLATFORM'] = 'surfaceless' # Ubuntu 20.04+
os.environ['OPEN3D_CPU_RENDERING'] = 'true' # Ubuntu 18.04
import open3d as o3d

Expand Down
31 changes: 16 additions & 15 deletions docs/tutorial/visualization/interactive_visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
Interactive visualization
-------------------------------------

This tutorial introduces user interaction features of the visualizer window.
This tutorial introduces user interaction features of the visualizer window provided by:-

#. ``open3d.visualization.draw_geometries_with_editing``
#. ``open3d.visualization.VisualizerWithEditing``

.. literalinclude:: ../../../examples/python/visualization/interactive_visualization.py
:language: python
:lineno-start: 27
:lines: 27-
:start-at: # examples/python/visualization/interactive_visualization.py
:linenos:

This script executes two applications of user interaction: ``demo_crop_geometry`` and ``demo_manual_registration``.
Expand All @@ -20,8 +22,7 @@ Crop geometry

.. literalinclude:: ../../../examples/python/visualization/interactive_visualization.py
:language: python
:lineno-start: 37
:lines: 37-51
:pyobject: demo_crop_geometry
:linenos:

This function simply reads a point cloud and calls ``draw_geometries_with_editing``. This function provides vertex selection and cropping.
Expand Down Expand Up @@ -58,26 +59,27 @@ To finish selection mode, press ``F`` to switch to freeview mode.
Manual registration
`````````````````````````````````````````````

Select correspondences
=====================================

The following script registers two point clouds using point-to-point ICP. It gets initial alignment via user interaction.

Prepare data
=====================================

.. literalinclude:: ../../../examples/python/visualization/interactive_visualization.py
:language: python
:lineno-start: 61
:lines: 61-76
:pyobject: prepare_data
:linenos:

The script reads two point clouds, and visualizes the point clouds before alignment.
This function reads two point clouds, and visualizes the point clouds before performing manual alignment.

.. image:: ../../_static/visualization/interactive_visualization/manual_icp_initial.png
:width: 400px

Select correspondences
=====================================

.. literalinclude:: ../../../examples/python/visualization/interactive_visualization.py
:language: python
:lineno-start: 52
:lines: 52-60
:pyobject: pick_points
:linenos:

The function ``pick_points(pcd)`` makes an instance of ``VisualizerWithEditing``. To mimic ``draw_geometries``, it creates windows, adds the geometry, visualizes the geometry, and then terminates. A novel interface function from ``VisualizerWithEditing`` is ``get_picked_points()`` that returns the indices of user-picked vertices.
Expand Down Expand Up @@ -115,8 +117,7 @@ Registration using user correspondences

.. literalinclude:: ../../../examples/python/visualization/interactive_visualization.py
:language: python
:lineno-start: 77
:lines: 77-110
:pyobject: register_via_correspondences
:linenos:

The later part of the demo computes an initial transformation based on the user-provided correspondences. This script builds pairs of correspondences using ``Vector2iVector(corr)``. It utilizes ``TransformationEstimationPointToPoint.compute_transformation`` to compute the initial transformation from the correspondences. The initial transformation is refined using ``registration_icp``.
Expand Down
17 changes: 9 additions & 8 deletions docs/tutorial/visualization/non_blocking_visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This rendering loop can be readily customized. For example, a custom loop can be

vis = Visualizer()
vis.create_window()
vis.add_geometry(geometry)
for i in range(icp_iteration):
# do ICP single iteration
# transform geometry using ICP
Expand All @@ -39,8 +40,7 @@ The full script implementing this idea is displayed below.

.. literalinclude:: ../../../examples/python/visualization/non_blocking_visualization.py
:language: python
:lineno-start: 27
:lines: 27-
:start-at: # examples/python/visualization/non_blocking_visualization.py
:linenos:

The following sections explain this script.
Expand All @@ -50,8 +50,7 @@ Prepare example data

.. literalinclude:: ../../../examples/python/visualization/non_blocking_visualization.py
:language: python
:lineno-start: 35
:lines: 35-46
:pyobject: prepare_data
:linenos:

This part reads two point clouds and downsamples them. The source point cloud is intentionally transformed for the misalignment. Both point clouds are flipped for better visualization.
Expand All @@ -61,9 +60,10 @@ Initialize Visualizer class

.. literalinclude:: ../../../examples/python/visualization/non_blocking_visualization.py
:language: python
:lineno-start: 47
:lines: 47-59
:start-after: def demo_non_blocking_visualization():
:linenos:
:lineno-start: 30
:lines: 3-7

These lines make an instance of the visualizer class, open a visualizer window, and add two geometries to the visualizer.

Expand All @@ -72,9 +72,10 @@ Transform geometry and visualize it

.. literalinclude:: ../../../examples/python/visualization/non_blocking_visualization.py
:language: python
:lineno-start: 59
:lines: 59-72
:start-after: def demo_non_blocking_visualization():
:linenos:
:lineno-start: 30
:lines: 8-23

This script calls ``registration_icp`` for every iteration. Note that it explicitly forces only one ICP iteration via ``ICPConvergenceCriteria(max_iteration = 1)``. This is a trick to retrieve a slight pose update from a single ICP iteration. After ICP, source geometry is transformed accordingly.

Expand Down
43 changes: 25 additions & 18 deletions examples/python/visualization/interactive_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ def draw_registration_result(source, target, transformation):
o3d.visualization.draw_geometries([source_temp, target_temp])


def prepare_data():
pcd_data = o3d.data.DemoICPPointClouds()
source = o3d.io.read_point_cloud(pcd_data.paths[0])
target = o3d.io.read_point_cloud(pcd_data.paths[2])
print("Visualization of two point clouds before manual alignment")
draw_registration_result(source, target, np.identity(4))
return source, target


def pick_points(pcd):
print("")
print(
Expand All @@ -53,36 +62,34 @@ def pick_points(pcd):
return vis.get_picked_points()


def demo_manual_registration():
print("Demo for manual ICP")
pcd_data = o3d.data.DemoICPPointClouds()
source = o3d.io.read_point_cloud(pcd_data.paths[0])
target = o3d.io.read_point_cloud(pcd_data.paths[2])
print("Visualization of two point clouds before manual alignment")
draw_registration_result(source, target, np.identity(4))

# pick points from two point clouds and builds correspondences
picked_id_source = pick_points(source)
picked_id_target = pick_points(target)
assert (len(picked_id_source) >= 3 and len(picked_id_target) >= 3)
assert (len(picked_id_source) == len(picked_id_target))
corr = np.zeros((len(picked_id_source), 2))
corr[:, 0] = picked_id_source
corr[:, 1] = picked_id_target

def register_via_correspondences(source, target, source_points, target_points):
corr = np.zeros((len(source_points), 2))
corr[:, 0] = source_points
corr[:, 1] = target_points
# estimate rough transformation using correspondences
print("Compute a rough transform using the correspondences given by user")
p2p = o3d.pipelines.registration.TransformationEstimationPointToPoint()
trans_init = p2p.compute_transformation(source, target,
o3d.utility.Vector2iVector(corr))

# point-to-point ICP for refinement
print("Perform point-to-point ICP refinement")
threshold = 0.03 # 3cm distance threshold
reg_p2p = o3d.pipelines.registration.registration_icp(
source, target, threshold, trans_init,
o3d.pipelines.registration.TransformationEstimationPointToPoint())
draw_registration_result(source, target, reg_p2p.transformation)


def demo_manual_registration():
print("Demo for manual ICP")
source, target = prepare_data()

# pick points from two point clouds and builds correspondences
source_points = pick_points(source)
target_points = pick_points(target)
assert (len(source_points) >= 3 and len(target_points) >= 3)
assert (len(source_points) == len(target_points))
register_via_correspondences(source, target, source_points, target_points)
print("")


Expand Down
18 changes: 14 additions & 4 deletions examples/python/visualization/non_blocking_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@
import open3d as o3d
import numpy as np

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

def prepare_data():
pcd_data = o3d.data.DemoICPPointClouds()
source_raw = o3d.io.read_point_cloud(pcd_data.paths[0])
target_raw = o3d.io.read_point_cloud(pcd_data.paths[1])

source = source_raw.voxel_down_sample(voxel_size=0.02)
target = target_raw.voxel_down_sample(voxel_size=0.02)

trans = [[0.862, 0.011, -0.507, 0.0], [-0.139, 0.967, -0.215, 0.7],
[0.487, 0.255, 0.835, -1.4], [0.0, 0.0, 0.0, 1.0]]
source.transform(trans)

flip_transform = [[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]
source.transform(flip_transform)
target.transform(flip_transform)
return source, target


def demo_non_blocking_visualization():
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)

source, target = prepare_data()
vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(source)
Expand All @@ -46,4 +51,9 @@
if save_image:
vis.capture_screen_image("temp_%04d.jpg" % i)
vis.destroy_window()

o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Info)


if __name__ == '__main__':
demo_non_blocking_visualization()