コード例 #1
0
ファイル: export_bundler.py プロジェクト: wulun0102/OpenSfM
def run_dataset(data, list_path, bundle_path, undistorted):
    """ Export reconstruction to bundler format.

    Args:
        list_path: txt list of images to export
        bundle_path : output path
        undistorted : export undistorted reconstruction

    """

    udata = dataset.UndistortedDataSet(data, 'undistorted')

    default_path = os.path.join(data.data_path, 'bundler')
    list_file_path = list_path if list_path else default_path
    bundle_file_path = bundle_path if bundle_path else default_path

    if undistorted:
        reconstructions = udata.load_undistorted_reconstruction()
        track_manager = udata.load_undistorted_tracks_manager()
        images = reconstructions[0].shots.keys()
    else:
        reconstructions = data.load_reconstruction()
        track_manager = data.load_tracks_manager()
        images = data.images()

    io.export_bundler(images, reconstructions, track_manager, bundle_file_path,
                      list_file_path)
コード例 #2
0
ファイル: undistort.py プロジェクト: whuaegeanse/OpenSfM
def run_dataset(data: DataSet, reconstruction, reconstruction_index, tracks,
                output):
    """Export reconstruction to NVM_V3 format from VisualSfM

    Args:
        reconstruction: reconstruction to undistort
        reconstruction_index: index of the reconstruction component to undistort
        tracks: tracks graph of the reconstruction
        output: undistorted

    """
    undistorted_data_path = os.path.join(data.data_path, output)
    udata = dataset.UndistortedDataSet(data,
                                       undistorted_data_path,
                                       io_handler=data.io_handler)
    reconstructions = data.load_reconstruction(reconstruction)
    if data.tracks_exists(tracks):
        tracks_manager = data.load_tracks_manager(tracks)
    else:
        tracks_manager = None

    if reconstructions:
        r = reconstructions[reconstruction_index]
        undistort.undistort_reconstruction_and_images(tracks_manager, r, data,
                                                      udata)
コード例 #3
0
ファイル: export_ply.py プロジェクト: wulun0102/OpenSfM
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)
コード例 #4
0
ファイル: export_ply.py プロジェクト: ragarciafran/OpenSfM
    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)
コード例 #5
0
def run_dataset(
    data: DataSet,
    reconstruction: Optional[str] = None,
    reconstruction_index: int = 0,
    tracks: Optional[str] = None,
    output: str = "undistorted",
    skip_images: bool = False,
) -> None:
    """Export reconstruction to NVM_V3 format from VisualSfM

    Args:
        reconstruction: reconstruction to undistort
        reconstruction_index: index of the reconstruction component to undistort
        tracks: tracks graph of the reconstruction
        output: undistorted
        skip_images: do not undistort images
    """
    undistorted_data_path = os.path.join(data.data_path, output)
    udata = dataset.UndistortedDataSet(data,
                                       undistorted_data_path,
                                       io_handler=data.io_handler)
    reconstructions = data.load_reconstruction(reconstruction)
    if data.tracks_exists(tracks):
        tracks_manager = data.load_tracks_manager(tracks)
    else:
        tracks_manager = None

    if reconstructions:
        r = reconstructions[reconstruction_index]
        undistort.undistort_reconstruction_with_images(tracks_manager, r, data,
                                                       udata, skip_images)
コード例 #6
0
ファイル: compute_depthmaps.py プロジェクト: jm5948/test
    def run(self, args):
        data = dataset.DataSet(args)
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        data.config['interactive'] = args
        reconstructions = udata.load_undistorted_reconstruction()
        graph = udata.load_undistorted_tracks_graph()

        dense.compute_depthmaps(udata, graph, reconstructions[0])
コード例 #7
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, args.subfolder)
        data.config['interactive'] = args.interactive
        reconstructions = udata.load_undistorted_reconstruction()
        tracks_manager = udata.load_undistorted_tracks_manager()

        dense.compute_depthmaps(udata, tracks_manager, reconstructions[0])
コード例 #8
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        reconstructions = udata.load_undistorted_reconstruction()
        graph = udata.load_undistorted_tracks_graph()

        if reconstructions:
            self.export(reconstructions[0], graph, data)
コード例 #9
0
ファイル: export_openmvs.py プロジェクト: smarvar/sfm_smarvar
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        reconstructions = udata.load_undistorted_reconstruction()
        tracks_manager = udata.load_undistorted_tracks_manager()

        if reconstructions:
            self.export(reconstructions[0], tracks_manager, udata, data)
コード例 #10
0
ファイル: export_openmvs.py プロジェクト: silwalanish/OpenSfM
def run_dataset(data):
    """ Export reconstruction to OpenMVS format. """

    udata = dataset.UndistortedDataSet(data, 'undistorted')
    reconstructions = udata.load_undistorted_reconstruction()
    tracks_manager = udata.load_undistorted_tracks_manager()

    if reconstructions:
        export(reconstructions[0], tracks_manager, udata, data)
コード例 #11
0
ファイル: export_pmvs.py プロジェクト: ziweiWWANG/OpenSfM
def run_dataset(data, 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 = dataset.UndistortedDataSet(data)

    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,
            tracks_manager,
            base_output_path,
            data,
            undistorted,
            udata,
            points,
            export_only,
        )
コード例 #12
0
ファイル: undistort.py プロジェクト: jm5948/test
    def run(self, args):
        data = dataset.DataSet(args)
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        reconstructions = data.load_reconstruction(args)
        if data.tracks_exists(args):
            graph = data.load_tracks_graph(args)
        else:
            graph = None

        if reconstructions:
            self.undistort_reconstruction(graph, reconstructions[0], data, udata)
コード例 #13
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, args.output)
        reconstructions = data.load_reconstruction(args.reconstruction)
        if data.tracks_exists(args.tracks):
            tracks_manager = data.load_tracks_manager(args.tracks)
        else:
            tracks_manager = None

        if reconstructions:
            r = reconstructions[args.reconstruction_index]
            self.undistort_reconstruction(tracks_manager, r, data, udata)
コード例 #14
0
    def run(self, args):
        print(args)
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, args.output)
        reconstructions = data.load_reconstruction(args.reconstruction)
        if data.tracks_exists(args.tracks):
            graph = data.load_tracks_graph(args.tracks)
        else:
            graph = None

        if reconstructions:
            r = reconstructions[args.reconstruction_index]
            self.undistort_reconstruction(graph, r, data, udata)
コード例 #15
0
def run_dataset(data, subfolder, interactive):
    """ Compute depthmap on a dataset with has SfM ran already.

    Args:
        subfolder: dataset's subfolder where to store results
        interactive : display plot of computed depthmaps

    """

    udataset = dataset.UndistortedDataSet(data, subfolder)
    data.config['interactive'] = interactive
    reconstructions = udataset.load_undistorted_reconstruction()
    tracks_manager = udataset.load_undistorted_tracks_manager()
    dense.compute_depthmaps(udataset, tracks_manager, reconstructions[0])
コード例 #16
0
def run_dataset(data: DataSet, subfolder, interactive) -> None:
    """Compute depthmap on a dataset with has SfM ran already.

    Args:
        subfolder: dataset's subfolder where to store results
        interactive : display plot of computed depthmaps

    """

    udata_path = os.path.join(data.data_path, subfolder)
    udataset = dataset.UndistortedDataSet(data, udata_path, io_handler=data.io_handler)
    data.config["interactive"] = interactive
    reconstructions = udataset.load_undistorted_reconstruction()
    tracks_manager = udataset.load_undistorted_tracks_manager()
    dense.compute_depthmaps(udataset, tracks_manager, reconstructions[0])
コード例 #17
0
def run_dataset(data, proj, transformation, image_positions, reconstruction,
                dense, output):
    """ Export reconstructions in geographic coordinates

    Args:
        proj: PROJ.4 projection string
        transformation : print cooordinate transformation matrix'
        image_positions : export image positions
        reconstruction : export reconstruction.json
        dense : export dense point cloud (depthmaps/merged.ply)
        output : path of the output file relative to the dataset

    """

    if not (transformation or image_positions or reconstruction or dense):
        logger.info('Nothing to do. At least on of the options: ')
        logger.info(
            ' --transformation, --image-positions, --reconstruction, --dense')

    reference = data.load_reference()

    projection = pyproj.Proj(proj)
    transformation = _get_transformation(reference, projection)

    if transformation:
        output = output or 'geocoords_transformation.txt'
        output_path = os.path.join(data.data_path, output)
        _write_transformation(transformation, output_path)

    if image_positions:
        reconstructions = data.load_reconstruction()
        output = output or 'image_geocoords.tsv'
        output_path = os.path.join(data.data_path, output)
        _transform_image_positions(reconstructions, transformation,
                                   output_path)

    if reconstruction:
        reconstructions = data.load_reconstruction()
        for r in reconstructions:
            _transform_reconstruction(r, transformation)
        output = output or 'reconstruction.geocoords.json'
        data.save_reconstruction(reconstructions, output)

    if dense:
        output = output or 'undistorted/depthmaps/merged.geocoords.ply'
        output_path = os.path.join(data.data_path, output)
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        _transform_dense_point_cloud(udata, transformation, output_path)
コード例 #18
0
ファイル: export_openmvs.py プロジェクト: ziweiWWANG/OpenSfM
def run_dataset(data, image_list):
    """ Export reconstruction to OpenMVS format. """

    udata = dataset.UndistortedDataSet(data)
    reconstructions = udata.load_undistorted_reconstruction()
    tracks_manager = udata.load_undistorted_tracks_manager()

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

    if reconstructions:
        export(reconstructions[0], tracks_manager, udata, data, export_only)
コード例 #19
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, args.subfolder)

        data.config['interactive'] = args.interactive
        graph, neighbors_dict = None, None
        reconstructions = udata.load_undistorted_reconstruction()
        neighbors_path: Path = Path(data.data_path) / "neighbors.json"
        if neighbors_path.exists():
            with io.open_rt(neighbors_path) as fp:
                neighbors_dict = io.json_load(fp)
        else:
            graph = udata.load_undistorted_tracks_graph()

        dense.compute_depthmaps(udata, graph, reconstructions[0],
                                neighbors_dict)
コード例 #20
0
ファイル: export_visualsfm.py プロジェクト: wulun0102/OpenSfM
def run_dataset(data, points, image_list):
    udata = dataset.UndistortedDataSet(data, 'undistorted')

    validate_image_names(data, udata)

    reconstructions = udata.load_undistorted_reconstruction()
    tracks_manager = udata.load_undistorted_tracks_manager()

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

    if reconstructions:
        export(reconstructions[0], tracks_manager, udata, points, export_only)
コード例 #21
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, 'undistorted')

        reconstructions = udata.load_undistorted_reconstruction()
        graph = udata.load_undistorted_tracks_graph()

        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

        if reconstructions:
            self.export(reconstructions[0], graph, udata, args.points,
                        export_only)
コード例 #22
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, 'undistorted')

        self.validate_image_names(data, udata)

        reconstructions = udata.load_undistorted_reconstruction()
        tracks_manager = udata.load_undistorted_tracks_manager()

        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

        if reconstructions:
            self.export(reconstructions[0], tracks_manager, udata, args.points,
                        export_only)
コード例 #23
0
    def run(self, args):
        data = dataset.DataSet(args.dataset)
        udata = dataset.UndistortedDataSet(data, 'undistorted')

        default_path = os.path.join(data.data_path, 'bundler')
        list_file_path = args.list_path if args.list_path else default_path
        bundle_file_path = args.bundle_path if args.bundle_path else default_path

        if args.undistorted:
            reconstructions = udata.load_undistorted_reconstruction()
            track_manager = udata.load_undistorted_tracks_manager()
            images = reconstructions[0].shots.keys()
        else:
            reconstructions = data.load_reconstruction()
            track_manager = data.load_tracks_manager()
            images = data.images()

        io.export_bundler(images, reconstructions, track_manager,
                          bundle_file_path, list_file_path)
コード例 #24
0
def run_dataset(data, reconstruction, reconstruction_index, tracks, output):
    """Export reconstruction to NVM_V3 format from VisualSfM

    Args:
        reconstruction: reconstruction to undistort
        reconstruction_index: index of the reconstruction component to undistort
        tracks: tracks graph of the reconstruction
        output: undistorted

    """

    udata = dataset.UndistortedDataSet(data, output)
    reconstructions = data.load_reconstruction(reconstruction)
    if data.tracks_exists(tracks):
        tracks_manager = data.load_tracks_manager(tracks)
    else:
        tracks_manager = None

    if reconstructions:
        r = reconstructions[reconstruction_index]
        undistort_reconstruction(tracks_manager, r, data, udata)
コード例 #25
0
ファイル: export_geocoords.py プロジェクト: soon14/openSFMEx
    def run(self, args):
        if not (args.transformation or args.image_positions
                or args.reconstruction or args.dense):
            print('Nothing to do. At least on of the options: ')
            print(
                ' --transformation, --image-positions, --reconstruction, --dense'
            )

        data = dataset.DataSet(args.dataset)
        reference = data.load_reference()

        projection = pyproj.Proj(args.proj)
        transformation = self._get_transformation(reference, projection)

        if args.transformation:
            output = args.output or 'geocoords_transformation.txt'
            output_path = os.path.join(data.data_path, output)
            self._write_transformation(transformation, output_path)

        if args.image_positions:
            reconstructions = data.load_reconstruction()
            output = args.output or 'image_geocoords.tsv'
            output_path = os.path.join(data.data_path, output)
            self._transform_image_positions(reconstructions, transformation,
                                            output_path)

        if args.reconstruction:
            reconstructions = data.load_reconstruction()
            for r in reconstructions:
                self._transform_reconstruction(r, transformation)
            output = args.output or 'reconstruction.geocoords.json'
            data.save_reconstruction(reconstructions, output)

        if args.dense:
            output = args.output or 'undistorted/depthmaps/merged.geocoords.ply'
            output_path = os.path.join(data.data_path, output)
            udata = dataset.UndistortedDataSet(data, 'undistorted')
            self._transform_dense_point_cloud(udata, transformation,
                                              output_path)
コード例 #26
0
ファイル: export_pmvs.py プロジェクト: smarvar/sfm_smarvar
    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)
コード例 #27
0
ファイル: export_ply.py プロジェクト: HaifengDeng0709/OpenSfM
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)
コード例 #28
0
            print("Whoops! Cannot find %s (we need that!)" % coords_file)
            exit(1)

        with open(coords_file) as f:
            line = f.readline()  # discard

            # second line is a northing/easting offset
            line = f.readline().rstrip()
            dem_offset_x, dem_offset_y = map(float, line.split(" "))

        print("DEM offset: (%s, %s)" % (dem_offset_x, dem_offset_y))

    print("DEM dimensions: %sx%s pixels" % (w, h))

    # Read reconstruction
    udata = dataset.UndistortedDataSet(
        dataset.DataSet(os.path.join(dataset_path, "opensfm")))
    reconstructions = udata.load_undistorted_reconstruction()
    if len(reconstructions) == 0:
        raise Exception("No reconstructions available")

    max_workers = multiprocessing.cpu_count()
    print("Using %s threads" % max_workers)

    reconstruction = reconstructions[0]
    for shot in reconstruction.shots.values():
        if len(target_images) == 0 or shot.id in target_images:

            print("Processing %s..." % shot.id)
            shot_image = udata.load_undistorted_image(shot.id)

            r = shot.pose.get_rotation_matrix().T
コード例 #29
0
            print("Whoops! Cannot find %s (we need that!)" % coords_file)
            exit(1)
        
        with open(coords_file) as f:
            l = f.readline() # discard

            # second line is a northing/easting offset
            l = f.readline().rstrip()
            dem_offset_x, dem_offset_y = map(float, l.split(" "))
        
        print("DEM offset: (%s, %s)" % (dem_offset_x, dem_offset_y))

    print("DEM dimensions: %sx%s pixels" % (w, h))

    # Read reconstruction
    udata = dataset.UndistortedDataSet(dataset.DataSet(os.path.join(dataset_path, "opensfm")), undistorted_data_path=os.path.join(dataset_path, "opensfm", "undistorted"))
    reconstructions = udata.load_undistorted_reconstruction()
    if len(reconstructions) == 0:
        raise Exception("No reconstructions available")

    max_workers = args.threads
    print("Using %s threads" % max_workers)

    reconstruction = reconstructions[0]
    for shot in reconstruction.shots.values():
        if len(target_images) == 0 or shot.id in target_images:

            print("Processing %s..." % shot.id)
            shot_image = udata.load_undistorted_image(shot.id)

            r = shot.pose.get_rotation_matrix()
コード例 #30
0
def main():
    parser = argparse.ArgumentParser(
        description='Convert COLMAP database to OpenSfM dataset')
    parser.add_argument('database', help='path to the database to be processed')
    parser.add_argument('images', help='path to the images')
    args = parser.parse_args()
    logger.info(f"Converting {args.database} to COLMAP format")

    p_db = Path(args.database)
    assert p_db.is_file()

    export_folder = p_db.parent / EXPORT_DIR_NAME
    export_folder.mkdir(exist_ok=True)
    images_path = export_folder / 'images'
    if not images_path.exists():
        os.symlink(os.path.abspath(args.images), images_path, target_is_directory=True)

    # Copy the config if this is an colmap export of an opensfm export
    if p_db.parent.name == 'colmap_export' and not (export_folder/'config.yaml').exists():
        os.symlink(p_db.parent.parent / 'config.yaml', export_folder / 'config.yaml')

    data = dataset.DataSet(export_folder)
    db = sqlite3.connect(p_db.as_posix())
    camera_map, image_map = import_cameras_images(db, data)

    # Create image_list.txt
    with open(export_folder / 'image_list.txt', 'w') as f:
        for _, (filename, _) in image_map.items():
            f.write('images/' + filename + '\n')
    data.load_image_list()

    keypoints = import_features(db, data, image_map, camera_map)
    import_matches(db, data, image_map)


    rec_cameras = p_db.parent / 'cameras.bin'
    rec_points = p_db.parent / 'points3D.bin'
    rec_images = p_db.parent / 'images.bin'
    if rec_cameras.exists() and rec_images.exists() and rec_points.exists():
        reconstruction = types.Reconstruction()
        import_cameras_reconstruction(rec_cameras, reconstruction)
        import_points_reconstruction(rec_points, reconstruction)
        tracks_manager, _ = import_images_reconstruction(rec_images,
                                                         keypoints,
                                                         reconstruction)

        data.save_reconstruction([reconstruction])
        data.save_tracks_manager(tracks_manager)

        # Save undistorted reconstruction as well
        udata = dataset.UndistortedDataSet(data, 'undistorted')
        urec = compute_and_save_undistorted_reconstruction(reconstruction, tracks_manager, data, udata)

        # Project colmap's fused pointcloud to save depths in opensfm format
        path_ply = p_db.parent / 'dense/fused.ply'
        if path_ply.is_file():
            rec_cameras = p_db.parent / 'dense/sparse/cameras.bin'
            rec_images = p_db.parent / 'dense/sparse/images.bin'
            rec_points = p_db.parent / 'points3D.bin'
            reconstruction = types.Reconstruction()
            import_cameras_reconstruction(rec_cameras, reconstruction)
            import_points_reconstruction(rec_points, reconstruction)
            _, image_ix_to_shot_id = import_images_reconstruction(rec_images,
                                                                  keypoints,
                                                                  reconstruction)
            logger.info(f"Projecting {path_ply} to depth images")
            import_depthmaps_from_fused_pointcloud(udata, urec, image_ix_to_shot_id, path_ply)
        else:
            logger.info("Not importing dense reconstruction: Didn't find {}".format(path_ply))

    else:
        logger.info("Didn't find some of the reconstruction files at {}".format(p_db.parent))

    db.close()