Loading autocnet/graph/edge.py +15 −6 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ class Edge(dict, MutableMapping): self.matches = None self._subpixel_offsets = None self.provenance = {} self.weight = {} self._observers = set() Loading @@ -64,6 +65,17 @@ class Edge(dict, MutableMapping): Available Masks: {} """.format(self.source, self.destination, self.masks) def __getitem__(self, item): attribute_dict = {'source': self.source, 'destination': self.destination, '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): mask_lookup = {'fundamental': 'fundamental_matrix', Loading Loading @@ -690,18 +702,15 @@ class Edge(dict, MutableMapping): def plot_decomposition(self, *args, **kwargs): #pragma: no cover return plot_edge_decomposition(self, *args, **kwargs) def clean(self, clean_keys, pid=None): def clean(self, clean_keys): """ Given a list of clean keys and a provenance id compute the mask of valid matches Given a list of clean keys compute the mask of valid matches Parameters ---------- clean_keys : list of columns names (clean keys) pid : int The provenance id of the parameter set to be cleaned. Defaults to the last run. Returns ------- Loading autocnet/graph/node.py +36 −4 Original line number Diff line number Diff line Loading @@ -76,11 +76,29 @@ class Node(dict, MutableMapping): """.format(self.node_id, self.image_name, self.image_path, self.nkeypoints, self.masks, self.__class__) def __getitem__(self, item): attribute_dict = {'image_name': self.image_name, 'image_path': self.image_path, 'geodata': self.geodata, '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 @@ -127,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 @@ -239,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 @@ -256,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 @@ -298,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 +15 −6 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ class Edge(dict, MutableMapping): self.matches = None self._subpixel_offsets = None self.provenance = {} self.weight = {} self._observers = set() Loading @@ -64,6 +65,17 @@ class Edge(dict, MutableMapping): Available Masks: {} """.format(self.source, self.destination, self.masks) def __getitem__(self, item): attribute_dict = {'source': self.source, 'destination': self.destination, '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): mask_lookup = {'fundamental': 'fundamental_matrix', Loading Loading @@ -690,18 +702,15 @@ class Edge(dict, MutableMapping): def plot_decomposition(self, *args, **kwargs): #pragma: no cover return plot_edge_decomposition(self, *args, **kwargs) def clean(self, clean_keys, pid=None): def clean(self, clean_keys): """ Given a list of clean keys and a provenance id compute the mask of valid matches Given a list of clean keys compute the mask of valid matches Parameters ---------- clean_keys : list of columns names (clean keys) pid : int The provenance id of the parameter set to be cleaned. Defaults to the last run. Returns ------- Loading
autocnet/graph/node.py +36 −4 Original line number Diff line number Diff line Loading @@ -76,11 +76,29 @@ class Node(dict, MutableMapping): """.format(self.node_id, self.image_name, self.image_path, self.nkeypoints, self.masks, self.__class__) def __getitem__(self, item): attribute_dict = {'image_name': self.image_name, 'image_path': self.image_path, 'geodata': self.geodata, '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 @@ -127,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 @@ -239,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 @@ -256,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 @@ -298,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