Skip to content

Commit

Permalink
TB plugin demo and docs (isl-org#4285)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey authored Nov 23, 2021
1 parent 699c4fa commit b387122
Show file tree
Hide file tree
Showing 19 changed files with 545 additions and 296 deletions.
3 changes: 3 additions & 0 deletions cpp/pybind/visualization/visualization.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ std::shared_ptr<T> TakeOwnership(UnownedPointer<T> x) {
return std::shared_ptr<T>(x.get());
}

// Please update docs/python_api_in/open3d.visualization.rst when adding /
// reorganizing submodules to open3d.visualization.

void pybind_visualization(py::module &m);

void pybind_renderoption(py::module &m);
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Open3D: A Modern Library for 3D Data Processing
cpp_api


.. Note: when adding new modules, please also update documented_modules.txt.
..
Note: when adding new modules, please also update documented_modules.txt.
.. toctree::
:maxdepth: 1
Expand All @@ -76,4 +77,3 @@ Open3D: A Modern Library for 3D Data Processing
python_api/open3d.pipelines
python_api/open3d.utility
python_api/open3d.visualization
python_api/open3d.visualization.tensorboard_plugin.summary
86 changes: 86 additions & 0 deletions docs/python_api_in/open3d.visualization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
open3d.visualization
--------------------

.. currentmodule:: open3d.visualization

**Classes**

.. autosummary::

ExternalVisualizer
Material
MeshColorOption
MeshShadeOption
O3DVisualizer
PickedPoint
PointColorOption
RenderOption
ScalarProperties
SelectedIndex
SelectionPolygonVolume
TextureMaps
VectorProperties
ViewControl
Visualizer
VisualizerWithEditing
VisualizerWithKeyCallback
VisualizerWithVertexSelection


**Functions**

.. autosummary::

draw
draw_geometries
draw_geometries_with_animation_callback
draw_geometries_with_custom_animation
draw_geometries_with_editing
draw_geometries_with_key_callbacks
draw_geometries_with_vertex_selection
read_selection_polygon_volume


**Modules**

.. autosummary::

gui
rendering
webrtc_server
tensorboard_plugin.summary


.. toctree::
:hidden:

ExternalVisualizer <open3d.visualization.ExternalVisualizer>
Material <open3d.visualization.Material>
MeshColorOption <open3d.visualization.MeshColorOption>
MeshShadeOption <open3d.visualization.MeshShadeOption>
O3DVisualizer <open3d.visualization.O3DVisualizer>
PickedPoint <open3d.visualization.PickedPoint>
PointColorOption <open3d.visualization.PointColorOption>
RenderOption <open3d.visualization.RenderOption>
ScalarProperties <open3d.visualization.ScalarProperties>
SelectedIndex <open3d.visualization.SelectedIndex>
SelectionPolygonVolume <open3d.visualization.SelectionPolygonVolume>
TextureMaps <open3d.visualization.TextureMaps>
VectorProperties <open3d.visualization.VectorProperties>
ViewControl <open3d.visualization.ViewControl>
Visualizer <open3d.visualization.Visualizer>
VisualizerWithEditing <open3d.visualization.VisualizerWithEditing>
VisualizerWithKeyCallback <open3d.visualization.VisualizerWithKeyCallback>
VisualizerWithVertexSelection <open3d.visualization.VisualizerWithVertexSelection>
draw <open3d.visualization.draw>
draw_geometries <open3d.visualization.draw_geometries>
draw_geometries_with_animation_callback <open3d.visualization.draw_geometries_with_animation_callback>
draw_geometries_with_custom_animation <open3d.visualization.draw_geometries_with_custom_animation>
draw_geometries_with_editing <open3d.visualization.draw_geometries_with_editing>
draw_geometries_with_key_callbacks <open3d.visualization.draw_geometries_with_key_callbacks>
draw_geometries_with_vertex_selection <open3d.visualization.draw_geometries_with_vertex_selection>
read_selection_polygon_volume <open3d.visualization.read_selection_polygon_volume>
gui <open3d.visualization.gui>
rendering <open3d.visualization.rendering>
webrtc_server <open3d.visualization.webrtc_server>
tensorboard_plugin.summary <open3d.visualization.tensorboard_plugin.summary>
1 change: 1 addition & 0 deletions docs/tutorial/visualization/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Visualization
non_blocking_visualization
headless_rendering
web_visualizer
tensorboard_plugin
3 changes: 3 additions & 0 deletions docs/tutorial/visualization/tensorboard_plugin.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. _tensorboard_plugin:

.. mdinclude:: ../../../../Open3D-ML/docs/tensorboard.md
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
import copy
import os
import sys
Expand Down Expand Up @@ -168,10 +167,35 @@ def with_material(model_dir=MODEL_DIR):
writer.add_3d(model_name, summary_3d, step=0)


def demo_scene():
"""Write the demo_scene.py example showing rich PBR materials as a summary
"""
import demo_scene
demo_scene.check_for_required_assets()
geoms = demo_scene.create_scene()
writer = SummaryWriter(os.path.join(BASE_LOGDIR, 'demo_scene'))
for geom_data in geoms:
geom = geom_data["geometry"]
summary_3d = {}
for key, tensor in geom.vertex.items():
summary_3d["vertex_" + key] = tensor
for key, tensor in geom.triangle.items():
summary_3d["triangle_" + key] = tensor
if geom.has_valid_material():
summary_3d["material_name"] = geom.material.material_name
for key, value in geom.material.scalar_properties.items():
summary_3d["material_scalar_" + key] = value
for key, value in geom.material.vector_properties.items():
summary_3d["material_vector_" + key] = value
for key, value in geom.material.texture_maps.items():
summary_3d["material_texture_map_" + key] = value
writer.add_3d(geom_data["name"], summary_3d, step=0)


if __name__ == "__main__":

examples = ('small_scale', 'large_scale', 'property_reference',
'with_material')
'with_material', 'demo_scene')
selected = tuple(eg for eg in sys.argv[1:] if eg in examples)
if len(selected) == 0:
print(f'Usage: python {__file__} EXAMPLE...')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
import copy
import os
import sys
Expand Down Expand Up @@ -182,10 +181,37 @@ def with_material(model_dir=MODEL_DIR):
summary.add_3d(model_name, summary_3d, step=0, logdir=logdir)


def demo_scene():
"""Write the demo_scene.py example showing rich PBR materials as a summary.
"""
import demo_scene
demo_scene.check_for_required_assets()
geoms = demo_scene.create_scene()
logdir = os.path.join(BASE_LOGDIR, 'demo_scene')
writer = tf.summary.create_file_writer(logdir)
for geom_data in geoms:
geom = geom_data["geometry"]
summary_3d = {}
for key, tensor in geom.vertex.items():
summary_3d["vertex_" + key] = tensor
for key, tensor in geom.triangle.items():
summary_3d["triangle_" + key] = tensor
if geom.has_valid_material():
summary_3d["material_name"] = geom.material.material_name
for key, value in geom.material.scalar_properties.items():
summary_3d["material_scalar_" + key] = value
for key, value in geom.material.vector_properties.items():
summary_3d["material_vector_" + key] = value
for key, value in geom.material.texture_maps.items():
summary_3d["material_texture_map_" + key] = value
with writer.as_default():
summary.add_3d(geom_data["name"], summary_3d, step=0, logdir=logdir)


if __name__ == "__main__":

examples = ('small_scale', 'large_scale', 'property_reference',
'with_material')
'with_material', 'demo_scene')
selected = tuple(eg for eg in sys.argv[1:] if eg in examples)
if len(selected) == 0:
print(f'Usage: python {__file__} EXAMPLE...')
Expand Down
Binary file modified examples/test_data/test_tensorboard_plugin.zip
Binary file not shown.
6 changes: 2 additions & 4 deletions python/open3d/visualization/async_event_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,20 @@ def _start(self):

def run_sync(self, func, *args, **kwargs):
"""Enqueue task, wait for completion and return result. Can run in any
thread."""
thread.
"""
from open3d.visualization.tensorboard_plugin.util import _log
if not self._started:
raise RuntimeError("GUI thread has exited.")

with self._lock:
task = _AsyncEventLoop._Task(func, *args, **kwargs)
_log.debug(f"[async_event_loop] Enqueue {func.__name__} with args:"
f" {args} {kwargs}")
self._run_queue.append(task)

while True:
with self._cv:
self._cv.wait_for(lambda: task.task_id in self._return_vals)
with self._lock:
_log.debug(f"[async_event_loop] Completed {func.__name__}")
return self._return_vals.pop(task.task_id)

def _thread_main(self):
Expand Down
Loading

0 comments on commit b387122

Please sign in to comment.