12345678910111213141516171819202122232425262728293031323334 |
- def integrate(flags, data):
- """
- Integrates collected RGB-D maps using the Open3D integration pipeline.
- flags: command line arguments
- data: dict with keys ['intrinsics', 'poses']
- Returns: open3d.geometry.TriangleMesh
- """
- volume = o3d.pipelines.integration.ScalableTSDFVolume(
- voxel_length=flags.voxel_size,
- sdf_trunc=0.05,
- color_type=o3d.pipelines.integration.TSDFVolumeColorType.RGB8)
- intrinsics = get_intrinsics(data['intrinsics'])
- rgb_path = os.path.join(flags.path, 'rgb.mp4')
- video = skvideo.io.vreader(rgb_path)
- for i, (T_WC, rgb) in enumerate(zip(data['poses'], video)):
- print(f"Integrating frame {i:06}", end='\r')
- depth_path = data['depth_frames'][i]
- depth = load_depth(depth_path)
- rgb = Image.fromarray(rgb)
- rgb = rgb.resize((DEPTH_WIDTH, DEPTH_HEIGHT))
- rgb = np.array(rgb)
- rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth(
- o3d.geometry.Image(rgb), depth,
- depth_scale=1.0, depth_trunc=MAX_DEPTH, convert_rgb_to_intensity=False)
- volume.integrate(rgbd, intrinsics, np.linalg.inv(T_WC))
- mesh = volume.extract_triangle_mesh()
- mesh.compute_vertex_normals()
- return mesh
|