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
35 changes: 32 additions & 3 deletions t4_devkit/cli/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ def scene(
help="Output directory to save recorded .rrd file.",
),
] = None,
show_map: Annotated[
bool,
typer.Option(
...,
"-m",
"--map",
help="Whether to render the map.",
),
] = False,
) -> None:
_create_dir(output)

t4 = T4Devkit(data_root, revision=revision, verbose=False)
t4.render_scene(future_seconds=future, save_dir=output)
t4.render_scene(future_seconds=future, save_dir=output, show_map=show_map)


@cli.command("instance", help="Visualize a particular instance in the corresponding scene.")
Expand Down Expand Up @@ -79,11 +88,22 @@ def instance(
help="Output directory to save recorded .rrd file.",
),
] = None,
show_map: Annotated[
bool,
typer.Option(
...,
"-m",
"--map",
help="Whether to render the map.",
),
] = False,
) -> None:
_create_dir(output)

t4 = T4Devkit(data_root, revision=revision, verbose=False)
t4.render_instance(instance_token=instance, future_seconds=future, save_dir=output)
t4.render_instance(
instance_token=instance, future_seconds=future, save_dir=output, show_map=show_map
)


@cli.command("pointcloud", help="Visualize pointcloud in the corresponding scene.")
Expand All @@ -104,11 +124,20 @@ def pointcloud(
help="Output directory to save recorded .rrd file.",
),
] = None,
show_map: Annotated[
bool,
typer.Option(
...,
"-m",
"--map",
help="Whether to render the map.",
),
] = False,
) -> None:
_create_dir(output)

t4 = T4Devkit(data_root, revision=revision, verbose=False)
t4.render_pointcloud(save_dir=output)
t4.render_pointcloud(save_dir=output, show_map=show_map)


def _create_dir(dir_path: str | None) -> None:
Expand Down
16 changes: 12 additions & 4 deletions t4_devkit/helper/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def render_scene(
max_time_seconds: float = np.inf,
future_seconds: float = 0.0,
save_dir: str | None = None,
show_map: bool = False,
) -> None:
"""Render specified scene.

Expand All @@ -157,6 +158,7 @@ def render_scene(
future_seconds (float, optional): Future time in [s].
save_dir (str | None, optional): Directory path to save the recording.
Viewer will be spawned if it is None, otherwise not.
show_map (bool, optional): Whether to render the map.
"""
# search first sample data tokens
first_lidar_tokens: list[str] = [
Expand All @@ -179,7 +181,8 @@ def render_scene(
contents = self._load_contents(RenderingMode.SCENE)
viewer = self._init_viewer(app_id, contents=contents, render_ann=True, save_dir=save_dir)

self._try_render_map(viewer)
if show_map:
self._try_render_map(viewer)

scene: Scene = self._t4.scene[0]
first_sample: Sample = self._t4.get("sample", scene.first_sample_token)
Expand Down Expand Up @@ -233,6 +236,7 @@ def render_instance(
*,
future_seconds: float = 0.0,
save_dir: str | None = None,
show_map: bool = False,
) -> None:
"""Render particular instance.

Expand All @@ -241,7 +245,7 @@ def render_instance(
future_seconds (float, optional): Future time in [s].
save_dir (str | None, optional): Directory path to save the recording.
Viewer will be spawned if it is None, otherwise not.

show_map (bool, optional): Whether to render the map.
"""
instance_tokens = [instance_token] if isinstance(instance_token, str) else instance_token

Expand Down Expand Up @@ -293,7 +297,8 @@ def render_instance(
contents = self._load_contents(RenderingMode.INSTANCE)
viewer = self._init_viewer(app_id, contents=contents, render_ann=True, save_dir=save_dir)

self._try_render_map(viewer)
if show_map:
self._try_render_map(viewer)

pointcloud_color_mode = (
PointCloudColorMode.SEGMENTATION
Expand Down Expand Up @@ -344,13 +349,15 @@ def render_pointcloud(
*,
max_time_seconds: float = np.inf,
save_dir: str | None = None,
show_map: bool = False,
) -> None:
"""Render pointcloud on 3D and 2D view.

Args:
max_time_seconds (float, optional): Max time length to be rendered [s].
save_dir (str | None, optional): Directory path to save the recording.
Viewer will be spawned if it is None, otherwise not.
show_map (bool, optional): Whether to render the map.

TODO:
Add an option of rendering radar channels.
Expand Down Expand Up @@ -379,7 +386,8 @@ def render_pointcloud(
)
viewer = self._init_viewer(app_id, contents=contents, render_ann=False, save_dir=save_dir)

self._try_render_map(viewer)
if show_map:
self._try_render_map(viewer)

# TODO: support rendering segmentation pointcloud on camera
futures = self._render_lidar_and_ego(
Expand Down
9 changes: 9 additions & 0 deletions t4_devkit/tier4.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,18 +747,21 @@ def render_scene(
max_time_seconds: float = np.inf,
future_seconds: float = 0.0,
save_dir: str | None = None,
show_map: bool = False,
) -> None:
"""Render specified scene.

Args:
max_time_seconds (float, optional): Max time length to be rendered [s].
future_seconds (float, optional): Future time in [s].
save_dir (str | None, optional): Directory path to save the recording.
show_map (bool, optional): Whether to render the map.
"""
self._rendering_helper.render_scene(
max_time_seconds=max_time_seconds,
future_seconds=future_seconds,
save_dir=save_dir,
show_map=show_map,
)

def render_instance(
Expand All @@ -767,38 +770,44 @@ def render_instance(
*,
future_seconds: float = 0.0,
save_dir: str | None = None,
show_map: bool = False,
) -> None:
Comment thread
ktro2828 marked this conversation as resolved.
"""Render particular instance.

Args:
instance_token (str | Sequence[str]): Instance token(s).
future_seconds (float, optional): Future time in [s].
save_dir (str | None, optional): Directory path to save the recording.
show_map (bool, optional): Whether to render the map.
"""
self._rendering_helper.render_instance(
instance_token=instance_token,
future_seconds=future_seconds,
save_dir=save_dir,
show_map=show_map,
)

def render_pointcloud(
self,
*,
max_time_seconds: float = np.inf,
save_dir: str | None = None,
show_map: bool = False,
) -> None:
Comment thread
ktro2828 marked this conversation as resolved.
"""Render pointcloud on 3D and 2D view.

Args:
max_time_seconds (float, optional): Max time length to be rendered [s].
save_dir (str | None, optional): Directory path to save the recording.
show_map (bool, optional): Whether to render the map.

TODO:
Add an option of rendering radar channels.
"""
self._rendering_helper.render_pointcloud(
max_time_seconds=max_time_seconds,
save_dir=save_dir,
show_map=show_map,
)


Expand Down
Loading