예제 #1
0
    def test_three_image(self):
        # Step: Create an adjacency graph
        adjacency = get_path('three_image_adjacency.json')
        basepath = get_path('Apollo15')
        cg = CandidateGraph.from_adjacency(adjacency, basepath)
        self.assertEqual(3, cg.number_of_nodes())
        self.assertEqual(3, cg.number_of_edges())

        # Step: Extract image data and attribute nodes
        cg.extract_features(extractor_parameters={'nfeatures':500})
        for i, node, in cg.nodes_iter(data=True):
            self.assertIn(node.nkeypoints, range(490, 511))

        cg.match_features(k=5)
        cg.symmetry_checks()
        cg.ratio_checks()

        cg.apply_func_to_edges("compute_homography", clean_keys=['symmetry', 'ratio'])
        cg.compute_fundamental_matrices(clean_keys=['symmetry', 'ratio'])

        # Step: And create a C object
        cg.generate_cnet(clean_keys=['symmetry', 'ratio', 'ransac'])

        # Step: Create a fromlist to go with the cnet and write it to a file
        filelist = cg.to_filelist()
        write_filelist(filelist, 'TestThreeImageMatching_fromlist.lis')

        # Step: Create a correspondence network
        cg.generate_cnet(clean_keys=['ransac'], deepen=True)

        to_isis('TestThreeImageMatching.net', cg.cn, mode='wb',
                networkid='TestThreeImageMatching', targetname='Moon')
예제 #2
0
    def test_two_image(self):
        # Step: Create an adjacency graph
        adjacency = get_path('two_image_adjacency.json')
        basepath = get_path('Apollo15')
        cg = CandidateGraph.from_adjacency(adjacency, basepath=basepath)
        self.assertEqual(2, cg.number_of_nodes())
        self.assertEqual(1, cg.number_of_edges())

        # Step: Extract image data and attribute nodes
        cg.extract_features(method='sift', extractor_parameters={"nfeatures":500})
        for i, node in cg.nodes_iter(data=True):
            self.assertIn(node.nkeypoints, range(490, 511))

        # Step: Compute the coverage ratios
        truth_ratios = [0.95351579,
                        0.93595664]
        for i, node in cg.nodes_iter(data=True):
            ratio = node.coverage_ratio()
            self.assertIn(round(ratio, 8), truth_ratios)

        cg.match_features(k=2)

        # Perform the symmetry check
        cg.symmetry_checks()
        # Perform the ratio check
        cg.ratio_checks(clean_keys=['symmetry'], single=True)
        # Create fundamental matrix
        cg.compute_fundamental_matrices(clean_keys = ['symmetry', 'ratio'])

        for source, destination, edge in cg.edges_iter(data=True):

            # Perform the symmetry check
            self.assertIn(edge.masks['symmetry'].sum(), range(400, 600))
            # Perform the ratio test
            self.assertIn(edge.masks['ratio'].sum(), range(225, 275))

            # Range needs to be set
            self.assertIn(edge.masks['fundamental'].sum(), range(200, 250))

        # Step: Compute the homographies and apply RANSAC
        cg.compute_homographies(clean_keys=['symmetry', 'ratio'])

        # Apply AMNS
        cg.suppress(k=30, suppression_func=error)

        # Step: Compute subpixel offsets for candidate points
        cg.subpixel_register(clean_keys=['suppression'])


        # Step: And create a C object
        cg.generate_cnet(clean_keys=['subpixel'])

        # Step: Create a fromlist to go with the cnet and write it to a file
        filelist = cg.to_filelist()
        write_filelist(filelist, path="fromlis.lis")

        # Step: Output a control network
        to_isis('TestTwoImageMatching.net', cg.cn, mode='wb',
                networkid='TestTwoImageMatching', targetname='Moon')