Ejemplo n.º 1
0
def run_dataset(data: DataSet, points, image_list, output, undistorted):
    """Export reconstruction to PLY format

    Args:
        points: export points
        image_list: export only the shots included in this file (path to .txt file)
        output: output pmvs directory
        undistorted: export the undistorted reconstruction

    """

    udata = data.undistorted_dataset()

    base_output_path = output if output else os.path.join(
        data.data_path, "pmvs")
    io.mkdir_p(base_output_path)
    logger.info("Converting dataset [%s] to PMVS dir [%s]" %
                (data.data_path, base_output_path))

    if undistorted:
        reconstructions = udata.load_undistorted_reconstruction()
    else:
        reconstructions = data.load_reconstruction()

    # load tracks for vis.dat
    try:
        if undistorted:
            tracks_manager = udata.load_undistorted_tracks_manager()
        else:
            tracks_manager = data.load_tracks_manager()
        image_graph = tracking.as_weighted_graph(tracks_manager)
    except IOError:
        image_graph = None

    export_only = None
    if image_list:
        export_only = {}
        with open(image_list, "r") as f:
            for image in f:
                export_only[image.strip()] = True

    for h, reconstruction in enumerate(reconstructions):
        export(
            reconstruction,
            h,
            image_graph,
            # pyre-fixme[61]: `tracks_manager` may not be initialized here.
            tracks_manager,
            base_output_path,
            data,
            undistorted,
            udata,
            points,
            export_only,
        )
Ejemplo n.º 2
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, 'undistorted')

        base_output_path = args.output if args.output else os.path.join(data.data_path, 'pmvs')
        io.mkdir_p(base_output_path)
        logger.info("Converting dataset [%s] to PMVS dir [%s]" % (
            data.data_path, base_output_path))

        if args.undistorted:
            reconstructions = udata.load_undistorted_reconstruction()
        else:
            reconstructions = data.load_reconstruction()

        # load tracks for vis.dat
        try:
            if args.undistorted:
                tracks_manager = udata.load_undistorted_tracks_manager()
            else:
                tracks_manager = data.load_tracks_manager()
            image_graph = tracking.as_weighted_graph(tracks_manager)
        except IOError:
            image_graph = None

        export_only = None
        if args.image_list:
            export_only = {}
            with open(args.image_list, 'r') as f:
                for image in f:
                    export_only[image.strip()] = True

        for h, reconstruction in enumerate(reconstructions):
            self.export(reconstruction, h,
                        image_graph, tracks_manager,
                        base_output_path, data,
                        args.undistorted, udata,
                        args.points, export_only)