def test_tracks_io(): d = data_generation.CubeDataset(2, 100, 0.0, 0.3) output = StringIO() tracks_before = d.tracks opensfm.tracking.save_tracks_graph(output, tracks_before) output.seek(0) tracks_after = opensfm.tracking.load_tracks_graph(output) assert tracks_before.nodes() == tracks_after.nodes() assert tracks_before.edges() == tracks_after.edges()
def synthetic_reconstruction(): cube_dataset = data_generation.CubeDataset(10, 100, 0.001, 0.3) synthetic_reconstruction = types.Reconstruction() for shot in cube_dataset.shots.values(): synthetic_reconstruction.add_shot(shot) for camera in cube_dataset.cameras.values(): synthetic_reconstruction.add_camera(camera) for point_id, point in cube_dataset.points.items(): point_type = types.Point() point_type.coordinates = point point_type.id = point_id synthetic_reconstruction.add_point(point_type) return synthetic_reconstruction, cube_dataset.tracks
def test_robust_match(): d = data_generation.CubeDataset(2, 100, 0.1, 0.3) p1 = np.array([v['feature'] for k, v in d.tracks['shot0'].iteritems()]) p2 = np.array([v['feature'] for k, v in d.tracks['shot1'].iteritems()]) camera1 = d.shots['shot0'].camera camera2 = d.shots['shot1'].camera num_points = len(p1) inlier_matches = np.array([(i, i) for i in range(num_points)]) outlier_matches = np.random.randint(num_points, size=(num_points / 2, 2)) matches = np.concatenate((inlier_matches, outlier_matches)) config = opensfm.config.default_config() rmatches = opensfm.matching.robust_match(p1, p2, camera1, camera2, matches, config) assert num_points <= len(rmatches) <= len(matches)