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 argparse
import os
import multiprocessing
from opensfm import reconstruction
from opensfm import io
from opensfm.synthetic_data import synthetic_dataset
from opensfm.synthetic_data import synthetic_scene
def construct_scene(scene_type, scene_length):
points_count = 10000
generator = synthetic_scene.get_scene_generator(scene_type, scene_length)
scene = synthetic_scene.SyntheticScene(generator)
scene.add_street(points_count, 7, 7).perturb_floor([0, 0, 0.1]).\
perturb_walls([0.2, 0.2, 0.01])
camera_height = 1.5
camera_interval = 3
position_perturbation = [0.2, 0.2, 0.01]
rotation_perturbation = 0.3
camera = synthetic_scene.get_camera('perspective', '1', 0.9, -0.1, 0.01)
scene.add_camera_sequence(camera, 0, scene_length,
camera_height, camera_interval,
position_perturbation,
rotation_perturbation)
return scene
def frange(x, y, jump):
while x < y:
yield x
x += jump
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Reconstruct a synthetic\
scene and evaluate its quality over different image noise\
and different GPS noise')
parser.add_argument('--type',
choices=['ellipse', 'line', 'curve'],
default='ellipse',
help='type of street geometry')
parser.add_argument('--length',
default=100,
type=int,
help='street length in meters')
parser.add_argument('--image_noise',
default=3.0,
type=float,
help='maximum image noise')
parser.add_argument('--gps_noise',
default=10.0,
type=float,
help='maximum GPS noise')
parser.add_argument('--output',
default='./',
help='output directory of errors files')
args = parser.parse_args()
scene = construct_scene(args.type, args.length)
reference = scene.get_reconstruction()
maximum_depth = 40
position_file = open(os.path.join(args.output, 'stats_cameras.txt'), 'w')
points_file = open(os.path.join(args.output, 'stats_points.txt'), 'w')
for projection_noise in frange(0.0, args.image_noise, 0.5):
features, desc, colors, graph = scene.get_tracks_data(maximum_depth,
projection_noise)
exifs = scene.get_scene_exifs(args.gps_noise)
dataset = synthetic_dataset.SyntheticDataSet(reference, exifs,
features, desc,
colors, graph)
dataset.config['processes'] = multiprocessing.cpu_count()
_, reconstructed_scene = reconstruction.\
incremental_reconstruction(dataset, graph)
errors = scene.compare(reconstructed_scene[0])
position_file.write('%f, %f\n' % (projection_noise,
errors['position_average'] +
errors['position_std']))
points_file.write('%f, %f\n' % (projection_noise,
errors['points_average'] +
errors['points_std']))
position_file.close()
points_file.close()