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
9 changes: 8 additions & 1 deletion t4_devkit/helper/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,14 @@ def _render_sensor_calibration(self, viewer: RerunViewer, sample_data_token: str
"calibrated_sensor", sample_data.calibrated_sensor_token
)
sensor: Sensor = self._t4.get("sensor", calibration.sensor_token)
viewer.render_calibration(sensor=sensor, calibration=calibration)
if sensor.modality == SensorModality.CAMERA:
viewer.render_calibration(
sensor=sensor,
calibration=calibration,
resolution=(sample_data.width, sample_data.height),
)
else:
viewer.render_calibration(sensor=sensor, calibration=calibration)

def _render_lidar_and_ego(
self,
Expand Down
23 changes: 18 additions & 5 deletions t4_devkit/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
if TYPE_CHECKING:
from t4_devkit.dataclass import Box2D, Box3D, Future, PointCloudLike
from t4_devkit.schema import CalibratedSensor, EgoPose, Sensor
from t4_devkit.typing import CamIntrinsicLike, NDArrayU8, RoiLike, RotationLike, Vector3Like
from t4_devkit.typing import (
CamIntrinsicLike,
NDArrayU8,
RoiLike,
RotationLike,
Vector2Like,
Vector3Like,
)

__all__ = ["RerunViewer", "format_entity"]

Expand Down Expand Up @@ -563,12 +570,14 @@ def render_calibration(
self,
sensor: Sensor,
calibration: CalibratedSensor,
resolution: Vector2Like | None = None,
) -> None:
"""Render a sensor calibration.

Args:
sensor (Sensor): `Sensor` object.
calibration (CalibratedSensor): `CalibratedSensor` object.
resolution (Vector2Like | None, optional): Camera resolution (width, height).
"""
pass

Expand All @@ -580,6 +589,7 @@ def render_calibration(
translation: Vector3Like,
rotation: RotationLike,
camera_intrinsic: CamIntrinsicLike | None = None,
resolution: Vector2Like | None = None,
) -> None:
"""Render a sensor calibration.

Expand All @@ -589,13 +599,13 @@ def render_calibration(
translation (Vector3Like): Sensor translation in ego centric coords.
rotation (RotationLike): Sensor rotation in ego centric coords.
camera_intrinsic (CamIntrinsicLike | None, optional): Camera intrinsic matrix.
Defaults to None.
resolution (Vector2Like | None, optional): Camera resolution (width, height).
"""
pass

def render_calibration(self, *args, **kwargs) -> None:
"""Render a sensor calibration."""
if len(args) + len(kwargs) == 2:
if len(args) + len(kwargs) <= 3:
Comment thread
ktro2828 marked this conversation as resolved.
self._render_calibration_with_schema(*args, **kwargs)
else:
self._render_calibration_without_schema(*args, **kwargs)
Expand All @@ -604,13 +614,15 @@ def _render_calibration_with_schema(
self,
sensor: Sensor,
calibration: CalibratedSensor,
resolution: Vector2Like | None = None,
) -> None:
self._render_calibration_without_schema(
channel=sensor.channel,
modality=sensor.modality,
translation=calibration.translation,
rotation=calibration.rotation,
camera_intrinsic=calibration.camera_intrinsic,
resolution=resolution,
)

def _render_calibration_without_schema(
Expand All @@ -620,6 +632,7 @@ def _render_calibration_without_schema(
translation: Vector3Like,
rotation: RotationLike,
camera_intrinsic: CamIntrinsicLike | None = None,
resolution: Vector2Like | None = None,
) -> None:
"""Render a sensor calibration.

Expand All @@ -629,7 +642,7 @@ def _render_calibration_without_schema(
translation (Vector3Like): Sensor translation in ego centric coords.
rotation (RotationLike): Sensor rotation in ego centric coords.
camera_intrinsic (CamIntrinsicLike | None, optional): Camera intrinsic matrix.
Defaults to None.
resolution (Vector2Like | None, optional): Camera resolution (width, height).
"""
rr.log(
format_entity(self.ego_entity, channel),
Expand All @@ -640,7 +653,7 @@ def _render_calibration_without_schema(
if modality == SensorModality.CAMERA:
rr.log(
format_entity(self.ego_entity, channel),
rr.Pinhole(image_from_camera=camera_intrinsic),
rr.Pinhole(image_from_camera=camera_intrinsic, resolution=resolution),
static=True,
)

Expand Down
Loading