MCPcopy Create free account
hub / github.com/InternRobotics/EmbodiedScan / render_occupancy

Method render_occupancy

embodiedscan/explorer.py:450–505  ·  view source on GitHub ↗

Render the occupancy annotation of a given scene. Args: scene_name (str): Scene name.

(self, scene_name)

Source from the content-addressed store, hash-verified

448 drawer.begin()
449
450 def render_occupancy(self, scene_name):
451 """Render the occupancy annotation of a given scene.
452
453 Args:
454 scene_name (str): Scene name.
455 """
456 s = scene_name.split('/')
457 if len(s) == 2:
458 dataset, region = s
459 else:
460 dataset, building, region = s
461
462 if dataset == 'scannet':
463 filepath = os.path.join(self.data_root['scannet'], 'scans', region,
464 'occupancy', 'occupancy.npy')
465 elif dataset == '3rscan':
466 filepath = os.path.join(self.data_root['3rscan'], region,
467 'occupancy', 'occupancy.npy')
468 elif dataset == 'matterport3d':
469 filepath = os.path.join(self.data_root['matterport3d'], building,
470 'occupancy', f'occupancy_{region}.npy')
471 else:
472 raise NotImplementedError
473
474 if self.verbose:
475 print('Loading occupancy')
476 gt_occ = np.load(filepath)
477 if self.verbose:
478 print('Loading complete')
479 point_cloud_range = [-3.2, -3.2, -1.28 + 0.5, 3.2, 3.2, 1.28 + 0.5]
480 # occ_size = [40, 40, 16]
481 grid_size = [0.16, 0.16, 0.16]
482 points = np.zeros((gt_occ.shape[0], 6), dtype=float)
483 for i in range(gt_occ.shape[0]):
484 x, y, z, label_id = gt_occ[i]
485 label_id = int(label_id)
486 label = 'object'
487 if label_id == 0:
488 label = 'object'
489 else:
490 label = self.classes[self.id_to_index[label_id]]
491 color = self.color_selector.get_color(label)
492 color = [x / 255.0 for x in color]
493 points[i][:3] = [
494 x * grid_size[0] + point_cloud_range[0] + grid_size[0] / 2,
495 y * grid_size[1] + point_cloud_range[1] + grid_size[1] / 2,
496 z * grid_size[2] + point_cloud_range[2] + grid_size[2] / 2
497 ]
498 points[i][3:] = color
499 pcd = o3d.geometry.PointCloud()
500 pcd.points = o3d.utility.Vector3dVector(points[:, :3])
501 pcd.colors = o3d.utility.Vector3dVector(points[:, 3:])
502 voxel_grid = o3d.geometry.VoxelGrid.create_from_point_cloud(
503 pcd, voxel_size=grid_size[0])
504 frame = o3d.geometry.TriangleMesh.create_coordinate_frame()
505 o3d.visualization.draw_geometries([frame, voxel_grid])
506
507 def show_image(self, scene_name, camera_name, render_box=False):

Callers

nothing calls this directly

Calls 2

get_colorMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected