def point_clouds(flags, data): """ Converts depth maps to point clouds and merges them all into one global point cloud. flags: command line arguments data: dict with keys ['intrinsics', 'poses'] returns: [open3d.geometry.PointCloud] """ pcs = [] intrinsics = get_intrinsics(data['intrinsics']) pc = o3d.geometry.PointCloud() meshes = [] 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)): if i % flags.every != 0: continue print(f"Point cloud {i}", end="\r") T_CW = np.linalg.inv(T_WC) confidence = load_confidence(os.path.join(flags.path, 'confidence', f'{i:06}.png')) depth_path = data['depth_frames'][i] depth = load_depth(depth_path, confidence, filter_level=flags.confidence) 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) pc += o3d.geometry.PointCloud.create_from_rgbd_image(rgbd, intrinsics, extrinsic=T_CW) return [pc]