Loading autocnet/graph/network.py +24 −11 Original line number Diff line number Diff line Loading @@ -84,9 +84,23 @@ class CandidateGraph(nx.Graph): edge['matches'] = matches # deal with no edge case / fail better #document def compute_homography(self, source_key, destination_key, outlier_algorithm=cv2.RANSAC): """ Parameters ---------- source_key : str The identifier for the source node destination_key : str The identifier for the destination node Returns ------- : tuple A tuple of the form (transformation matrix, bad entry mask) """ #TODO: deal with no edge case / fail better #TODO: off-by-one error? if self.has_edge(source_key, destination_key): try: edge = self[source_key][destination_key] Loading @@ -98,21 +112,20 @@ class CandidateGraph(nx.Graph): for i, row in edge['matches'].iterrows(): # Get the source and destination x,y coordinates for matches source_idx = row['queryIdx_x'] src_keypoints = [self.node[source_key]['keypoints'][source_idx].pt[0], src_keypoint = [self.node[source_key]['keypoints'][source_idx].pt[0], self.node[source_key]['keypoints'][source_idx].pt[1]] destination_idx = row['queryIdx_y'] #print(destination_idx) #print(len(self.node[destination_key]['keypoints'])) dest_keypoints = [self.node[destination_key]['keypoints'][destination_idx-1].pt[0], self.node[destination_key]['keypoints'][destination_idx-1].pt[1]] dest_keypoint = [self.node[destination_key]['keypoints'][destination_idx-1].pt[0], self.node[destination_key]['keypoints'][destination_idx-1].pt[1]] source_keypoints.append(src_keypoints) destination_keypoints.append(dest_keypoints) return cv2.findHomography(np.array(source_keypoints), np.array(destination_keypoints), outlier_algorithm, 5.0) 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: return (",") return ('', '') else: return ('','') Loading autocnet/homography.pydeleted 100644 → 0 +0 −7 Original line number Diff line number Diff line #imports import cv2 #define our one function. add documentation. def calculate_homography(src_points, des_points, outlier_algorithm=cv2.RANSAC): cv2.calculateHomography(src_points, des_points, outlier_algorithm, 5.0) autocnet/test_homography.pydeleted 100644 → 0 +0 −12 Original line number Diff line number Diff line import unittest class TestCalculateHomography(unittest.TestCase): def setUp(self): self.src_points = "" self.des_points = "" def test_compute_homography(self): self.assertEqual(self.src_points, self.des_points) def tearDown(self): print(False) functional_tests/test_two_image.py +5 −7 Original line number Diff line number Diff line Loading @@ -67,13 +67,13 @@ class TestTwoImageMatching(unittest.TestCase): for node, attributes in cg.nodes_iter(data=True): descriptors = attributes['descriptors'] ignoreme, matches = fl.query(descriptors, k=2) matches = fl.query(descriptors, k=2) cg.add_matches(node, matches) #test new M, n = cg.compute_homography('AS15-M-0297_SML.png', 'AS15-M-0298_SML.png') print(M) #for me print(n) # for me # Step: Compute Homography transformation_matrix, mask = cg.compute_homography('AS15-M-0297_SML.png', 'AS15-M-0298_SML.png') self.assertEquals(len(transformation_matrix), 3) self.assertEquals(len(mask), 19) # Step: And create a C object cnet = cg.to_cnet() Loading @@ -88,8 +88,6 @@ class TestTwoImageMatching(unittest.TestCase): cnet.index.set_levels(new_idx, inplace=True) self.assertTrue(False) #force test to fail # Step: Output a control network to_isis('TestTwoImageMatching.net', cnet, mode='wb', networkid='TestTwoImageMatching', targetname='Moon') Loading Loading
autocnet/graph/network.py +24 −11 Original line number Diff line number Diff line Loading @@ -84,9 +84,23 @@ class CandidateGraph(nx.Graph): edge['matches'] = matches # deal with no edge case / fail better #document def compute_homography(self, source_key, destination_key, outlier_algorithm=cv2.RANSAC): """ Parameters ---------- source_key : str The identifier for the source node destination_key : str The identifier for the destination node Returns ------- : tuple A tuple of the form (transformation matrix, bad entry mask) """ #TODO: deal with no edge case / fail better #TODO: off-by-one error? if self.has_edge(source_key, destination_key): try: edge = self[source_key][destination_key] Loading @@ -98,21 +112,20 @@ class CandidateGraph(nx.Graph): for i, row in edge['matches'].iterrows(): # Get the source and destination x,y coordinates for matches source_idx = row['queryIdx_x'] src_keypoints = [self.node[source_key]['keypoints'][source_idx].pt[0], src_keypoint = [self.node[source_key]['keypoints'][source_idx].pt[0], self.node[source_key]['keypoints'][source_idx].pt[1]] destination_idx = row['queryIdx_y'] #print(destination_idx) #print(len(self.node[destination_key]['keypoints'])) dest_keypoints = [self.node[destination_key]['keypoints'][destination_idx-1].pt[0], self.node[destination_key]['keypoints'][destination_idx-1].pt[1]] dest_keypoint = [self.node[destination_key]['keypoints'][destination_idx-1].pt[0], self.node[destination_key]['keypoints'][destination_idx-1].pt[1]] source_keypoints.append(src_keypoints) destination_keypoints.append(dest_keypoints) return cv2.findHomography(np.array(source_keypoints), np.array(destination_keypoints), outlier_algorithm, 5.0) 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: return (",") return ('', '') else: return ('','') Loading
autocnet/homography.pydeleted 100644 → 0 +0 −7 Original line number Diff line number Diff line #imports import cv2 #define our one function. add documentation. def calculate_homography(src_points, des_points, outlier_algorithm=cv2.RANSAC): cv2.calculateHomography(src_points, des_points, outlier_algorithm, 5.0)
autocnet/test_homography.pydeleted 100644 → 0 +0 −12 Original line number Diff line number Diff line import unittest class TestCalculateHomography(unittest.TestCase): def setUp(self): self.src_points = "" self.des_points = "" def test_compute_homography(self): self.assertEqual(self.src_points, self.des_points) def tearDown(self): print(False)
functional_tests/test_two_image.py +5 −7 Original line number Diff line number Diff line Loading @@ -67,13 +67,13 @@ class TestTwoImageMatching(unittest.TestCase): for node, attributes in cg.nodes_iter(data=True): descriptors = attributes['descriptors'] ignoreme, matches = fl.query(descriptors, k=2) matches = fl.query(descriptors, k=2) cg.add_matches(node, matches) #test new M, n = cg.compute_homography('AS15-M-0297_SML.png', 'AS15-M-0298_SML.png') print(M) #for me print(n) # for me # Step: Compute Homography transformation_matrix, mask = cg.compute_homography('AS15-M-0297_SML.png', 'AS15-M-0298_SML.png') self.assertEquals(len(transformation_matrix), 3) self.assertEquals(len(mask), 19) # Step: And create a C object cnet = cg.to_cnet() Loading @@ -88,8 +88,6 @@ class TestTwoImageMatching(unittest.TestCase): cnet.index.set_levels(new_idx, inplace=True) self.assertTrue(False) #force test to fail # Step: Output a control network to_isis('TestTwoImageMatching.net', cnet, mode='wb', networkid='TestTwoImageMatching', targetname='Moon') Loading