Render an ego-centric image view with annotations. Args: scene_name (str): Scene name. camera_name (str): The name of rendered camera frame. render_box (bool): Whether to render box annotations in the image. Defaults to False.
(self, scene_name, camera_name, render_box=False)
| 505 | o3d.visualization.draw_geometries([frame, voxel_grid]) |
| 506 | |
| 507 | def show_image(self, scene_name, camera_name, render_box=False): |
| 508 | """Render an ego-centric image view with annotations. |
| 509 | |
| 510 | Args: |
| 511 | scene_name (str): Scene name. |
| 512 | camera_name (str): The name of rendered camera frame. |
| 513 | render_box (bool): Whether to render box annotations in the image. |
| 514 | Defaults to False. |
| 515 | """ |
| 516 | dataset = scene_name.split('/')[0] |
| 517 | select = None |
| 518 | for scene in self.data: |
| 519 | if scene['sample_idx'] == scene_name: |
| 520 | select = scene |
| 521 | for camera in select['images']: |
| 522 | img_path = camera['img_path'] |
| 523 | img_path = os.path.join(self.data_root[dataset], |
| 524 | img_path[img_path.find('/') + 1:]) |
| 525 | if dataset == 'scannet': |
| 526 | cam_name = img_path.split('/')[-1][:-4] |
| 527 | elif dataset == '3rscan': |
| 528 | cam_name = img_path.split('/')[-1][:-10] |
| 529 | elif dataset == 'matterport3d': |
| 530 | cam_name = img_path.split('/')[-1][:-8] + img_path.split( |
| 531 | '/')[-1][-7:-4] |
| 532 | else: |
| 533 | cam_name = img_path.split('/')[-1][:-4] |
| 534 | if cam_name == camera_name: |
| 535 | axis_align_matrix = select['axis_align_matrix'] |
| 536 | extrinsic = axis_align_matrix @ camera['cam2global'] |
| 537 | if 'cam2img' in camera: |
| 538 | intrinsic = camera['cam2img'] |
| 539 | else: |
| 540 | intrinsic = select['cam2img'] |
| 541 | img_drawer = ImageDrawer(img_path, verbose=self.verbose) |
| 542 | if render_box: |
| 543 | if self.verbose: |
| 544 | print('Rendering box') |
| 545 | for i in camera['visible_instance_ids']: |
| 546 | instance = select['instances'][i] |
| 547 | box = _9dof_to_box( |
| 548 | instance['bbox_3d'], self.classes[self.id_to_index[ |
| 549 | instance['bbox_label_3d']]], |
| 550 | self.color_selector) |
| 551 | label = self.classes[self.id_to_index[ |
| 552 | instance['bbox_label_3d']]] |
| 553 | color = self.color_selector.get_color(label) |
| 554 | img_drawer.draw_box3d(box, |
| 555 | color, |
| 556 | label, |
| 557 | extrinsic=extrinsic, |
| 558 | intrinsic=intrinsic) |
| 559 | if self.verbose: |
| 560 | print('Rendering complete') |
| 561 | |
| 562 | img_drawer.show() |
| 563 | return |
| 564 |
no test coverage detected