Commit ba7af8eb authored by Jay's avatar Jay Committed by Jason R Laura
Browse files

Updates the feature descriptor to ensure that the function is externally...

Updates the feature descriptor to ensure that the function is externally usable as well as within autocnet.
parent b7c64e3b
Loading
Loading
Loading
Loading
+9 −3
Changes for autocnet/matcher/feature_extractor.py: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
import cv2

from scipy.misc import bytescale

try:
    import cyvlfeat as vl
    vlfeat = True
@@ -8,7 +10,7 @@ except:
    pass


def extract_features(array, method='orb', extractor_parameters=None):
def extract_features(array, method='orb', extractor_parameters={}):
    """
    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
@@ -19,8 +21,9 @@ def extract_features(array, method='orb', extractor_parameters=None):
    array : ndarray
            a NumPy array that represents an image

    detector : {'orb', 'sift', 'fast', 'surf'}
              The detector method to be used
    method : {'orb', 'sift', 'fast', 'surf', 'vl_sift'}
              The detector method to be used.  Note that vl_sift requires that
              vlfeat and cyvlfeat dependencies be installed.

    extractor_parameters : dict
                           A dictionary containing OpenCV SIFT parameters names and values.
@@ -41,5 +44,8 @@ def extract_features(array, method='orb', extractor_parameters=None):
    if 'vl_' in method:
        return detectors[method](array, compute_descriptor=True, float_descriptors=True, **extractor_parameters)
    else:
        # OpenCV requires the input images to be 8-bit
        if not array.dtype == 'int8':
            array = bytescale(array)
        detector = detectors[method](**extractor_parameters)
        return detector.detectAndCompute(array, None)