Skip to content
Merged
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
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ readme = "README.md"
license = "BSD-3-Clause"
requires-python = ">=3.8"
dependencies = [
"click",
"numpy",
"seaborn",
"shapely",
Expand All @@ -28,11 +29,7 @@ classifiers = [
]

[project.optional-dependencies]
viz = [
"plotly",
"open3d >= 0.17",
"scipy",
]
viz = ["trimesh", "viser"]

[project.urls]
Repository = "https://github.com/MIT-SPARK/Spark-DSG"
Expand Down
17 changes: 12 additions & 5 deletions python/bindings/src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,29 @@
* -------------------------------------------------------------------------- */
#include "spark_dsg/python/color.h"

#include <pybind11/eigen.h>
#include <spark_dsg/color.h>
#include <spark_dsg/colormaps.h>

#include <Eigen/Dense>

namespace spark_dsg::python {

namespace py = pybind11;

using namespace spark_dsg;
using namespace py::literals;

void init_color(py::module_& m) {
// TODO(nathan) colormaps

py::class_<Color>(m, "Color")
.def(py::init())
.def_readwrite("r", &Color::r)
.def_readwrite("g", &Color::g)
.def_readwrite("b", &Color::b)
.def_readwrite("a", &Color::a);
.def_readwrite("a", &Color::a)
.def("to_float_array", [](const Color& c) { return Eigen::Vector3f(c.r / 255.0, c.g / 255.0, c.b / 255.0); });

m.def("colorbrewer_color", &colormaps::colorbrewerId);
m.def("distinct_150_color", &colormaps::distinct150Id);
m.def("rainbow_color", &colormaps::rainbowId, "id"_a, "ids_per_revolution"_a = 16);
}

} // namespace spark_dsg::python
2 changes: 2 additions & 0 deletions python/bindings/src/scene_graph_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ void init_scene_graph_layer(py::module_& m) {
.def("num_nodes", &LayerView::numNodes)
.def("num_edges", &LayerView::numEdges)
.def("get_position", &LayerView::getPosition)
.def_property(
"key", [](const LayerView& view) { return view.id; }, nullptr)
.def_property(
"id", [](const LayerView& view) { return view.id.layer; }, nullptr)
.def_property(
Expand Down
4 changes: 1 addition & 3 deletions python/spark_dsg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
SceneGraphLayer,
compute_ancestor_bounding_box,
)
from spark_dsg.open3d_visualization import render_to_open3d
from spark_dsg.torch_conversion import scene_graph_layer_to_torch, scene_graph_to_torch
from spark_dsg.visualization import plot_scene_graph


def add_bounding_boxes_to_layer(
Expand Down Expand Up @@ -104,7 +102,7 @@ def _hash_layerkey(key):

def _get_layer_id(graph, name):
warnings.warn(
"'get_layer_key' is deprecated. Please use 'get_layer_key'",
"'get_layer_id' is deprecated. Please use 'get_layer_key'",
DeprecationWarning,
stacklevel=2,
)
Expand Down
15 changes: 11 additions & 4 deletions python/spark_dsg/commands/visualize.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
"""Entry point for visualizing scene graph."""

import time

import click
import spark_dsg as dsg
from spark_dsg.open3d_visualization import render_to_open3d
from spark_dsg.viser import ViserRenderer


@click.command("visualize")
@click.argument("filepath", type=click.Path(exists=True))
def cli(filepath):
@click.option("--ip", default="localhost")
@click.option("--port", default="8080")
def cli(filepath, ip, port):
"""Visualize a scene graph from FILEPATH using Open3D."""
G = dsg.DynamicSceneGraph.load(filepath)
render_to_open3d(G)
print("Done.")

with ViserRenderer(ip, port=port) as renderer:
renderer.draw(G)
while True:
time.sleep(10.0)
Loading