Commit 3fc473a6 authored by kberry's avatar kberry
Browse files

updated compute_homography for updated matches df format

parent 44222cb9
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -121,19 +121,15 @@ class CandidateGraph(nx.Graph):
                destination_keypoints = []

                for i, row in edge['matches'].iterrows():
                    source_matched_to = row['matched_to_x']
                    source_idx = row['trainIdx_x']
                    src_keypoint = [self.node[source_matched_to]['keypoints'][source_idx].pt[0],
                                    self.node[source_matched_to]['keypoints'][source_idx].pt[1]]

                    destination_matched_to = row['matched_to_y']
                    destination_idx = row['trainIdx_y']
                    dest_keypoint = [self.node[destination_matched_to]['keypoints'][destination_idx].pt[0],
                                     self.node[destination_matched_to]['keypoints'][destination_idx].pt[1]]
                    source_idx = row['source_idx']
                    src_keypoint = [self.node[source_key]['keypoints'][int(source_idx)].pt[0],
                                    self.node[source_key]['keypoints'][int(source_idx)].pt[1]]
                    destination_idx = row['destination_idx']
                    dest_keypoint = [self.node[destination_key]['keypoints'][int(destination_idx)].pt[0],
                                     self.node[destination_key]['keypoints'][int(destination_idx)].pt[1]]

                    source_keypoints.append(src_keypoint)
                    destination_keypoints.append(dest_keypoint)

                return cv2.findHomography(np.array(source_keypoints), np.array(destination_keypoints),
                                          outlier_algorithm, 5.0)
            else:
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ class TestFeatureExtractor(unittest.TestCase):
    def test_extract_features(self):
        features = feature_extractor.extract_features(self.data_array, self.parameters)
        self.assertEquals(len(features), 2)
        self.assertEqual(len(features[0]), 10)  # OpenCV +1 to
        self.assertEqual(len(features[0]), 11)  # OpenCV +1 to
        self.assertIsInstance(features[0][0], type(cv2.KeyPoint()))
        self.assertIsInstance(features[1][0], np.ndarray)
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ class TestTwoImageMatching(unittest.TestCase):
            cg.add_matches(matches)

        # Step: Compute Homography
        transformation_matrix, mask = cg.compute_homography('AS15-M-0297_SML.png', 'AS15-M-0298_SML.png')
        transformation_matrix, mask = cg.compute_homography(0, 1)
        self.assertEquals(len(transformation_matrix), 3)
        #TODO: write better test
        #self.assertEquals(len(mask), 19)