Loading autocnet/__init__.py +0 −2 Original line number Diff line number Diff line Loading @@ -43,8 +43,6 @@ def cuda(enable=False, gpu=0): from autocnet.matcher.cuda_decompose import decompose_and_match Edge.decompose_and_match = decompose_and_match # Outlier Detectors except Exception: warnings.warn('Failed to enable Cuda') return Loading autocnet/graph/edge.py +6 −2 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class Edge(dict, MutableMapping): boolean_mask = v[1] self.masks[column_name] = boolean_mask""" def match(self, k=2, **kwargs): def match(self, k=2, overlap=False, **kwargs): """ Given two sets of descriptors, utilize a FLANN (Approximate Nearest Loading @@ -105,6 +105,11 @@ class Edge(dict, MutableMapping): ---------- k : int The number of neighbors to find overlap : boolean Apply the matcher only to the overlapping area defined by the source_mbr and destin_mbr attributes (stored in the edge dict). """ pass Loading Loading @@ -498,4 +503,3 @@ class Edge(dict, MutableMapping): pixel space """ self.overlap_latlon_coords, self["source_mbr"], self["destin_mbr"] = self.source.geodata.compute_overlap(self.destination.geodata, **kwargs) autocnet/graph/network.py +2 −0 Original line number Diff line number Diff line import itertools import math import os from time import gmtime, strftime import warnings Loading Loading @@ -247,6 +248,7 @@ class CandidateGraph(nx.Graph): def extract_features_with_tiling(self, tilesize=1000, overlap=500, *args, **kwargs): #pragma: no cover for i, node in self.nodes_iter(data=True): print('Processing {}'.format(node['image_name'])) node.extract_features_with_tiling(tilesize=tilesize, overlap=overlap, *args, **kwargs) def extract_subsets(self, *args, **kwargs): Loading autocnet/graph/node.py +7 −1 Original line number Diff line number Diff line Loading @@ -340,12 +340,18 @@ class Node(dict, MutableMapping): stepsize = tilesize - overlap if stepsize < 0: raise ValueError('Overlap can not be greater than tilesize.') # Compute the tiles if tilesize >= array_size[1]: ytiles = [(0, array_size[1])] else: ystarts = range(0, array_size[1], stepsize) ystops = range(tilesize, array_size[1], stepsize) ytiles = list(zip(ystarts, ystops)) ytiles.append((ytiles[-1][0] + stepsize, array_size[1])) if tilesize >= array_size[0]: xtiles = [(0, array_size[0])] else: xstarts = range(0, array_size[0], stepsize) xstops = range(tilesize, array_size[0], stepsize) xtiles = list(zip(xstarts, xstops)) Loading autocnet/matcher/cpu_matcher.py +29 −3 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(self, k=2, overlap=False, **kwargs): """ Given two sets of descriptors, utilize a FLANN (Approximate Nearest Neighbor KDTree) matcher to find the k nearest matches. Nearness is Loading Loading @@ -77,8 +77,34 @@ def match(self, k=2, **kwargs): fl.clear() fl = FlannMatcher() mono_matches(self.source, self.destination, **kwargs) mono_matches(self.destination, self.source, **kwargs) # Get the correct descriptors # TODO: Extract into a helper function if 'aidx' in kwargs.keys(): aidx = kwargs['aidx'] kwargs.pop('aidx') elif overlap: # Query the source keypoints for those in the MBR source_mbr = self['source_mbr'] query_result = self.source.keypoints.query() aidx = query_result.index else: aidx = None if 'bidx' in kwargs.keys(): bidx = kwargs['bidx'] kwargs.pop('bidx') elif overlap: destin_mbr = self['destin_mbr'] query_result = self.destination.keypoints.query() bidx = query_result.index else: bidx = None mono_matches(self.source, self.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']) Loading Loading
autocnet/__init__.py +0 −2 Original line number Diff line number Diff line Loading @@ -43,8 +43,6 @@ def cuda(enable=False, gpu=0): from autocnet.matcher.cuda_decompose import decompose_and_match Edge.decompose_and_match = decompose_and_match # Outlier Detectors except Exception: warnings.warn('Failed to enable Cuda') return Loading
autocnet/graph/edge.py +6 −2 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class Edge(dict, MutableMapping): boolean_mask = v[1] self.masks[column_name] = boolean_mask""" def match(self, k=2, **kwargs): def match(self, k=2, overlap=False, **kwargs): """ Given two sets of descriptors, utilize a FLANN (Approximate Nearest Loading @@ -105,6 +105,11 @@ class Edge(dict, MutableMapping): ---------- k : int The number of neighbors to find overlap : boolean Apply the matcher only to the overlapping area defined by the source_mbr and destin_mbr attributes (stored in the edge dict). """ pass Loading Loading @@ -498,4 +503,3 @@ class Edge(dict, MutableMapping): pixel space """ self.overlap_latlon_coords, self["source_mbr"], self["destin_mbr"] = self.source.geodata.compute_overlap(self.destination.geodata, **kwargs)
autocnet/graph/network.py +2 −0 Original line number Diff line number Diff line import itertools import math import os from time import gmtime, strftime import warnings Loading Loading @@ -247,6 +248,7 @@ class CandidateGraph(nx.Graph): def extract_features_with_tiling(self, tilesize=1000, overlap=500, *args, **kwargs): #pragma: no cover for i, node in self.nodes_iter(data=True): print('Processing {}'.format(node['image_name'])) node.extract_features_with_tiling(tilesize=tilesize, overlap=overlap, *args, **kwargs) def extract_subsets(self, *args, **kwargs): Loading
autocnet/graph/node.py +7 −1 Original line number Diff line number Diff line Loading @@ -340,12 +340,18 @@ class Node(dict, MutableMapping): stepsize = tilesize - overlap if stepsize < 0: raise ValueError('Overlap can not be greater than tilesize.') # Compute the tiles if tilesize >= array_size[1]: ytiles = [(0, array_size[1])] else: ystarts = range(0, array_size[1], stepsize) ystops = range(tilesize, array_size[1], stepsize) ytiles = list(zip(ystarts, ystops)) ytiles.append((ytiles[-1][0] + stepsize, array_size[1])) if tilesize >= array_size[0]: xtiles = [(0, array_size[0])] else: xstarts = range(0, array_size[0], stepsize) xstops = range(tilesize, array_size[0], stepsize) xtiles = list(zip(xstarts, xstops)) Loading
autocnet/matcher/cpu_matcher.py +29 −3 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(self, k=2, overlap=False, **kwargs): """ Given two sets of descriptors, utilize a FLANN (Approximate Nearest Neighbor KDTree) matcher to find the k nearest matches. Nearness is Loading Loading @@ -77,8 +77,34 @@ def match(self, k=2, **kwargs): fl.clear() fl = FlannMatcher() mono_matches(self.source, self.destination, **kwargs) mono_matches(self.destination, self.source, **kwargs) # Get the correct descriptors # TODO: Extract into a helper function if 'aidx' in kwargs.keys(): aidx = kwargs['aidx'] kwargs.pop('aidx') elif overlap: # Query the source keypoints for those in the MBR source_mbr = self['source_mbr'] query_result = self.source.keypoints.query() aidx = query_result.index else: aidx = None if 'bidx' in kwargs.keys(): bidx = kwargs['bidx'] kwargs.pop('bidx') elif overlap: destin_mbr = self['destin_mbr'] query_result = self.destination.keypoints.query() bidx = query_result.index else: bidx = None mono_matches(self.source, self.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']) Loading