Loading autocnet/graph/edge.py +8 −5 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ class Edge(dict, MutableMapping): def decompose_and_match(*args, **kwargs): pass """ def extract_subset(self, *args, **kwargs): self.compute_overlap() Loading @@ -136,7 +137,7 @@ class Edge(dict, MutableMapping): node = self.destination arr = node.geodata.read_array(pixels=pixels) node.extract_features(arr, xystart=xystart, *args, **kwargs) """ def symmetry_check(self): self.masks['symmetry'] = od.mirroring_test(self.matches) Loading Loading @@ -167,10 +168,8 @@ class Edge(dict, MutableMapping): matches, mask = self.clean(clean_keys) # TODO: Homogeneous is horribly inefficient here, use Numpy array notation s_keypoints = self.source.get_keypoint_coordinates(index=matches['source_idx'], homogeneous=True) d_keypoints = self.destination.get_keypoint_coordinates(index=matches['destination_idx'], homogeneous=True) s_keypoints = self.get_keypoints('source', index=matches['source_idx']) d_keypoints = self.get_keypoints('destination', index=matches['destination_idx']) # Replace the index with the matches index. Loading @@ -186,6 +185,10 @@ class Edge(dict, MutableMapping): # Set the initial state of the fundamental mask in the masks self.masks[maskname] = mask def get_keypoints(self, node, index=None, homogeneous=True): node = getattr(self, node) return node.get_keypoint_coordinates(index=index, homogeneous=homogeneous) def compute_fundamental_error(self, clean_keys=[]): """ Given a fundamental matrix, compute the reprojective error between Loading autocnet/graph/tests/test_edge.py +0 −21 Original line number Diff line number Diff line Loading @@ -22,30 +22,9 @@ class TestEdge(unittest.TestCase): destination = Mock(node.Node) self.edge = edge.Edge(source=source, destination=destination) ''' # Define a matches dataframe source_image = np.zeros(20) destination_image = np.ones(20) source_idx = np.repeat(np.arange(10), 2) destination_idx = np.array([336, 78, 267, 467, 214, 212, 463, 241, 27, 154, 320, 108, 196, 460, 67, 135, 80, 122, 106, 343]) distance = np.array([263.43121338, 287.05050659, 231.03895569, 242.14459229, 140.07498169, 299.86331177, 332.05722046, 337.71438599, 94.9052124, 208.04806519, 102.21056366, 173.48774719, 102.19099426, 237.63206482, 240.93359375, 277.74627686, 217.82791138, 224.22979736, 260.3939209, 287.91143799]) data = np.stack((source_image, source_idx, destination_image, destination_idx, distance), axis=-1) self.edge.matches = pd.DataFrame(data, columns=['source_image', 'source_idx', 'destination_image', 'destination_idx', 'distance']) ''' def test_masks(self): self.assertIsInstance(self.edge.masks, pd.DataFrame) def test_compute_fundamental_matrix(self): pass def test_edge_overlap(self): e = edge.Edge() e.weight = {} Loading functional_tests/test_two_image.py +10 −0 Original line number Diff line number Diff line Loading @@ -63,13 +63,23 @@ class TestTwoImageMatching(unittest.TestCase): # Create fundamental matrix cg.compute_fundamental_matrices() for s, d, e in cg.edges_iter(data=True): assert isinstance(e['fundamental_matrix'], np.ndarray) err = e.compute_fundamental_error(clean_keys=['fundamental']) assert isinstance(err, pd.Series) matches, _ = e.clean(clean_keys=['fundamental']) assert matches.index.all() == err.index.all() # Apply AMNS cg.suppress(k=30, suppression_func=error) # Step: Compute subpixel offsets for candidate points cg.subpixel_register(clean_keys=['suppression'], tiled=True) cg.subpixel_register(clean_keys=['suppression']) # Step: And create a C object cg.generate_cnet(clean_keys=['subpixel']) Loading Loading
autocnet/graph/edge.py +8 −5 Original line number Diff line number Diff line Loading @@ -118,6 +118,7 @@ class Edge(dict, MutableMapping): def decompose_and_match(*args, **kwargs): pass """ def extract_subset(self, *args, **kwargs): self.compute_overlap() Loading @@ -136,7 +137,7 @@ class Edge(dict, MutableMapping): node = self.destination arr = node.geodata.read_array(pixels=pixels) node.extract_features(arr, xystart=xystart, *args, **kwargs) """ def symmetry_check(self): self.masks['symmetry'] = od.mirroring_test(self.matches) Loading Loading @@ -167,10 +168,8 @@ class Edge(dict, MutableMapping): matches, mask = self.clean(clean_keys) # TODO: Homogeneous is horribly inefficient here, use Numpy array notation s_keypoints = self.source.get_keypoint_coordinates(index=matches['source_idx'], homogeneous=True) d_keypoints = self.destination.get_keypoint_coordinates(index=matches['destination_idx'], homogeneous=True) s_keypoints = self.get_keypoints('source', index=matches['source_idx']) d_keypoints = self.get_keypoints('destination', index=matches['destination_idx']) # Replace the index with the matches index. Loading @@ -186,6 +185,10 @@ class Edge(dict, MutableMapping): # Set the initial state of the fundamental mask in the masks self.masks[maskname] = mask def get_keypoints(self, node, index=None, homogeneous=True): node = getattr(self, node) return node.get_keypoint_coordinates(index=index, homogeneous=homogeneous) def compute_fundamental_error(self, clean_keys=[]): """ Given a fundamental matrix, compute the reprojective error between Loading
autocnet/graph/tests/test_edge.py +0 −21 Original line number Diff line number Diff line Loading @@ -22,30 +22,9 @@ class TestEdge(unittest.TestCase): destination = Mock(node.Node) self.edge = edge.Edge(source=source, destination=destination) ''' # Define a matches dataframe source_image = np.zeros(20) destination_image = np.ones(20) source_idx = np.repeat(np.arange(10), 2) destination_idx = np.array([336, 78, 267, 467, 214, 212, 463, 241, 27, 154, 320, 108, 196, 460, 67, 135, 80, 122, 106, 343]) distance = np.array([263.43121338, 287.05050659, 231.03895569, 242.14459229, 140.07498169, 299.86331177, 332.05722046, 337.71438599, 94.9052124, 208.04806519, 102.21056366, 173.48774719, 102.19099426, 237.63206482, 240.93359375, 277.74627686, 217.82791138, 224.22979736, 260.3939209, 287.91143799]) data = np.stack((source_image, source_idx, destination_image, destination_idx, distance), axis=-1) self.edge.matches = pd.DataFrame(data, columns=['source_image', 'source_idx', 'destination_image', 'destination_idx', 'distance']) ''' def test_masks(self): self.assertIsInstance(self.edge.masks, pd.DataFrame) def test_compute_fundamental_matrix(self): pass def test_edge_overlap(self): e = edge.Edge() e.weight = {} Loading
functional_tests/test_two_image.py +10 −0 Original line number Diff line number Diff line Loading @@ -63,13 +63,23 @@ class TestTwoImageMatching(unittest.TestCase): # Create fundamental matrix cg.compute_fundamental_matrices() for s, d, e in cg.edges_iter(data=True): assert isinstance(e['fundamental_matrix'], np.ndarray) err = e.compute_fundamental_error(clean_keys=['fundamental']) assert isinstance(err, pd.Series) matches, _ = e.clean(clean_keys=['fundamental']) assert matches.index.all() == err.index.all() # Apply AMNS cg.suppress(k=30, suppression_func=error) # Step: Compute subpixel offsets for candidate points cg.subpixel_register(clean_keys=['suppression'], tiled=True) cg.subpixel_register(clean_keys=['suppression']) # Step: And create a C object cg.generate_cnet(clean_keys=['subpixel']) Loading