Skip to content

Commit 270421c

Browse files
committed
feat: use dataset ID as viewer application ID
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent 4acb907 commit 270421c

4 files changed

Lines changed: 18 additions & 33 deletions

File tree

docs/tutorials/render.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ If you want to visualize annotation results, `Tier4` supports some rendering met
55
### Scene
66

77
```python
8-
>>> scene_token = t4.scene[0].token
9-
>>> t4.render_scene(scene_token)
8+
>>> t4.render_scene()
109
```
1110

1211
![Render Scene GIF](../assets/render_scene.gif)
@@ -20,18 +19,21 @@ If you want to visualize annotation results, `Tier4` supports some rendering met
2019

2120
![Render Instance GIF](../assets/render_instance.gif)
2221

23-
You can also render multiple instances at once:
22+
<!-- prettier-ignore-start -->
23+
!!! NOTE
24+
You can also render multiple instances at once:
2425

25-
```python
26-
>>> instance_tokens = [inst.token for inst in t4.instance[:3]]
27-
>>> t4.render_instance(instance_tokens)
28-
```
26+
<!-- markdownlint-disable MD046 -->
27+
```python
28+
>>> instance_tokens = [inst.token for inst in t4.instance[:3]]
29+
>>> t4.render_instance(instance_tokens)
30+
```
31+
<!-- prettier-ignore-end -->
2932

3033
### PointCloud
3134

3235
```python
33-
>>> scene_token = t4.scene[0].token
34-
>>> t4.render_pointcloud(scene_token)
36+
>>> t4.render_pointcloud()
3537
```
3638

3739
![Render PointCloud GIF](../assets/render_pointcloud.gif)
@@ -42,7 +44,7 @@ You can also render multiple instances at once:
4244

4345
<!-- markdownlint-disable MD046 -->
4446
```python
45-
>>> t4.render_pointcloud(scene_token, ignore_distortion=True)
47+
>>> t4.render_pointcloud(ignore_distortion=True)
4648
```
4749
<!-- prettier-ignore-end -->
4850

t4_devkit/cli/visualize.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def scene(
4242
_create_dir(output)
4343

4444
t4 = Tier4(data_root, verbose=False)
45-
scene_token = t4.scene[0].token
46-
t4.render_scene(scene_token, future_seconds=future, save_dir=output)
45+
t4.render_scene(future_seconds=future, save_dir=output)
4746

4847

4948
@cli.command("instance", help="Visualize a particular instance in the corresponding scene.")
@@ -100,12 +99,7 @@ def pointcloud(
10099
_create_dir(output)
101100

102101
t4 = Tier4(data_root, verbose=False)
103-
scene_token = t4.scene[0].token
104-
t4.render_pointcloud(
105-
scene_token,
106-
ignore_distortion=ignore_distortion,
107-
save_dir=output,
108-
)
102+
t4.render_pointcloud(ignore_distortion=ignore_distortion, save_dir=output)
109103

110104

111105
def _create_dir(dir_path: str | None) -> None:

t4_devkit/helper/rendering.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def _init_viewer(
9797

9898
def render_scene(
9999
self,
100-
scene_token: str,
101100
*,
102101
max_time_seconds: float = np.inf,
103102
future_seconds: float = 0.0,
@@ -106,7 +105,6 @@ def render_scene(
106105
"""Render specified scene.
107106
108107
Args:
109-
scene_token (str): Unique identifier of scene.
110108
max_time_seconds (float, optional): Max time length to be rendered [s].
111109
future_seconds (float, optional): Future time in [s].
112110
save_dir (str | None, optional): Directory path to save the recording.
@@ -132,7 +130,7 @@ def render_scene(
132130
render3d = len(first_lidar_tokens) > 0 or len(first_radar_tokens) > 0
133131
render2d = len(first_camera_tokens) > 0
134132

135-
app_id = f"scene@{scene_token}"
133+
app_id = f"scene@{self._t4.dataset_id}"
136134
viewer = self._init_viewer(
137135
app_id,
138136
render3d=render3d,
@@ -141,7 +139,7 @@ def render_scene(
141139
save_dir=save_dir,
142140
)
143141

144-
scene: Scene = self._t4.get("scene", scene_token)
142+
scene: Scene = self._t4.scene[0]
145143
first_sample: Sample = self._t4.get("sample", scene.first_sample_token)
146144
max_timestamp_us = first_sample.timestamp + sec2us(max_time_seconds)
147145

@@ -212,7 +210,6 @@ def render_instance(
212210
if last_sample is None or current_last_sample.timestamp > last_sample.timestamp:
213211
last_sample = current_last_sample
214212

215-
scene_token = first_sample.scene_token
216213
max_timestamp_us = last_sample.timestamp
217214

218215
# search first sample data tokens
@@ -235,7 +232,7 @@ def render_instance(
235232
render3d = len(first_lidar_tokens) > 0 or len(first_radar_tokens) > 0
236233
render2d = len(first_camera_tokens) > 0
237234

238-
app_id = f"instance@{scene_token}"
235+
app_id = f"instance@{self._t4.dataset_id}"
239236
viewer = self._init_viewer(
240237
app_id,
241238
render3d=render3d,
@@ -279,7 +276,6 @@ def render_instance(
279276

280277
def render_pointcloud(
281278
self,
282-
scene_token: str,
283279
*,
284280
max_time_seconds: float = np.inf,
285281
ignore_distortion: bool = True,
@@ -288,7 +284,6 @@ def render_pointcloud(
288284
"""Render pointcloud on 3D and 2D view.
289285
290286
Args:
291-
scene_token (str): Scene token.
292287
max_time_seconds (float, optional): Max time length to be rendered [s].
293288
ignore_distortion (bool, optional): Whether to ignore distortion parameters.
294289
save_dir (str | None, optional): Directory path to save the recording.
@@ -298,7 +293,7 @@ def render_pointcloud(
298293
Add an option of rendering radar channels.
299294
"""
300295
# initialize viewer
301-
app_id = f"pointcloud@{scene_token}"
296+
app_id = f"pointcloud@{self._t4.dataset_id}"
302297
viewer = self._init_viewer(app_id, render_ann=False, save_dir=save_dir)
303298

304299
# search first lidar sample data token

t4_devkit/tier4.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ def box_velocity(self, sample_annotation_token: str, max_time_diff: float = 1.5)
692692

693693
def render_scene(
694694
self,
695-
scene_token: str,
696695
*,
697696
max_time_seconds: float = np.inf,
698697
future_seconds: float = 0.0,
@@ -701,13 +700,11 @@ def render_scene(
701700
"""Render specified scene.
702701
703702
Args:
704-
scene_token (str): Unique identifier of scene.
705703
max_time_seconds (float, optional): Max time length to be rendered [s].
706704
future_seconds (float, optional): Future time in [s].
707705
save_dir (str | None, optional): Directory path to save the recording.
708706
"""
709707
self._rendering_helper.render_scene(
710-
scene_token=scene_token,
711708
max_time_seconds=max_time_seconds,
712709
future_seconds=future_seconds,
713710
save_dir=save_dir,
@@ -735,7 +732,6 @@ def render_instance(
735732

736733
def render_pointcloud(
737734
self,
738-
scene_token: str,
739735
*,
740736
max_time_seconds: float = np.inf,
741737
ignore_distortion: bool = True,
@@ -744,7 +740,6 @@ def render_pointcloud(
744740
"""Render pointcloud on 3D and 2D view.
745741
746742
Args:
747-
scene_token (str): Scene token.
748743
max_time_seconds (float, optional): Max time length to be rendered [s].
749744
save_dir (str | None, optional): Directory path to save the recording.
750745
ignore_distortion (bool, optional): Whether to ignore distortion parameters.
@@ -753,7 +748,6 @@ def render_pointcloud(
753748
Add an option of rendering radar channels.
754749
"""
755750
self._rendering_helper.render_pointcloud(
756-
scene_token=scene_token,
757751
max_time_seconds=max_time_seconds,
758752
ignore_distortion=ignore_distortion,
759753
save_dir=save_dir,

0 commit comments

Comments
 (0)