Commit 4bcce96c authored by Jay's avatar Jay Committed by jay
Browse files

Test fixes for new detector methods and updates for ratio test.

parent b77af0df
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -366,9 +366,6 @@ class CandidateGraph(nx.Graph):

                edge_offsets[i] = sp.subpixel_offset(s_template, d_search, upsampling=upsampling)

            # The destination node is the node that is subpixel registered, so downsample there
            edge_offsets[:, :2] /= d_node['downsampling']

            # Compute the mask for correlations less than the threshold
            threshold_mask = edge_offsets[edge_offsets[:, -1] >= threshold]

+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ def distance_ratio(matches, ratio=0.8):
                # The distances from the unique points are identical
                mask[counter: counter + group_size] = False
                counter += group_size
            elif unique[1] / unique[0] > ratio:
            elif unique[1] / unique[0] < ratio:
                # The ratio test passes
                mask[counter] = True
                mask[counter + 1:counter + group_size] = False
+3 −1
Original line number Diff line number Diff line
@@ -24,7 +24,9 @@ class TestFeatureExtractor(unittest.TestCase):
                          "sigma": 1.6}

    def test_extract_features(self):
        features = feature_extractor.extract_features(self.data_array, self.parameters)
        features = feature_extractor.extract_features(self.data_array,
                                                      method='sift',
                                                      extractor_parameters=self.parameters)
        self.assertEquals(len(features), 2)
        self.assertIn(len(features[0]), range(8,12))
        self.assertIsInstance(features[0][0], type(cv2.KeyPoint()))
+4 −4
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class TestTwoImageMatching(unittest.TestCase):
        self.assertEqual(1, cg.number_of_edges())

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

@@ -68,12 +68,12 @@ class TestTwoImageMatching(unittest.TestCase):
            attributes['symmetry'] = symmetry_mask

            # Perform the ratio test
            ratio_mask = od.distance_ratio(matches, ratio=0.95)
            self.assertIn(ratio_mask.sum(), range(390, 451))
            ratio_mask = od.distance_ratio(matches, ratio=0.8)
            self.assertIn(ratio_mask.sum(), range(20, 100))
            attributes['ratio'] = ratio_mask

            mask = np.array(ratio_mask * symmetry_mask)
            self.assertIn(len(matches.loc[mask]), range(75,101))
            self.assertIn(len(matches.loc[mask]), range(5,50))

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