Loading autocnet/matcher/feature_extractor.py +9 −9 Original line number Diff line number Diff line import cv2 from scipy import misc def extract_features(image_array, num_nodes=500): def extract_features(image_array, extractor_parameters): """ Extracts keypoints and corresponding descriptors from a numpy array that represents an image. The extracted information is returned as a tuple whose first element is a list of KeyPoints and whose second element is a numpy array of geometric vector descriptors. This method finds and extracts features from an image using the given dictionary of keyword arguments. The input image is represented as NumPy array and the output features are represented as keypoint IDs with corresponding descriptors. Parameters ---------- image_array : ndarray a numpy array that represents an image num_nodes : int the number of best features to retain a NumPy array that represents an image extractor_parameters : dict A dictionary containing OpenCV SIFT parameters names and values. Returns ------- : tuple This tuple is in the form (list of KeyPoints, array of descriptors) in the form ([list of OpenCV KeyPoints], [NumPy array of descriptors as geometric vectors]) """ sift = cv2.xfeatures2d.SIFT_create(num_nodes) sift = cv2.xfeatures2d.SIFT_create(**extractor_parameters) converted_array = misc.bytescale(image_array) return sift.detectAndCompute(converted_array, None) autocnet/matcher/tests/test_feature_extractor.py +6 −1 Original line number Diff line number Diff line Loading @@ -15,9 +15,14 @@ class TestFeatureExtractor(unittest.TestCase): def setUp(self): self.dataset = io_gdal.GeoDataset(get_path('Mars_MGS_MOLA_ClrShade_MAP2_0.0N0.0_MERC.tif')) self.data_array = self.dataset.read_array() self.parameters = {"nfeatures" : 10, "nOctaveLayers" : 3, "contrastThreshold" : 0.02, "edgeThreshold" : 10, "sigma" : 1.6} def test_extract_features(self): features = feature_extractor.extract_features(self.data_array, 10) features = feature_extractor.extract_features(self.data_array, self.parameters) self.assertEquals(len(features), 2) self.assertIsInstance(features[0][0], type(cv2.KeyPoint())) self.assertIsInstance(features[1][0], np.ndarray) Loading docs/conf.py +2 −2 Original line number Diff line number Diff line Loading @@ -293,8 +293,8 @@ class Mock(MagicMock): def __getter__(cls, name): return Mock() MOCK_MODULES = ['proj4', 'numpy', 'pandas', 'scipy', 'osgeo'] # All imported libraries should be added to this mock modules list. MOCK_MODULES = ['proj4', 'numpy', 'pandas', 'scipy', 'osgeo', 'cv2'] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) # NumpyDoc Options Loading docs/library/fileio/gdal.rst +4 −1 Original line number Diff line number Diff line :mod:`fileio.io_gdal` --- Geospatial Data Abstraction Library ============================================================= The :mod:`fileio.io_gdal` module provides a convenience wrapper to GDAL The :mod:`fileio.io_gdal` and :mod:`fileio.extract_metadata` modules provide convenience wrappers to GDAL. .. versionadded:: 0.1.0 Loading @@ -9,3 +9,6 @@ The :mod:`fileio.io_gdal` module provides a convenience wrapper to GDAL :synopsis: This is the synopsis :members: .. automodule:: autocnet.fileio.extract_metadata :synopsis: This is the synopsis :members: docs/library/matcher/feature_extractor.rst 0 → 100644 +10 −0 Original line number Diff line number Diff line :mod:`matcher.feature_extractor` --- Extracting Features from Images ==================================================================== The :mod:`matcher.feature_extractor` module .. versionadded:: 0.1.0 .. automodule:: autocnet.matcher.feature_extractor :synopsis: :members: Loading
autocnet/matcher/feature_extractor.py +9 −9 Original line number Diff line number Diff line import cv2 from scipy import misc def extract_features(image_array, num_nodes=500): def extract_features(image_array, extractor_parameters): """ Extracts keypoints and corresponding descriptors from a numpy array that represents an image. The extracted information is returned as a tuple whose first element is a list of KeyPoints and whose second element is a numpy array of geometric vector descriptors. This method finds and extracts features from an image using the given dictionary of keyword arguments. The input image is represented as NumPy array and the output features are represented as keypoint IDs with corresponding descriptors. Parameters ---------- image_array : ndarray a numpy array that represents an image num_nodes : int the number of best features to retain a NumPy array that represents an image extractor_parameters : dict A dictionary containing OpenCV SIFT parameters names and values. Returns ------- : tuple This tuple is in the form (list of KeyPoints, array of descriptors) in the form ([list of OpenCV KeyPoints], [NumPy array of descriptors as geometric vectors]) """ sift = cv2.xfeatures2d.SIFT_create(num_nodes) sift = cv2.xfeatures2d.SIFT_create(**extractor_parameters) converted_array = misc.bytescale(image_array) return sift.detectAndCompute(converted_array, None)
autocnet/matcher/tests/test_feature_extractor.py +6 −1 Original line number Diff line number Diff line Loading @@ -15,9 +15,14 @@ class TestFeatureExtractor(unittest.TestCase): def setUp(self): self.dataset = io_gdal.GeoDataset(get_path('Mars_MGS_MOLA_ClrShade_MAP2_0.0N0.0_MERC.tif')) self.data_array = self.dataset.read_array() self.parameters = {"nfeatures" : 10, "nOctaveLayers" : 3, "contrastThreshold" : 0.02, "edgeThreshold" : 10, "sigma" : 1.6} def test_extract_features(self): features = feature_extractor.extract_features(self.data_array, 10) features = feature_extractor.extract_features(self.data_array, self.parameters) self.assertEquals(len(features), 2) self.assertIsInstance(features[0][0], type(cv2.KeyPoint())) self.assertIsInstance(features[1][0], np.ndarray) Loading
docs/conf.py +2 −2 Original line number Diff line number Diff line Loading @@ -293,8 +293,8 @@ class Mock(MagicMock): def __getter__(cls, name): return Mock() MOCK_MODULES = ['proj4', 'numpy', 'pandas', 'scipy', 'osgeo'] # All imported libraries should be added to this mock modules list. MOCK_MODULES = ['proj4', 'numpy', 'pandas', 'scipy', 'osgeo', 'cv2'] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) # NumpyDoc Options Loading
docs/library/fileio/gdal.rst +4 −1 Original line number Diff line number Diff line :mod:`fileio.io_gdal` --- Geospatial Data Abstraction Library ============================================================= The :mod:`fileio.io_gdal` module provides a convenience wrapper to GDAL The :mod:`fileio.io_gdal` and :mod:`fileio.extract_metadata` modules provide convenience wrappers to GDAL. .. versionadded:: 0.1.0 Loading @@ -9,3 +9,6 @@ The :mod:`fileio.io_gdal` module provides a convenience wrapper to GDAL :synopsis: This is the synopsis :members: .. automodule:: autocnet.fileio.extract_metadata :synopsis: This is the synopsis :members:
docs/library/matcher/feature_extractor.rst 0 → 100644 +10 −0 Original line number Diff line number Diff line :mod:`matcher.feature_extractor` --- Extracting Features from Images ==================================================================== The :mod:`matcher.feature_extractor` module .. versionadded:: 0.1.0 .. automodule:: autocnet.matcher.feature_extractor :synopsis: :members: