Esempio n. 1
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        reconstructions = data.load_reconstruction()
        no_cameras = args.no_cameras
        no_points = args.no_points
        _all = args.all
        path_all = args.dataset + "/reconstruction_files/"

        if reconstructions and not _all:
            data.save_ply(reconstructions[0], None, no_cameras, no_points)

        elif reconstructions and _all:
            if not os.path.isdir(path_all):
                os.mkdir(path_all)
            for r in range(len(reconstructions)):
                data.save_ply(
                    reconstructions[r],
                    "reconstruction_files/reconstruction_" + str(r) + ".ply",
                    no_cameras, no_points)

        if args.depthmaps and reconstructions:
            udata = dataset.UndistortedDataSet(data, 'undistorted')
            for id, shot in reconstructions[0].shots.items():
                rgb = udata.load_undistorted_image(id)
                for t in ('clean', 'raw'):
                    path_depth = udata._depthmap_file(id, t + '.npz')
                    if not os.path.exists(path_depth):
                        continue
                    depth = np.load(path_depth)['depth']
                    rgb = scale_down_image(rgb, depth.shape[1], depth.shape[0])
                    ply = depthmap_to_ply(shot, depth, rgb)
                    with io.open_wt(udata._depthmap_file(id,
                                                         t + '.ply')) as fout:
                        fout.write(ply)
Esempio n. 2
0
def run_dataset(data, no_cameras, no_points, depthmaps):
    """ Export reconstruction to PLY format

    Args:
        no_cameras: do not save camera positions
        no_points: do not save points
        depthmaps: export per-image depthmaps as pointclouds

    """

    reconstructions = data.load_reconstruction()
    no_cameras = no_cameras
    no_points = no_points

    if reconstructions:
        data.save_ply(reconstructions[0], None, no_cameras, no_points)

    if depthmaps and reconstructions:
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        for id, shot in reconstructions[0].shots.items():
            rgb = udata.load_undistorted_image(id)
            for t in ('clean', 'raw'):
                path_depth = udata._depthmap_file(id, t + '.npz')
                if not os.path.exists(path_depth):
                    continue
                depth = np.load(path_depth)['depth']
                rgb = scale_down_image(rgb, depth.shape[1], depth.shape[0])
                ply = depthmap_to_ply(shot, depth, rgb)
                with io.open_wt(udata._depthmap_file(id, t + '.ply')) as fout:
                    fout.write(ply)
Esempio n. 3
0
    def run(self, file_path, opensfm_config, self_compute=False, self_path=''):
        #data = dataset.DataSet(args.dataset)
        reconstructions = opensfm_interface.load_reconstruction(file_path)
        no_cameras = True
        no_points = False

        if reconstructions:
            self.save_ply(file_path, reconstructions[0], None, no_cameras,
                          no_points)

        if False and reconstructions:
            udata = opensfm_interface.UndistortedDataSet(
                file_path, opensfm_config, 'undistorted', self_compute,
                self_path)
            for id, shot in reconstructions[0].shots.items():
                rgb = udata.load_undistorted_image(id)
                for t in ('clean', 'raw'):
                    path_depth = udata._depthmap_file(id, t + '.npz')
                    if not os.path.exists(path_depth):
                        continue
                    depth = np.load(path_depth)['depth']
                    rgb = scale_down_image(rgb, depth.shape[1], depth.shape[0])
                    ply = depthmap_to_ply(shot, depth, rgb)
                    with io.open_wt(udata._depthmap_file(id,
                                                         t + '.ply')) as fout:
                        fout.write(ply)
Esempio n. 4
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        reconstructions = data.load_reconstruction()
        no_cameras = args.no_cameras
        no_points = args.no_points

        if reconstructions:
            data.save_ply(reconstructions[0], None, no_cameras, no_points)

        if args.depthmaps and reconstructions:
            for id, shot in reconstructions[0].shots.items():
                rgb = data.load_undistorted_image(id)
                for t in ('clean', 'raw'):
                    path_depth = data._depthmap_file(id, t + '.npz')
                    if not os.path.exists(path_depth):
                        continue
                    depth = np.load(path_depth)['depth']
                    rgb = scale_down_image(rgb, depth.shape[1], depth.shape[0])
                    ply = depthmap_to_ply(shot, depth, rgb)
                    with io.open_wt(data._depthmap_file(id, t + '.ply')) as fout:
                        fout.write(ply)
Esempio n. 5
0
def run_dataset(data: DataSet, no_cameras, no_points, depthmaps,
                point_num_views):
    """Export reconstruction to PLY format

    Args:
        no_cameras: do not save camera positions
        no_points: do not save points
        depthmaps: export per-image depthmaps as pointclouds
        point_num_views: Export the number of views associated with each point

    """

    reconstructions = data.load_reconstruction()
    tracks_manager = data.load_tracks_manager()
    no_cameras = no_cameras
    no_points = no_points
    point_num_views = point_num_views

    if reconstructions:
        data.save_ply(reconstructions[0], tracks_manager, None, no_cameras,
                      no_points, point_num_views)

    if depthmaps:
        udata = dataset.UndistortedDataSet(data)
        urec = udata.load_undistorted_reconstruction()[0]
        for shot in urec.shots.values():
            rgb = udata.load_undistorted_image(shot.id)
            for t in ("clean", "raw"):
                path_depth = udata.depthmap_file(shot.id, t + ".npz")
                if not os.path.exists(path_depth):
                    continue
                depth = np.load(path_depth)["depth"]
                rgb = scale_down_image(rgb, depth.shape[1], depth.shape[0])
                ply = depthmap_to_ply(shot, depth, rgb)
                with io.open_wt(udata.depthmap_file(shot.id,
                                                    t + ".ply")) as fout:
                    fout.write(ply)