Commit aa795b6d authored by Adam Paquette's avatar Adam Paquette
Browse files

primary fin_in_dict implementation

parent 719bcc9c
Loading
Loading
Loading
Loading
+25 −25
Original line number Diff line number Diff line
@@ -4,20 +4,15 @@ system_paths:
    outputfile_path: /home/acpaquette/autocnet/autocnet/examples/Apollo15/

extract_features:
    # method can be orb, sift, fast, and surf
    method: sift
    extractor_parameters:
        # number of feature points to apply to an image
        nfeatures: 2000
        nOctaveLayers:
        contrastThreshold:
        edgeThreshold:
        sigma:
        nfeatures: 500

match_features:
    # k is the number of matchs to find per feature
    k: 50

# Any clean keys being passed in requires a method to have been used on the candidate graph object
# before the key can be passed in
ratio_checks:
    clean_keys:
        -
@@ -26,31 +21,36 @@ ratio_checks:

fundamental_matrics:
    clean_keys:
        -
        - ratio
        - symmetry
    keyword_arguments:
        -

subpixel_register:
    clean_keys:
        -
    # size of the template in pixels, must be odd
    template_size:
    # a range from (-1, 1), values less tahn or equal to this threshold are considered outliers
    threshold:
    search_size:
    # maximum value a pixel can shift in the x direction without being considered an outlier
    max_x_shift:
    # maximum value a pixel can shift in the x direction without being considered an outlier
    max_y_shift:
        - ratio
        - symmetry
        - fundamental
    template_size: 19
    threshold: 0.8
    search_size: 53
    max_x_shift: 1.0
    max_y_shift: 1.0
    tiled: False
    keyword arguments:
    keyword_arguments:
        -

suppress:
    clean_keys:
        -
    keyword arguments:
        -
cnet conversion:
        - fundamental
    keyword_arguments:
        k: 50

cnet_conversion:
    clean_keys:
        -
        - subpixel
to_isis:
    networkid: None
    targetname: moon
    description: None
    username: DEFAULTUSERNAME
 No newline at end of file
+21 −8
Original line number Diff line number Diff line
@@ -23,9 +23,10 @@ def parse_arguments():
    return args

def match_images(args, config_dict):

    # print(find_in_dict(config_dict, 'to_isis'))
    # Matches the images in the input file using various candidate graph methods
    # produces two files usable in isis

    try:
        cg = CandidateGraph.from_adjacency(find_in_dict(config_dict, 'inputfile_path') +
                                           args.input_file, basepath=find_in_dict(config_dict, 'basepath'))
@@ -34,28 +35,40 @@ def match_images(args, config_dict):

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

    # Match
    cg.match_features()
    cg.match_features(k=find_in_dict(config_dict, 'match_features')['k'])

    # Apply outlier detection
    cg.symmetry_checks()
    cg.ratio_checks()

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

    cg.subpixel_register(clean_keys=['fundamental', 'symmetry', 'ratio'], template_size=5, search_size=15)
    cg.subpixel_register(clean_keys=find_in_dict(config_dict, 'subpixel_register')['clean_keys'],
                         template_size=find_in_dict(config_dict, 'template_size'),
                         threshold=find_in_dict(config_dict, 'threshold_size'),
                         search_size=find_in_dict(config_dict, 'search_size'),
                         max_x_shift=find_in_dict(config_dict, 'max_x_shift'),
                         max_y_shift=find_in_dict(config_dict, 'max_y_shift'),
                         tiled=find_in_dict(config_dict, 'tiled'))

    cg.suppress(clean_keys=['fundamental'], k=50)
    cg.suppress(clean_keys=find_in_dict(config_dict, 'suppress')['clean_keys'],
                k=find_in_dict(config_dict, 'suppress')['keyword_arguments']['k'])

    cnet = cg.to_cnet(clean_keys=['subpixel'], isis_serials=True)
    cnet = cg.to_cnet(clean_keys=find_in_dict(config_dict, 'cnet_conversion')['clean_keys'],
                      isis_serials=True)

    filelist = cg.to_filelist()
    write_filelist(filelist, find_in_dict(config_dict, 'outputfile_path') + args.output_file + '.lis')

    to_isis(find_in_dict(config_dict, 'outputfile_path') + args.output_file + '.net', cnet, mode='wb', targetname='Moon')
    to_isis(find_in_dict(config_dict, 'outputfile_path') + args.output_file + '.net', cnet,
            mode='wb',
            networkid=find_in_dict(config_dict, 'networkid'),
            targetname=find_in_dict(config_dict, 'targetnamme'),
            description=find_in_dict(config_dict, 'description'))

if __name__ == '__main__':
    config = read_config('/home/acpaquette/autocnet/.image_match_config.yml')