Loading .travis.yml +0 −2 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ python: - "3.5" before_install: install: # We do this conditionally because it saves us some downloading if the # version is the same. Loading @@ -32,7 +31,6 @@ install: - source activate test-env # Install the non-conda packages if required, requirements.txt duplicates are ignored - conda install -c https://conda.binstar.org/menpo opencv3 - conda install -c osgeo proj4 - pip install -r requirements.txt - pip install coverage Loading autocnet/fileio/io_gdal.py +0 −1 Original line number Diff line number Diff line Loading @@ -350,7 +350,6 @@ class GeoDataset(object): xextent, yextent).astype(dtype) return array def array_to_raster(array, file_name, projection=None, geotransform=None, outformat='GTiff', ndv=None): Loading autocnet/matcher/tests/__init__.py→autocnet/fileio/tests/io_controlnetwork.py +0 −0 File moved. autocnet/graph/network.py +7 −16 Original line number Diff line number Diff line from collections import Hashable import networkx as nx from networkx import DiGraph from autocnet.fileio import io_json class CandidateGraph(nx.DiGraph): class CandidateGraph(DiGraph): """ A NetworkX derived directed graph to store candidate overlap images. Loading @@ -13,6 +12,8 @@ class CandidateGraph(nx.DiGraph): Attributes ---------- """ #TODO: This would be better with composition, and then dispatch the # network X calls to the graph object. def __init__(self,*args, **kwargs): super(CandidateGraph, self).__init__(*args, **kwargs) Loading @@ -35,7 +36,6 @@ class CandidateGraph(nx.DiGraph): Parameters ========== outputfile : str PATH where the JSON will be written """ Loading @@ -50,21 +50,12 @@ class CandidateGraph(nx.DiGraph): Instantiate the class using an adjacency list Parameters ---------- ========== inputfile : str The input file containing the graph representation Returns ------- : object A Network graph object Examples -------- >>> from autocnet.examples import get_path >>> inputfile = get_path('adjacency.json') >>> candidate_graph = network.CandidateGraph.from_adjacency(inputfile) """ #TODO: This is better as a generic reader that tries drivers until # a valid dict is returned. adjacency_dict = io_json.read_json(inputfile) return cls(adjacency_dict) autocnet/matcher/matcher.pydeleted 100644 → 0 +0 −92 Original line number Diff line number Diff line import cv2 import numpy as np import pandas as pd from autocnet.graph.network import CandidateGraph FLANN_INDEX_KDTREE = 1 # Algorithm to set centers, DEFAULT_FLANN_PARAMETERS = dict(algorithm=FLANN_INDEX_KDTREE, trees=3) class FlannMatcher(object): """ A wrapper to the OpenCV Flann based matcher class that adds metadata tracking attributes and methods. This takes arbitrary descriptors and so should be available for use with any descriptor data stored as an ndarray. Attributes ---------- image_indices : dict with key equal to the train image index (returned by the DMatch object), e.g. an integer array index and value equal to the image identifier, e.g. the name image_index_counter : int The current number of images loaded into the matcher """ def __init__(self, flann_parameters=DEFAULT_FLANN_PARAMETERS): self._flann_matcher = cv2.FlannBasedMatcher(flann_parameters, {}) self.image_indices = {} self.image_index_counter = 0 def add(self, descriptor, key): """ Add a set of descriptors to the matcher and add the image index key to the image_indices attribute Parameters ---------- descriptor : ndarray The descriptor to be added key : hashable The identifier for this image, e.g. the image name """ self._flann_matcher.add([descriptor]) self.image_indices[self.image_index_counter] = key self.image_index_counter += 1 def train(self): """ Using the descriptors, generate the KDTree """ self._flann_matcher.train() def query(self, descriptor, k=3, self_neighbor=True): """ Parameters ---------- descriptor : ndarray The query descriptor to search for k : int The number of nearest neighbors to search for self_neighbor : bool If the query descriptor is also a member of the KDTree avoid self neighbor, default True. Returns ------- matched : dataframe containing matched points with columns containg: matched image name, query index, train index, and descriptor distance """ idx = 0 if self_neighbor: idx = 1 matches = self._flann_matcher.knnMatch(descriptor, k=k) matched = [] for m in matches: for i in m[idx:]: matched.append((self.image_indices[i.imgIdx], i.queryIdx, i.trainIdx, i.distance)) return pd.DataFrame(matched, columns=['matched_to', 'queryIdx', 'trainIdx', 'distance']) Loading
.travis.yml +0 −2 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ python: - "3.5" before_install: install: # We do this conditionally because it saves us some downloading if the # version is the same. Loading @@ -32,7 +31,6 @@ install: - source activate test-env # Install the non-conda packages if required, requirements.txt duplicates are ignored - conda install -c https://conda.binstar.org/menpo opencv3 - conda install -c osgeo proj4 - pip install -r requirements.txt - pip install coverage Loading
autocnet/fileio/io_gdal.py +0 −1 Original line number Diff line number Diff line Loading @@ -350,7 +350,6 @@ class GeoDataset(object): xextent, yextent).astype(dtype) return array def array_to_raster(array, file_name, projection=None, geotransform=None, outformat='GTiff', ndv=None): Loading
autocnet/graph/network.py +7 −16 Original line number Diff line number Diff line from collections import Hashable import networkx as nx from networkx import DiGraph from autocnet.fileio import io_json class CandidateGraph(nx.DiGraph): class CandidateGraph(DiGraph): """ A NetworkX derived directed graph to store candidate overlap images. Loading @@ -13,6 +12,8 @@ class CandidateGraph(nx.DiGraph): Attributes ---------- """ #TODO: This would be better with composition, and then dispatch the # network X calls to the graph object. def __init__(self,*args, **kwargs): super(CandidateGraph, self).__init__(*args, **kwargs) Loading @@ -35,7 +36,6 @@ class CandidateGraph(nx.DiGraph): Parameters ========== outputfile : str PATH where the JSON will be written """ Loading @@ -50,21 +50,12 @@ class CandidateGraph(nx.DiGraph): Instantiate the class using an adjacency list Parameters ---------- ========== inputfile : str The input file containing the graph representation Returns ------- : object A Network graph object Examples -------- >>> from autocnet.examples import get_path >>> inputfile = get_path('adjacency.json') >>> candidate_graph = network.CandidateGraph.from_adjacency(inputfile) """ #TODO: This is better as a generic reader that tries drivers until # a valid dict is returned. adjacency_dict = io_json.read_json(inputfile) return cls(adjacency_dict)
autocnet/matcher/matcher.pydeleted 100644 → 0 +0 −92 Original line number Diff line number Diff line import cv2 import numpy as np import pandas as pd from autocnet.graph.network import CandidateGraph FLANN_INDEX_KDTREE = 1 # Algorithm to set centers, DEFAULT_FLANN_PARAMETERS = dict(algorithm=FLANN_INDEX_KDTREE, trees=3) class FlannMatcher(object): """ A wrapper to the OpenCV Flann based matcher class that adds metadata tracking attributes and methods. This takes arbitrary descriptors and so should be available for use with any descriptor data stored as an ndarray. Attributes ---------- image_indices : dict with key equal to the train image index (returned by the DMatch object), e.g. an integer array index and value equal to the image identifier, e.g. the name image_index_counter : int The current number of images loaded into the matcher """ def __init__(self, flann_parameters=DEFAULT_FLANN_PARAMETERS): self._flann_matcher = cv2.FlannBasedMatcher(flann_parameters, {}) self.image_indices = {} self.image_index_counter = 0 def add(self, descriptor, key): """ Add a set of descriptors to the matcher and add the image index key to the image_indices attribute Parameters ---------- descriptor : ndarray The descriptor to be added key : hashable The identifier for this image, e.g. the image name """ self._flann_matcher.add([descriptor]) self.image_indices[self.image_index_counter] = key self.image_index_counter += 1 def train(self): """ Using the descriptors, generate the KDTree """ self._flann_matcher.train() def query(self, descriptor, k=3, self_neighbor=True): """ Parameters ---------- descriptor : ndarray The query descriptor to search for k : int The number of nearest neighbors to search for self_neighbor : bool If the query descriptor is also a member of the KDTree avoid self neighbor, default True. Returns ------- matched : dataframe containing matched points with columns containg: matched image name, query index, train index, and descriptor distance """ idx = 0 if self_neighbor: idx = 1 matches = self._flann_matcher.knnMatch(descriptor, k=k) matched = [] for m in matches: for i in m[idx:]: matched.append((self.image_indices[i.imgIdx], i.queryIdx, i.trainIdx, i.distance)) return pd.DataFrame(matched, columns=['matched_to', 'queryIdx', 'trainIdx', 'distance'])