Commit cfbcb66b authored by jlaura's avatar jlaura
Browse files

Merge pull request #70 from acpaquette/image_match

Image match
parents 5b423c31 47ef7791
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ omit =
    autocnet/fileio/ControlNetFileV0002_pb2.py
    autocnet/vis/graph_view.py
    autocnet/fileio/sqlalchemy_json/*
    bin/*
exclude_lines =
    pragma: no cover
    def __repr__
+4 −0
Original line number Diff line number Diff line
@@ -102,6 +102,10 @@ class CandidateGraph(nx.Graph):
        : object
          A Network graph object
        """
        if not isinstance(filelist, list):
            with open(filelist, 'r') as f:
                filelist = f.readlines()
                filelist = map(str.rstrip, filelist)

        # TODO: Reject unsupported file formats + work with more file formats

+36 −17
Original line number Diff line number Diff line
@@ -8,7 +8,24 @@ from autocnet.graph.network import CandidateGraph
from autocnet.fileio.io_controlnetwork import to_isis
from autocnet.fileio.io_controlnetwork import write_filelist

cg = CandidateGraph.from_adjacency(sys.argv[1], basepath='')
# parses command line arguments into a single args variable
def parse_arguments():
    parser = argparse.ArgumentParser()
    parser.add_argument('-i', action='store', dest='input_file', default='No_Input', help='Provide the name of the file list/adjacency list')
    parser.add_argument('-o', action='store', dest='output_file', help='Provide the name of the output file')
    parser.add_argument('-p', action='store', dest='basepath', help='Provide the path to the image files')
    args = parser.parse_args()

    return args

def match_images(args):

    # Matches the images in the input file using various candidate graph methods
    # produces two files usable in isis
    try:
        cg = CandidateGraph.from_adjacency(args.input_file, basepath=args.basepath)
    except:
        cg = CandidateGraph.from_filelist(args.input_file)

    # Apply SIFT to extract features
    cg.extract_features(method='sift', extractor_parameters={'nfeatures': 1000})
@@ -20,8 +37,6 @@ cg.match_features()
    cg.symmetry_checks()
    cg.ratio_checks()

m = cg.edge[0][1].masks

    # Compute a homography and apply RANSAC
    cg.compute_fundamental_matrices(clean_keys=['ratio', 'symmetry'])

@@ -32,6 +47,10 @@ cg.suppress(clean_keys=['fundamental'], k=50)
    cnet = cg.to_cnet(clean_keys=['subpixel'], isis_serials=True)

    filelist = cg.to_filelist()
write_filelist(filelist, 'TestList.lis')
    write_filelist(filelist, args.output_file + '.lis')

    to_isis(args.output_file + '.net', cnet, mode='wb', targetname='Moon')

to_isis('TestList.net', cnet, mode='wb', targetname='Moon')
if __name__ == '__main__':
    command_line_args = parse_arguments()
    match_images(command_line_args)
 No newline at end of file