Skip to content

Commit

Permalink
feat: apply Tier4Viewer in Tier4 rendering (#19)
Browse files Browse the repository at this point in the history
* feat: apply `Tier4Viewer` in `Tier4` rendering

Signed-off-by: ktro2828 <[email protected]>

* docs: update documentation

Signed-off-by: ktro2828 <[email protected]>

---------

Signed-off-by: ktro2828 <[email protected]>
  • Loading branch information
ktro2828 authored Oct 22, 2024
1 parent 8aacfe1 commit 59a2078
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 279 deletions.
27 changes: 23 additions & 4 deletions docs/tutorials/render.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Rendering Scene
## Rendering with `Tier4`

If you want to visualize annotation results, `Tier4` supports some rendering methods as below.

### Rendering Scene

```python
>>> scene_token = t4.scene[0].token
Expand All @@ -7,7 +11,7 @@

![Render Scene GIF](../assets/render_scene.gif)

## Rendering Instance
### Rendering Instance

```python
>>> instance_token = t4.instance[0].token
Expand All @@ -16,7 +20,7 @@

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

## Rendering PointCloud
### Rendering PointCloud

```python
>>> scene_token = t4.scene[0].token
Expand All @@ -35,7 +39,7 @@
```
<!-- prettier-ignore-end -->

## Save Recording
### Save Recording

You can save the rendering result as follows:

Expand All @@ -48,3 +52,18 @@ If you don't want to spawn the viewer, please specify `show=False` as below:
```python
>>> t4.render_scene(scene_token, save_dir=<DIR_TO_SAVE>, show=False)
```

## Rendering with `Tier4Viewer`

If you want to visualize your components, such as boxes that your ML-model estimated, `Tier4Viewer` allows you to visualize these components.
For details, please refer to the API references.

```python
>>> from t4_devkit.viewer import Tier4Viewer
# You need to specify `cameras` if you want to 2D spaces
>>> viewer = Tier4Viewer(app_id, cameras=<CAMERA_NAMES:[str;N]>)
# Rendering 3D boxes
>>> viewer.render_box3ds(seconds, box3ds)
# Rendering 2D boxes
>>> viewer.render_box2ds(seconds, box2ds)
```
13 changes: 11 additions & 2 deletions t4_devkit/dataclass/pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import struct
from abc import abstractmethod
from dataclasses import dataclass
from typing import TYPE_CHECKING, ClassVar
from typing import TYPE_CHECKING, ClassVar, TypeVar

import numpy as np

Expand All @@ -12,7 +12,13 @@

from t4_devkit.typing import NDArrayFloat, NDArrayU8

__all__ = ["PointCloud", "LidarPointCloud", "RadarPointCloud", "SegmentationPointCloud"]
__all__ = [
"PointCloud",
"LidarPointCloud",
"RadarPointCloud",
"SegmentationPointCloud",
"PointCloudLike",
]


@dataclass
Expand Down Expand Up @@ -196,3 +202,6 @@ def from_file(cls, point_filepath: str, label_filepath: str) -> Self:
points = scan.reshape((-1, 5))[:, : cls.num_dims()]
labels = np.fromfile(label_filepath, dtype=np.uint8)
return cls(points.T, labels)


PointCloudLike = TypeVar("PointCloudLike", bound=PointCloud)
Loading

0 comments on commit 59a2078

Please sign in to comment.