Render a given scene with open3d. Args: scene_name (str): Scene name. render_box (bool): Whether to render the box in the scene. Defaults to False.
(self, scene_name, render_box=False)
| 231 | return None |
| 232 | |
| 233 | def render_scene(self, scene_name, render_box=False): |
| 234 | """Render a given scene with open3d. |
| 235 | |
| 236 | Args: |
| 237 | scene_name (str): Scene name. |
| 238 | render_box (bool): Whether to render the box in the scene. |
| 239 | Defaults to False. |
| 240 | """ |
| 241 | s = scene_name.split('/') |
| 242 | if len(s) == 2: |
| 243 | dataset, region = s |
| 244 | else: |
| 245 | dataset, building, region = s |
| 246 | select = None |
| 247 | for scene in self.data: |
| 248 | if scene['sample_idx'] == scene_name: |
| 249 | select = scene |
| 250 | break |
| 251 | axis_align_matrix = select['axis_align_matrix'] |
| 252 | if dataset == 'scannet': |
| 253 | filepath = os.path.join(self.data_root['scannet'], 'scans', region, |
| 254 | f'{region}_vh_clean.ply') |
| 255 | elif dataset == '3rscan': |
| 256 | filepath = os.path.join(self.data_root['3rscan'], region, |
| 257 | 'mesh.refined.v2.obj') |
| 258 | elif dataset == 'matterport3d': |
| 259 | filepath = os.path.join(self.data_root['matterport3d'], building, |
| 260 | 'region_segmentations', f'{region}.ply') |
| 261 | elif dataset == 'arkitscenes': |
| 262 | filepath = os.path.join(self.data_root['arkitscenes'], building, |
| 263 | region, f'{region}_3dod_mesh.ply') |
| 264 | else: |
| 265 | raise NotImplementedError |
| 266 | |
| 267 | if self.verbose: |
| 268 | print('Loading mesh') |
| 269 | mesh = o3d.io.read_triangle_mesh(filepath, True) |
| 270 | mesh.transform(axis_align_matrix) |
| 271 | frame = o3d.geometry.TriangleMesh.create_coordinate_frame() |
| 272 | if self.verbose: |
| 273 | print('Loading complete') |
| 274 | boxes = [] |
| 275 | if render_box: |
| 276 | if self.verbose: |
| 277 | print('Rendering box') |
| 278 | for instance in select['instances']: |
| 279 | box = _9dof_to_box( |
| 280 | instance['bbox_3d'], |
| 281 | self.classes[self.id_to_index[instance['bbox_label_3d']]], |
| 282 | self.color_selector) |
| 283 | boxes += _box_add_thickness(box, self.thickness) |
| 284 | if self.verbose: |
| 285 | print('Rendering complete') |
| 286 | o3d.visualization.draw_geometries([mesh, frame] + boxes) |
| 287 | |
| 288 | def render_continuous_scene(self, |
| 289 | scene_name, |
nothing calls this directly
no test coverage detected