Loading autocnet/__init__.py +2 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ def cuda(enable=False, gpu=0): Node._extract_features = staticmethod(extract_features) from autocnet.matcher.cuda_matcher import match Edge.match = match Edge._match = staticmethod(match) from autocnet.matcher.cuda_decompose import decompose_and_match Edge.decompose_and_match = decompose_and_match Loading @@ -52,7 +52,7 @@ def cuda(enable=False, gpu=0): Node._extract_features = staticmethod(extract_features) from autocnet.matcher.cpu_matcher import match Edge.match = match Edge._match = staticmethod(match) from autocnet.matcher.cpu_decompose import decompose_and_match Edge.decompose_and_match = decompose_and_match Loading autocnet/graph/edge.py +15 −4 Original line number Diff line number Diff line Loading @@ -107,11 +107,22 @@ class Edge(dict, MutableMapping): ---------- k : int The number of neighbors to find """ Edge._match(self, k, **kwargs) @staticmethod def _match(edge, k=2, **kwargs): """ Patches the static cpu_matcher.match(edge) or cuda_match.match(edge) into the member method Edge.match() overlap : boolean Apply the matcher only to the overlapping area defined by the source_mbr and destin_mbr attributes (stored in the edge dict). Parameters ---------- edge : Edge The edge object to compute matches for; Edge.match() calls this with self k : int The number of neighbors to find """ pass Loading autocnet/matcher/cpu_matcher.py +8 −8 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ FLANN_INDEX_KDTREE = 1 # Algorithm to set centers, DEFAULT_FLANN_PARAMETERS = dict(algorithm=FLANN_INDEX_KDTREE, trees=3) def match(self, k=2, **kwargs): def match(edge, k=2, **kwargs): """ Given two sets of descriptors, utilize a FLANN (Approximate Nearest Neighbor KDTree) matcher to find the k nearest matches. Nearness is Loading @@ -32,11 +32,11 @@ def match(self, k=2, **kwargs): matches : dataframe A dataframe of matches """ if self.matches is None: self.matches = matches if edge.matches is None: edge.matches = matches else: df = self.matches self.matches = df.append(matches, df = edge.matches edge.matches = df.append(matches, ignore_index=True, verify_integrity=True) Loading Loading @@ -92,11 +92,11 @@ def match(self, k=2, **kwargs): else: bidx = None mono_matches(self.source, self.destination, aidx=aidx, bidx=bidx, **kwargs) mono_matches(edge.source, edge.destination, aidx=aidx, bidx=bidx, **kwargs) # Swap the indices since mono_matches is generic and source/destin are # swapped mono_matches(self.destination, self.source, aidx=bidx, bidx=aidx, **kwargs) self.matches.sort_values(by=['distance']) mono_matches(edge.destination, edge.source, aidx=bidx, bidx=aidx, **kwargs) edge.matches.sort_values(by=['distance']) class FlannMatcher(object): Loading autocnet/matcher/cuda_matcher.py +9 −9 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import cudasift as cs import numpy as np import pandas as pd def match(self, ratio=0.8, **kwargs): def match(edge, ratio=0.8, **kwargs): """ Apply a composite CUDA matcher and ratio check. If this method is used, Loading @@ -14,11 +14,11 @@ def match(self, ratio=0.8, **kwargs): without significant gain in accuracy when using this implementation. """ source_kps = self.source.get_keypoints() source_des = self.source.descriptors source_kps = edge.source.get_keypoints() source_des = edge.source.descriptors destin_kps = self.destination.get_keypoints() destin_des = self.destination.descriptors destin_kps = edge.destination.get_keypoints() destin_des = edge.destination.descriptors s_siftdata = cs.PySiftData.from_data_frame(source_kps, source_des) d_siftdata = cs.PySiftData.from_data_frame(destin_kps, destin_des) Loading @@ -26,9 +26,9 @@ def match(self, ratio=0.8, **kwargs): cs.PyMatchSiftData(s_siftdata, d_siftdata) matches, _ = s_siftdata.to_data_frame() source = np.empty(len(matches)) source[:] = self.source['node_id'] source[:] = edge.source['node_id'] destination = np.empty(len(matches)) destination[:] = self.destination['node_id'] destination[:] = edge.destination['node_id'] df = pd.concat([pd.Series(source), pd.Series(matches.index), pd.Series(destination), matches.match, Loading @@ -37,5 +37,5 @@ def match(self, ratio=0.8, **kwargs): 'destination_idx', 'score', 'ambiguity'] # Set the matches and set the 'ratio' (ambiguity) mask self.matches = df self.masks['ratio'] = df['ambiguity'] <= ratio edge.matches = df edge.masks['ratio'] = df['ambiguity'] <= ratio Loading
autocnet/__init__.py +2 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ def cuda(enable=False, gpu=0): Node._extract_features = staticmethod(extract_features) from autocnet.matcher.cuda_matcher import match Edge.match = match Edge._match = staticmethod(match) from autocnet.matcher.cuda_decompose import decompose_and_match Edge.decompose_and_match = decompose_and_match Loading @@ -52,7 +52,7 @@ def cuda(enable=False, gpu=0): Node._extract_features = staticmethod(extract_features) from autocnet.matcher.cpu_matcher import match Edge.match = match Edge._match = staticmethod(match) from autocnet.matcher.cpu_decompose import decompose_and_match Edge.decompose_and_match = decompose_and_match Loading
autocnet/graph/edge.py +15 −4 Original line number Diff line number Diff line Loading @@ -107,11 +107,22 @@ class Edge(dict, MutableMapping): ---------- k : int The number of neighbors to find """ Edge._match(self, k, **kwargs) @staticmethod def _match(edge, k=2, **kwargs): """ Patches the static cpu_matcher.match(edge) or cuda_match.match(edge) into the member method Edge.match() overlap : boolean Apply the matcher only to the overlapping area defined by the source_mbr and destin_mbr attributes (stored in the edge dict). Parameters ---------- edge : Edge The edge object to compute matches for; Edge.match() calls this with self k : int The number of neighbors to find """ pass Loading
autocnet/matcher/cpu_matcher.py +8 −8 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ FLANN_INDEX_KDTREE = 1 # Algorithm to set centers, DEFAULT_FLANN_PARAMETERS = dict(algorithm=FLANN_INDEX_KDTREE, trees=3) def match(self, k=2, **kwargs): def match(edge, k=2, **kwargs): """ Given two sets of descriptors, utilize a FLANN (Approximate Nearest Neighbor KDTree) matcher to find the k nearest matches. Nearness is Loading @@ -32,11 +32,11 @@ def match(self, k=2, **kwargs): matches : dataframe A dataframe of matches """ if self.matches is None: self.matches = matches if edge.matches is None: edge.matches = matches else: df = self.matches self.matches = df.append(matches, df = edge.matches edge.matches = df.append(matches, ignore_index=True, verify_integrity=True) Loading Loading @@ -92,11 +92,11 @@ def match(self, k=2, **kwargs): else: bidx = None mono_matches(self.source, self.destination, aidx=aidx, bidx=bidx, **kwargs) mono_matches(edge.source, edge.destination, aidx=aidx, bidx=bidx, **kwargs) # Swap the indices since mono_matches is generic and source/destin are # swapped mono_matches(self.destination, self.source, aidx=bidx, bidx=aidx, **kwargs) self.matches.sort_values(by=['distance']) mono_matches(edge.destination, edge.source, aidx=bidx, bidx=aidx, **kwargs) edge.matches.sort_values(by=['distance']) class FlannMatcher(object): Loading
autocnet/matcher/cuda_matcher.py +9 −9 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import cudasift as cs import numpy as np import pandas as pd def match(self, ratio=0.8, **kwargs): def match(edge, ratio=0.8, **kwargs): """ Apply a composite CUDA matcher and ratio check. If this method is used, Loading @@ -14,11 +14,11 @@ def match(self, ratio=0.8, **kwargs): without significant gain in accuracy when using this implementation. """ source_kps = self.source.get_keypoints() source_des = self.source.descriptors source_kps = edge.source.get_keypoints() source_des = edge.source.descriptors destin_kps = self.destination.get_keypoints() destin_des = self.destination.descriptors destin_kps = edge.destination.get_keypoints() destin_des = edge.destination.descriptors s_siftdata = cs.PySiftData.from_data_frame(source_kps, source_des) d_siftdata = cs.PySiftData.from_data_frame(destin_kps, destin_des) Loading @@ -26,9 +26,9 @@ def match(self, ratio=0.8, **kwargs): cs.PyMatchSiftData(s_siftdata, d_siftdata) matches, _ = s_siftdata.to_data_frame() source = np.empty(len(matches)) source[:] = self.source['node_id'] source[:] = edge.source['node_id'] destination = np.empty(len(matches)) destination[:] = self.destination['node_id'] destination[:] = edge.destination['node_id'] df = pd.concat([pd.Series(source), pd.Series(matches.index), pd.Series(destination), matches.match, Loading @@ -37,5 +37,5 @@ def match(self, ratio=0.8, **kwargs): 'destination_idx', 'score', 'ambiguity'] # Set the matches and set the 'ratio' (ambiguity) mask self.matches = df self.masks['ratio'] = df['ambiguity'] <= ratio edge.matches = df edge.masks['ratio'] = df['ambiguity'] <= ratio