Loading files
35d5ba9d5This file is pinned to the selected release. Download the original to open it in your design tool.
#!/usr/bin/env python
import os.path, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import argparse
import json
import numpy as np
import opensfm.dataset as dataset
import opensfm.io as io
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Convert OpenSfM reconstructions to Bundler output format')
parser.add_argument('dataset', help='path to the dataset to be processed')
parser.add_argument('--list_path', help='path to the list.txt file')
parser.add_argument('--bundle_path', help='path to the bundle.out file')
parser.add_argument('--undistorted',
action='store_true',
help='export the undistorted reconstruction')
args = parser.parse_args()
# Assume that bundle.out, list.txt and all the images are in datapath
data_path = args.dataset
# converting reconstruction from bundler to OpenSfM reconstruction
if args.list_path:
list_file_path = args.list_path
else:
list_file_path = data_path
if args.bundle_path:
bundle_file_path = args.bundle_path
else:
bundle_file_path = data_path
data = dataset.DataSet(args.dataset)
images = data.images()
if args.undistorted:
reconstructions = data.load_undistorted_reconstruction()
track_graph = data.load_undistorted_tracks_graph()
images = reconstructions[0].shots.keys()
else:
reconstructions = data.load_reconstruction()
track_graph = data.load_tracks_graph()
images = data.images()
io.export_bundler(images, reconstructions, track_graph, bundle_file_path, list_file_path)