Loading autocnet/graph/edge.py +3 −0 Original line number Diff line number Diff line Loading @@ -71,7 +71,10 @@ class Edge(dict, MutableMapping): 'masks': self.masks, 'provenance': self.provenance, 'weight': self.weight} if item in attribute_dict.keys(): return attribute_dict[item] else: return super(Edge, self).__getitem__(item) @property def masks(self): Loading autocnet/graph/node.py +26 −5 Original line number Diff line number Diff line Loading @@ -80,18 +80,25 @@ class Node(dict, MutableMapping): attribute_dict = {'image_name': self.image_name, 'image_path': self.image_path, 'geodata': self.geodata, 'keypoints': self._keypoints, 'keypoints': self.keypoints, 'nkeypoints': self.nkeypoints, 'descriptors': self.descriptors, 'masks': self.masks, 'isis_serial': self.isis_serial} if item in attribute_dict.keys(): return attribute_dict[item] else: return super(Node, self).__getitem__(item) @property def geodata(self): if not getattr(self, '_geodata', None): if not getattr(self, '_geodata', None) and self.image_path is not None: self._geodata = GeoDataset(self.image_path) return self._geodata if hasattr(self, '_geodata'): return self._geodata else: return None @property def masks(self): Loading Loading @@ -138,6 +145,20 @@ class Node(dict, MutableMapping): else: return 0 @property def keypoints(self): if hasattr(self, '_keypoints'): return self._keypoints.copy() else: return None @property def descriptors(self): if hasattr(self, '_descriptors'): return np.copy(self._descriptors) else: return None def coverage(self): """ Determines the area of keypoint coverage Loading Loading @@ -250,7 +271,7 @@ class Node(dict, MutableMapping): kwargs passed to autocnet.feature_extractor.extract_features """ self._keypoints, self.descriptors = fe.extract_features(array, **kwargs) self._keypoints, self._descriptors = fe.extract_features(array, **kwargs) def load_features(self, in_path): """ Loading @@ -267,7 +288,7 @@ class Node(dict, MutableMapping): else: hdf = in_path self.descriptors = hdf['{}/descriptors'.format(self.image_name)][:] self._descriptors = hdf['{}/descriptors'.format(self.image_name)][:] raw_kps = hdf['{}/keypoints'.format(self.image_name)][:] index = raw_kps['index'] clean_kps = utils.remove_field_name(raw_kps, 'index') Loading Loading @@ -309,7 +330,7 @@ class Node(dict, MutableMapping): try: hdf.create_dataset('{}/descriptors'.format(self.image_name), data=self.descriptors, data=self._descriptors, compression=io_hdf.DEFAULT_COMPRESSION, compression_opts=io_hdf.DEFAULT_COMPRESSION_VALUE) hdf.create_dataset('{}/keypoints'.format(self.image_name), Loading autocnet/graph/tests/test_network.py +3 −3 Original line number Diff line number Diff line Loading @@ -47,9 +47,9 @@ class TestCandidateGraph(unittest.TestCase): self.assertEqual(graph.size(), graph.number_of_edges()) for u, v, e in graph.edges_iter(data=True): e['weight'] = 10 e['edge_weight'] = 10 self.assertEqual(graph.size('weight'), graph.number_of_edges()*10) self.assertEqual(graph.size('edge_weight'), graph.number_of_edges()*10) def test_island_nodes(self): self.assertEqual(len(self.disconnected_graph.island_nodes()), 1) Loading Loading @@ -159,7 +159,7 @@ class TestCandidateGraph(unittest.TestCase): test_sub_graph = graph.create_node_subgraph([0, 1]) test_sub_graph.extract_features(extractor_parameters={'nfeatures': 500}) test_sub_graph.match_features(k=2) filtered_nodes = graph.filter_nodes(lambda node: hasattr(node, 'descriptors')) filtered_nodes = graph.filter_nodes(lambda node: hasattr(node, '_descriptors')) filtered_edges = graph.filter_edges(edge_func) self.assertEqual(filtered_nodes.number_of_nodes(), test_sub_graph.number_of_nodes()) Loading Loading
autocnet/graph/edge.py +3 −0 Original line number Diff line number Diff line Loading @@ -71,7 +71,10 @@ class Edge(dict, MutableMapping): 'masks': self.masks, 'provenance': self.provenance, 'weight': self.weight} if item in attribute_dict.keys(): return attribute_dict[item] else: return super(Edge, self).__getitem__(item) @property def masks(self): Loading
autocnet/graph/node.py +26 −5 Original line number Diff line number Diff line Loading @@ -80,18 +80,25 @@ class Node(dict, MutableMapping): attribute_dict = {'image_name': self.image_name, 'image_path': self.image_path, 'geodata': self.geodata, 'keypoints': self._keypoints, 'keypoints': self.keypoints, 'nkeypoints': self.nkeypoints, 'descriptors': self.descriptors, 'masks': self.masks, 'isis_serial': self.isis_serial} if item in attribute_dict.keys(): return attribute_dict[item] else: return super(Node, self).__getitem__(item) @property def geodata(self): if not getattr(self, '_geodata', None): if not getattr(self, '_geodata', None) and self.image_path is not None: self._geodata = GeoDataset(self.image_path) return self._geodata if hasattr(self, '_geodata'): return self._geodata else: return None @property def masks(self): Loading Loading @@ -138,6 +145,20 @@ class Node(dict, MutableMapping): else: return 0 @property def keypoints(self): if hasattr(self, '_keypoints'): return self._keypoints.copy() else: return None @property def descriptors(self): if hasattr(self, '_descriptors'): return np.copy(self._descriptors) else: return None def coverage(self): """ Determines the area of keypoint coverage Loading Loading @@ -250,7 +271,7 @@ class Node(dict, MutableMapping): kwargs passed to autocnet.feature_extractor.extract_features """ self._keypoints, self.descriptors = fe.extract_features(array, **kwargs) self._keypoints, self._descriptors = fe.extract_features(array, **kwargs) def load_features(self, in_path): """ Loading @@ -267,7 +288,7 @@ class Node(dict, MutableMapping): else: hdf = in_path self.descriptors = hdf['{}/descriptors'.format(self.image_name)][:] self._descriptors = hdf['{}/descriptors'.format(self.image_name)][:] raw_kps = hdf['{}/keypoints'.format(self.image_name)][:] index = raw_kps['index'] clean_kps = utils.remove_field_name(raw_kps, 'index') Loading Loading @@ -309,7 +330,7 @@ class Node(dict, MutableMapping): try: hdf.create_dataset('{}/descriptors'.format(self.image_name), data=self.descriptors, data=self._descriptors, compression=io_hdf.DEFAULT_COMPRESSION, compression_opts=io_hdf.DEFAULT_COMPRESSION_VALUE) hdf.create_dataset('{}/keypoints'.format(self.image_name), Loading
autocnet/graph/tests/test_network.py +3 −3 Original line number Diff line number Diff line Loading @@ -47,9 +47,9 @@ class TestCandidateGraph(unittest.TestCase): self.assertEqual(graph.size(), graph.number_of_edges()) for u, v, e in graph.edges_iter(data=True): e['weight'] = 10 e['edge_weight'] = 10 self.assertEqual(graph.size('weight'), graph.number_of_edges()*10) self.assertEqual(graph.size('edge_weight'), graph.number_of_edges()*10) def test_island_nodes(self): self.assertEqual(len(self.disconnected_graph.island_nodes()), 1) Loading Loading @@ -159,7 +159,7 @@ class TestCandidateGraph(unittest.TestCase): test_sub_graph = graph.create_node_subgraph([0, 1]) test_sub_graph.extract_features(extractor_parameters={'nfeatures': 500}) test_sub_graph.match_features(k=2) filtered_nodes = graph.filter_nodes(lambda node: hasattr(node, 'descriptors')) filtered_nodes = graph.filter_nodes(lambda node: hasattr(node, '_descriptors')) filtered_edges = graph.filter_edges(edge_func) self.assertEqual(filtered_nodes.number_of_nodes(), test_sub_graph.number_of_nodes()) Loading