Commit b199fdb6 authored by Jay's avatar Jay
Browse files

Testing for save/load functionality

parent 88e8ce63
Loading
Loading
Loading
Loading
+1 −1
Changes for autocnet/graph/edge.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ class Edge(dict, MutableMapping):

        self['fundamental_matrix'], fmask = fm.compute_fundamental_matrix(s_keypoints, d_keypoints, **kwargs)

        if self['fundamental_matrix'] != None:
        if isinstance(self['fundamental_matrix'], np.ndarray):
            # Convert the truncated RANSAC mask back into a full length mask
            mask[mask] = fmask

+4 −4
Changes for autocnet/io/network.py: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -54,9 +54,9 @@ def save(network, projectname):
            grp = data['node_id']
            np.savez('{}.npz'.format(data['node_id']),
                     descriptors=data.descriptors,
                     _keypoints=data._keypoints,
                     _keypoints_idx=data._keypoints.index,
                     _keypoints_columns=data._keypoints.columns)
                     keypoints=data._keypoints,
                     keypoints_idx=data._keypoints.index,
                     keypoints_columns=data._keypoints.columns)
            pzip.write('{}.npz'.format(data['node_id']))
            os.remove('{}.npz'.format(data['node_id']))

@@ -112,7 +112,7 @@ def load(projectname):
            edge.source = cg.node[e['source']]
            edge.destination = cg.node[e['target']]
            edge['fundamental_matrix'] = e['fundamental_matrix']
            edge['weight'] = e['weight']
            edge['weights'] = e['weights']
            nzf = np.load(BytesIO(pzip.read('{}_{}.npz'.format(e['source'], e['target']))))

            edge._masks = pd.DataFrame(nzf['_masks'], index=nzf['_masks_idx'], columns=nzf['_masks_columns'])
+25 −0
Changes for functional_tests/test_save_load.py: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
from autocnet.examples import get_path
from autocnet.graph.network import CandidateGraph
from autocnet.io.network import load

def test_save_project(tmpdir):
    path = tmpdir.join('prject.proj')
    #Point to the adjacency Graph
    adjacency = get_path('three_image_adjacency.json')
    basepath = get_path('Apollo15')
    cg = CandidateGraph.from_adjacency(adjacency, basepath=basepath)

    #Apply SIFT to extract features
    cg.extract_features(method='sift', extractor_parameters={'nfeatures':500})

    #Match
    cg.match()

    cg.symmetry_checks()
    cg.ratio_checks()
    cg.compute_fundamental_matrices(clean_keys=['ratio', 'symmetry'], method='ransac')

    cg.save(path.strpath)
    cg2 = load(path.strpath)

    assert cg == cg2