diff --git a/t4_devkit/helper/rendering.py b/t4_devkit/helper/rendering.py index f1d739e..29aca75 100644 --- a/t4_devkit/helper/rendering.py +++ b/t4_devkit/helper/rendering.py @@ -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, diff --git a/t4_devkit/viewer/viewer.py b/t4_devkit/viewer/viewer.py index 5af872a..f825875 100644 --- a/t4_devkit/viewer/viewer.py +++ b/t4_devkit/viewer/viewer.py @@ -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"] @@ -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 @@ -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. @@ -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: self._render_calibration_with_schema(*args, **kwargs) else: self._render_calibration_without_schema(*args, **kwargs) @@ -604,6 +614,7 @@ def _render_calibration_with_schema( self, sensor: Sensor, calibration: CalibratedSensor, + resolution: Vector2Like | None = None, ) -> None: self._render_calibration_without_schema( channel=sensor.channel, @@ -611,6 +622,7 @@ def _render_calibration_with_schema( translation=calibration.translation, rotation=calibration.rotation, camera_intrinsic=calibration.camera_intrinsic, + resolution=resolution, ) def _render_calibration_without_schema( @@ -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. @@ -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), @@ -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, )