|
13 | 13 |
|
14 | 14 | from t4_devkit.common.geometry import view_points |
15 | 15 | from t4_devkit.common.timestamp import microseconds2seconds, seconds2microseconds |
16 | | -from t4_devkit.dataclass import LidarPointCloud, RadarPointCloud |
| 16 | +from t4_devkit.dataclass import LidarPointCloud, RadarPointCloud, SegmentationPointCloud |
17 | 17 | from t4_devkit.schema import SensorModality |
18 | 18 | from t4_devkit.viewer import ( |
19 | 19 | PointCloudColorMode, |
@@ -56,6 +56,11 @@ def __init__(self, t4: Tier4) -> None: |
56 | 56 | self._label2id: dict[str, int] = { |
57 | 57 | category.name: idx for idx, category in enumerate(self._t4.category) |
58 | 58 | } |
| 59 | + self._sample_data_to_lidarseg_filename: dict[str, str] | None = ( |
| 60 | + {lidarseg.sample_data_token: lidarseg.filename for lidarseg in self._t4.lidarseg} |
| 61 | + if self._t4.lidarseg |
| 62 | + else None |
| 63 | + ) |
59 | 64 |
|
60 | 65 | self._executor = concurrent.futures.ThreadPoolExecutor() |
61 | 66 |
|
@@ -122,7 +127,7 @@ def render_scene( |
122 | 127 | app_id = f"scene@{self._t4.dataset_id}" |
123 | 128 | viewer = self._init_viewer(app_id, render_ann=True, save_dir=save_dir) |
124 | 129 |
|
125 | | - self._render_map(viewer) |
| 130 | + # self._render_map(viewer) |
126 | 131 |
|
127 | 132 | scene: Scene = self._t4.scene[0] |
128 | 133 | first_sample: Sample = self._t4.get("sample", scene.first_sample_token) |
@@ -352,9 +357,21 @@ def _render_single_lidar(first_lidar_token: str) -> None: |
352 | 357 | ego_pose: EgoPose = self._t4.get("ego_pose", sample_data.ego_pose_token) |
353 | 358 | viewer.render_ego(ego_pose=ego_pose) |
354 | 359 |
|
355 | | - pointcloud = LidarPointCloud.from_file( |
356 | | - osp.join(self._t4.data_root, sample_data.filename) |
357 | | - ) |
| 360 | + # render segmentation pointcloud if available, otherwise render raw pointcloud |
| 361 | + if ( |
| 362 | + self._sample_data_to_lidarseg_filename |
| 363 | + and sample_data.token in self._sample_data_to_lidarseg_filename |
| 364 | + ): |
| 365 | + label_filename = self._sample_data_to_lidarseg_filename[sample_data.token] |
| 366 | + pointcloud = SegmentationPointCloud.from_file( |
| 367 | + point_filepath=osp.join(self._t4.data_root, sample_data.filename), |
| 368 | + label_filepath=osp.join(self._t4.data_root, label_filename), |
| 369 | + ) |
| 370 | + else: |
| 371 | + pointcloud = LidarPointCloud.from_file( |
| 372 | + osp.join(self._t4.data_root, sample_data.filename) |
| 373 | + ) |
| 374 | + |
358 | 375 | viewer.render_pointcloud( |
359 | 376 | seconds=microseconds2seconds(sample_data.timestamp), |
360 | 377 | channel=sample_data.channel, |
|
0 commit comments