diff --git a/docs/tutorials/render.md b/docs/tutorials/render.md index 52820fc..26ca5c7 100644 --- a/docs/tutorials/render.md +++ b/docs/tutorials/render.md @@ -53,15 +53,15 @@ If you don't want to spawn the viewer, please specify `show=False` as below: >>> t4.render_scene(scene_token, save_dir=, show=False) ``` -## Rendering with `Tier4Viewer` +## Rendering with `RerunViewer` -If you want to visualize your components, such as boxes that your ML-model estimated, `Tier4Viewer` allows you to visualize these components. +If you want to visualize your components, such as boxes that your ML-model estimated, `RerunViewer` allows you to visualize these components. For details, please refer to the API references. ```python ->>> from t4_devkit.viewer import Tier4Viewer +>>> from t4_devkit.viewer import RerunViewer # You need to specify `cameras` if you want to 2D spaces ->>> viewer = Tier4Viewer(app_id, cameras=) +>>> viewer = RerunViewer(app_id, cameras=) # Rendering 3D boxes >>> viewer.render_box3ds(seconds, box3ds) # Rendering 2D boxes diff --git a/t4_devkit/tier4.py b/t4_devkit/tier4.py index 62c0249..fb87ae3 100644 --- a/t4_devkit/tier4.py +++ b/t4_devkit/tier4.py @@ -21,7 +21,7 @@ ShapeType, ) from t4_devkit.schema import SchemaName, SensorModality, VisibilityLevel, build_schema -from t4_devkit.viewer import Tier4Viewer, distance_color, format_entity +from t4_devkit.viewer import RerunViewer, distance_color, format_entity if TYPE_CHECKING: from t4_devkit.typing import CamIntrinsicType, NDArrayF64, NDArrayU8, VelocityType @@ -882,7 +882,7 @@ def _init_viewer( render_2d: bool = True, render_annotation: bool = True, spawn: bool = False, - ) -> Tier4Viewer: + ) -> RerunViewer: """Initialize rendering viewer. Args: @@ -904,7 +904,7 @@ def _init_viewer( else None ) - viewer = Tier4Viewer(application_id, cameras=cameras, with_3d=render_3d, spawn=spawn) + viewer = RerunViewer(application_id, cameras=cameras, with_3d=render_3d, spawn=spawn) if render_annotation: viewer = viewer.with_labels(self._label2id) @@ -915,7 +915,7 @@ def _init_viewer( def _render_lidar_and_ego( self, - viewer: Tier4Viewer, + viewer: RerunViewer, first_lidar_token: str, max_timestamp_us: float, *, @@ -925,7 +925,7 @@ def _render_lidar_and_ego( """Render lidar pointcloud and ego transform. Args: - viewer (Tier4Viewer): Viewer object. + viewer (RerunViewer): Viewer object. first_lidar_token (str): First sample data token corresponding to the lidar. max_timestamp_us (float): Max time length in [us]. project_points (bool, optional): Whether to project 3d points on 2d images. @@ -961,14 +961,14 @@ def _render_lidar_and_ego( def _render_radars( self, - viewer: Tier4Viewer, + viewer: RerunViewer, first_radar_tokens: list[str], max_timestamp_us: float, ) -> None: """Render radar pointcloud. Args: - viewer (Tier4Viewer): Viewer object. + viewer (RerunViewer): Viewer object. first_radar_tokens (list[str]): List of first sample data tokens corresponding to radars. max_timestamp_us (float): Max time length in [us]. """ @@ -993,12 +993,12 @@ def _render_radars( current_radar_token = sample_data.next def _render_cameras( - self, viewer: Tier4Viewer, first_camera_tokens: list[str], max_timestamp_us: float + self, viewer: RerunViewer, first_camera_tokens: list[str], max_timestamp_us: float ) -> None: """Render camera images. Args: - viewer (Tier4Viewer): Viewer object. + viewer (RerunViewer): Viewer object. first_camera_tokens (list[str]): List of first sample data tokens corresponding to cameras. max_timestamp_us (float): Max time length in [us]. """ @@ -1038,7 +1038,7 @@ def _render_points_on_cameras( ignore_distortion (bool, optional): Whether to ignore distortion parameters. TODO: - Replace operation by `Tier4Viewer`. + Replace operation by `RerunViewer`. """ point_sample_data: SampleData = self.get("sample_data", point_sample_data_token) sample: Sample = self.get("sample", point_sample_data.sample_token) @@ -1060,10 +1060,10 @@ def _render_points_on_cameras( sensor_name = channel rr.set_time_seconds("timestamp", us2sec(camera_sample_data.timestamp)) - rr.log(format_entity(Tier4Viewer.ego_entity, sensor_name), rr.Image(img)) + rr.log(format_entity(RerunViewer.ego_entity, sensor_name), rr.Image(img)) rr.log( - format_entity(Tier4Viewer.ego_entity, sensor_name, "pointcloud"), + format_entity(RerunViewer.ego_entity, sensor_name, "pointcloud"), rr.Points2D( positions=points_on_img.T, colors=distance_color(depths), @@ -1072,7 +1072,7 @@ def _render_points_on_cameras( def _render_annotation_3ds( self, - viewer: Tier4Viewer, + viewer: RerunViewer, first_sample_token: str, max_timestamp_us: float, instance_token: str | None = None, @@ -1080,7 +1080,7 @@ def _render_annotation_3ds( """Render annotated 3D boxes. Args: - viewer (Tier4Viewer): Viewer object. + viewer (RerunViewer): Viewer object. first_sample_token (str): First sample token. max_timestamp_us (float): Max time length in [us]. instance_token (str | None, optional): Specify if you want to render only particular instance. @@ -1107,7 +1107,7 @@ def _render_annotation_3ds( def _render_annotation_2ds( self, - viewer: Tier4Viewer, + viewer: RerunViewer, first_sample_token: str, max_timestamp_us: float, instance_token: str | None = None, @@ -1115,7 +1115,7 @@ def _render_annotation_2ds( """Render annotated 2D boxes. Args: - viewer (Tier4Viewer): Viewer object. + viewer (RerunViewer): Viewer object. first_sample_token (str): First sample token. max_timestamp_us (float): Max time length in [us]. instance_token (str | None, optional): Specify if you want to render only particular instance. @@ -1175,11 +1175,11 @@ def _render_annotation_2ds( # TODO: add support of rendering keypoints current_sample_token = sample.next - def _render_sensor_calibration(self, viewer: Tier4Viewer, sample_data_token: str) -> None: + def _render_sensor_calibration(self, viewer: RerunViewer, sample_data_token: str) -> None: """Render a fixed calibrated sensor transform. Args: - viewer (Tier4Viewer): Viewer object. + viewer (RerunViewer): Viewer object. sample_data_token (str): First sample data token corresponding to the sensor. """ sample_data: SampleData = self.get("sample_data", sample_data_token) diff --git a/t4_devkit/viewer/viewer.py b/t4_devkit/viewer/viewer.py index f165e61..c6a4f1b 100644 --- a/t4_devkit/viewer/viewer.py +++ b/t4_devkit/viewer/viewer.py @@ -29,7 +29,7 @@ VelocityType, ) -__all__ = ["Tier4Viewer", "format_entity"] +__all__ = ["RerunViewer", "format_entity"] def format_entity(root: str, *entities) -> str: @@ -61,7 +61,7 @@ def format_entity(root: str, *entities) -> str: return osp.join(root, "/".join(entities)) -class Tier4Viewer: +class RerunViewer: """A viewer class that renders some components powered by rerun.""" # entity paths @@ -88,13 +88,13 @@ def __init__( spawn (bool, optional): Whether to spawn the viewer. Examples: - >>> from t4_devkit.viewer import Tier4Viewer + >>> from t4_devkit.viewer import RerunViewer # Rendering both 3D/2D spaces - >>> viewer = Tier4Viewer("myapp", cameras=["camera0", "camera1"]) + >>> viewer = RerunViewer("myapp", cameras=["camera0", "camera1"]) # Rendering 3D space only - >>> viewer = Tier4Viewer("myapp") + >>> viewer = RerunViewer("myapp") # Rendering 2D space only - >>> viewer = Tier4Viewer("myapp", cameras=["camera0", "camera1"], with_3d=False) + >>> viewer = RerunViewer("myapp", cameras=["camera0", "camera1"], with_3d=False) """ self.app_id = app_id self.cameras = cameras @@ -148,7 +148,7 @@ def with_labels(self, label2id: dict[str, int]) -> Self: Examples: >>> label2id = {"car": 0, "pedestrian": 1} - >>> viewer = Tier4Viewer("myapp").with_labels(label2id) + >>> viewer = RerunViewer("myapp").with_labels(label2id) """ self.label2id = label2id diff --git a/tests/viewer/conftest.py b/tests/viewer/conftest.py index 3318157..d57ea29 100644 --- a/tests/viewer/conftest.py +++ b/tests/viewer/conftest.py @@ -1,15 +1,17 @@ import pytest -from t4_devkit.viewer import Tier4Viewer +from t4_devkit.viewer import RerunViewer @pytest.fixture(scope="module") -def dummy_viewer(label2id) -> Tier4Viewer: +def dummy_viewer(label2id) -> RerunViewer: """Return a dummy viewer. Returns: - `Tier4Viewer` without spawning. + `RerunViewer` without spawning. """ - return Tier4Viewer("test_viewer", cameras=["camera"], spawn=False).with_labels( - label2id=label2id - ) + return RerunViewer( + "test_viewer", + cameras=["camera"], + spawn=False, + ).with_labels(label2id=label2id) diff --git a/tests/viewer/test_viewer.py b/tests/viewer/test_viewer.py index b949e0d..03d87d5 100644 --- a/tests/viewer/test_viewer.py +++ b/tests/viewer/test_viewer.py @@ -17,10 +17,10 @@ def test_format_entity() -> None: def test_render_box3ds(dummy_viewer, dummy_box3ds) -> None: - """Test rendering 3D boxes with `Tier4Viewer`. + """Test rendering 3D boxes with `RerunViewer`. Args: - dummy_viewer (Tier4Viewer): Viewer object. + dummy_viewer (RerunViewer): Viewer object. dummy_box3ds (list[Box3D]): List of 3D boxes. """ seconds = 1.0 # [sec] @@ -46,10 +46,10 @@ def test_render_box3ds(dummy_viewer, dummy_box3ds) -> None: def test_render_box2ds(dummy_viewer, dummy_box2ds) -> None: - """Test rendering 2D boxes with `Tier4Viewer`. + """Test rendering 2D boxes with `RerunViewer`. Args: - dummy_viewer (Tier4Viewer): Viewer object. + dummy_viewer (RerunViewer): Viewer object. dummy_box2ds (list[Box2D): List of 2D boxes. """ seconds = 1.0 # [sec] @@ -65,10 +65,10 @@ def test_render_box2ds(dummy_viewer, dummy_box2ds) -> None: def test_render_pointcloud(dummy_viewer) -> None: - """Test rendering pointcloud with `Tier4Viewer`. + """Test rendering pointcloud with `RerunViewer`. Args: - dummy_viewer (Tier4Viewer): Viewer object. + dummy_viewer (RerunViewer): Viewer object. """ seconds = 1.0 # [sec] @@ -77,10 +77,10 @@ def test_render_pointcloud(dummy_viewer) -> None: def test_render_ego(dummy_viewer) -> None: - """Test rendering ego pose with `Tier4Viewer`. + """Test rendering ego pose with `RerunViewer`. Args: - dummy_viewer (Tier4Viewer): Viewer object. + dummy_viewer (RerunViewer): Viewer object. """ seconds = 1.0 # [sec] @@ -100,10 +100,10 @@ def test_render_ego(dummy_viewer) -> None: def test_render_calibration(dummy_viewer) -> None: - """Test rendering sensor calibration with `Tier4Viewer`. + """Test rendering sensor calibration with `RerunViewer`. Args: - dummy_viewer (Tier4Viewer): Viewer object. + dummy_viewer (RerunViewer): Viewer object. """ # without `Sensor` and `CalibratedSensor` channel = "camera"