def run(self, args): start = time.time() data = dataset.DataSet(args.dataset) reconstruction.incremental_reconstruction(data) end = time.time() with open(data.profile_log(), 'a') as fout: fout.write('reconstruct: {0}\n'.format(end - start))
def run(self, args): start = time.time() data = dataset.DataSet(args.dataset) # experiments directory tree given if args.experiments: # check that directory exists if not os.path.isdir(args.experiments): print '--experiments option given but directory does not exist.' return # find yaml files in experiments directory yamls = glob.glob(os.path.join(args.experiments, '*.yaml')) if not yamls: print 'No yaml files found in ', args.experiments return for yaml in yamls: # setup data = dataset.DataSet(args.dataset) config_path = os.path.join(args.experiments, yaml) self.override_config(data, config_path) data.config['experiments_path'] = args.experiments start = time.time() # run recon if data.config.get('tag_tracks', False) or data.config.get( 'resection_with_tags', False): reconstruction.incremental_reconstruction_with_tags(data) else: reconstruction.incremental_reconstruction(data) # shutdown end = time.time() reconstruction_name = data.reconstruction_name_from_settings() log_path = os.path.join(args.experiments, reconstruction_name + '.log') with open(log_path, 'w') as fout: fout.write('reconstruct: {0}\n'.format(end - start)) # normal run else: # reconstruction type if data.config.get('tag_tracks', False) or data.config.get( 'resection_with_tags', False): reconstruction.incremental_reconstruction_with_tags(data) else: reconstruction.incremental_reconstruction(data) # profile end = time.time() with open(data.profile_log(), 'a') as fout: fout.write('reconstruct: {0}\n'.format(end - start))
def test_reconstruction_incremental( scene_synthetic: synthetic_scene.SyntheticInputData, ): reference = scene_synthetic.reconstruction dataset = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic.exifs, scene_synthetic.features, scene_synthetic.tracks_manager, ) _, reconstructed_scene = reconstruction.incremental_reconstruction( dataset, scene_synthetic.tracks_manager ) errors = synthetic_scene.compare(reference, reconstructed_scene[0]) assert reconstructed_scene[0].reference.lat == 47.0 assert reconstructed_scene[0].reference.lon == 6.0 assert errors["ratio_cameras"] == 1.0 assert 0.7 < errors["ratio_points"] < 1.0 assert 0 < errors["aligned_position_rmse"] < 0.02 assert 0 < errors["aligned_rotation_rmse"] < 0.001 assert 0 < errors["aligned_points_rmse"] < 0.1 # Sanity check that GPS error is similar to the generated gps_noise assert 4.0 < errors["absolute_gps_rmse"] < 7.0
def test_reconstruction_incremental_rig( scene_synthetic_rig: synthetic_scene.SyntheticInputData, ): reference = scene_synthetic_rig.reconstruction dataset = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic_rig.exifs, scene_synthetic_rig.features, scene_synthetic_rig.tracks_manager, ) dataset.config["align_method"] = "orientation_prior" _, reconstructed_scene = reconstruction.incremental_reconstruction( dataset, scene_synthetic_rig.tracks_manager ) errors = synthetic_scene.compare(reference, reconstructed_scene[0]) assert reconstructed_scene[0].reference.lat == 47.0 assert reconstructed_scene[0].reference.lon == 6.0 assert errors["ratio_cameras"] == 1.0 assert 0.7 < errors["ratio_points"] < 1.0 assert 0 < errors["aligned_position_rmse"] < 0.005 assert 0 < errors["aligned_rotation_rmse"] < 0.001 assert 0 < errors["aligned_points_rmse"] < 0.05 assert 0 < errors["absolute_gps_rmse"] < 0.15
def test_reconstruction_incremental(scene_synthetic): reference = scene_synthetic[0].get_reconstruction() dataset = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic[1], scene_synthetic[2], scene_synthetic[3], scene_synthetic[4], scene_synthetic[5], ) _, reconstructed_scene = reconstruction.incremental_reconstruction( dataset, scene_synthetic[5] ) errors = synthetic_scene.compare(reference, reconstructed_scene[0]) assert errors["ratio_cameras"] == 1.0 assert 0.7 < errors["ratio_points"] < 1.0 assert 0 < errors["aligned_position_rmse"] < 0.02 assert 0 < errors["aligned_rotation_rmse"] < 0.001 assert 0 < errors["aligned_points_rmse"] < 0.1 # Sanity check that GPS error is similar to the generated gps_noise assert 4.0 < errors["absolute_gps_rmse"] < 7.0
def run_dataset(data): """ Compute the SfM reconstruction. """ tracks_manager = data.load_tracks_manager() report, reconstructions = reconstruction.incremental_reconstruction( data, tracks_manager) data.save_reconstruction(reconstructions) data.save_report(io.json_dumps(report), "reconstruction.json")
def run(self, args): start = time.time() data = dataset.DataSet(args.dataset) report = reconstruction.incremental_reconstruction(data) end = time.time() with open(data.profile_log(), 'a') as fout: fout.write('reconstruct: {0}, error: {1}, bundle time: {2}\n'.format(end - start, \ reconstruction.get_avg_reprojection_error(), \ reconstruction.get_total_bundle_time())) data.save_report(io.json_dumps(report), 'reconstruction.json')
def test_reconstruction_incremental_rig(scene_synthetic_rig): reference = scene_synthetic_rig[0].get_reconstruction() dataset = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic_rig[1], scene_synthetic_rig[2], scene_synthetic_rig[3], scene_synthetic_rig[4], scene_synthetic_rig[5], ) _, reconstructed_scene = reconstruction.incremental_reconstruction( dataset, scene_synthetic_rig[5] ) errors = synthetic_scene.compare(reference, reconstructed_scene[0])
def run_dataset(data: DataSetBase, algorithm: reconstruction.ReconstructionAlgorithm) -> None: """Compute the SfM reconstruction.""" tracks_manager = data.load_tracks_manager() if algorithm == reconstruction.ReconstructionAlgorithm.INCREMENTAL: report, reconstructions = reconstruction.incremental_reconstruction( data, tracks_manager) elif algorithm == reconstruction.ReconstructionAlgorithm.TRIANGULATION: report, reconstructions = reconstruction.triangulation_reconstruction( data, tracks_manager) else: raise RuntimeError( f"Unsupported algorithm for reconstruction {algorithm}") data.save_reconstruction(reconstructions) data.save_report(io.json_dumps(report), "reconstruction.json")
def test_reconstruction_incremental( scene_synthetic: synthetic_scene.SyntheticInputData, ) -> None: reference = scene_synthetic.reconstruction dataset = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic.exifs, scene_synthetic.features, scene_synthetic.tracks_manager, scene_synthetic.gcps, ) dataset.config["bundle_compensate_gps_bias"] = True dataset.config["bundle_use_gcp"] = True _, reconstructed_scene = reconstruction.incremental_reconstruction( dataset, scene_synthetic.tracks_manager) errors = synthetic_scene.compare( reference, scene_synthetic.gcps, reconstructed_scene[0], ) assert reconstructed_scene[0].reference.lat == 47.0 assert reconstructed_scene[0].reference.lon == 6.0 assert errors["ratio_cameras"] == 1.0 assert 0.7 < errors["ratio_points"] < 1.0 assert 0 < errors["aligned_position_rmse"] < 0.03 assert 0 < errors["aligned_rotation_rmse"] < 0.002 assert 0 < errors["aligned_points_rmse"] < 0.1 # Sanity check that GPS error is similar to the generated gps_noise assert 4.0 < errors["absolute_gps_rmse"] < 7.0 # Sanity check that GCP error is similar to the generated gcp_noise assert 0.01 < errors["absolute_gcp_rmse_horizontal"] < 0.03 assert 0.08 < errors["absolute_gcp_rmse_vertical"] < 0.18 # Check that the GPS bias (only translation) is recovered translation = reconstructed_scene[0].biases["1"].translation assert 9.9 < translation[0] < 10.31 assert 99.9 < translation[2] < 100.2
def test_reconstruction_incremental_rig(scene_synthetic_rig): reference = scene_synthetic_rig[0].get_reconstruction() dataset = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic_rig[1], scene_synthetic_rig[2], scene_synthetic_rig[3], scene_synthetic_rig[4], scene_synthetic_rig[5], ) dataset.config["align_method"] = "orientation_prior" _, reconstructed_scene = reconstruction.incremental_reconstruction( dataset, scene_synthetic_rig[5]) errors = synthetic_scene.compare(reference, reconstructed_scene[0]) assert errors["ratio_cameras"] == 1.0 assert 0.7 < errors["ratio_points"] < 1.0 assert 0 < errors["aligned_position_rmse"] < 0.005 assert 0 < errors["aligned_rotation_rmse"] < 0.001 assert 0 < errors["aligned_points_rmse"] < 0.05 assert 0 < errors["absolute_gps_rmse"] < 0.15
data.config['seg_path'] = seg_path # data.config['label'] = 1 # reconstruction.incremental_reconstruction(data, graphs[1]) scene_reconstructions = {} for label in graphs: data.config['label'] = label try: # with open(seg_path + '/OpenSfM/' + 'reconstruction{:02d}.json'.format(label)) as f: reconstructions = data.load_reconstruction() except: reconstruction.incremental_reconstruction(data, graph=graphs[label], my_init=my_init) reconstructions = data.load_reconstruction() if (save_mesh): for i, r in enumerate(reconstructions): for shot in r.shots.values(): if shot.id in graphs[label]: vertices, faces = mesh.triangle_mesh( shot.id, r, graphs[label], data) shot.mesh = types.ShotMesh() shot.mesh.vertices = vertices shot.mesh.faces = faces data.save_reconstruction(reconstructions, filename='reconstruction.meshed.json')