def set_edge_threshold(self, value): """ This is size of the border where the features are not detected. It should roughly match the patchSize parameter. """ if int(value) < 1: raise FeatureDetectorError( "ORB edge threshold must be positive integer") self._edge_threshold = int(value)
def create(det_type, options=None): if det_type not in DetectorType.LIST_ALL: raise FeatureDetectorError( "Unknown detector type: {}".format(det_type)) if det_type == DetectorType.ORB: detector = OrbDetector() elif det_type == DetectorType.SIFT: detector = SiftDetector() elif det_type == DetectorType.SURF: detector = SurfDetector() # MSER currently has no wrapper class due to the format of the output - need to update to reinstate this # elif type == DetectorType.MSER: # detector = MserDetector() elif det_type == DetectorType.BRISK: detector = BriskDetector() else: detector = Detector(detector=det_type) if options is not None: detector_options = options.get_detector_options(det_type) detector.set_from_config(detector_options) if detector.is_non_free(): licensing = options.get_licensing_options() use_non_free = licensing.use_non_free.value() if not use_non_free: detector.set_enabled(False) return detector
def set_n_levels(self, value): """ The number of pyramid levels. The smallest level will have linear size equal to input_image_linear_size/pow(scaleFactor, nlevels). """ if int(value) < 1: raise FeatureDetectorError( "ORB number of levels must be positive integer") self._n_levels = int(value)
def set_scale_factor(self, value): """ Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor will mean that to cover certain scale range you will need more pyramid levels and so the speed will suffer. """ if float(value) <= 1.0: raise FeatureDetectorError("ORB scale factor must be float great than 1.0") self._scale_factor = float(value)
def set_score_type(self, value): """ The default HARRIS_SCORE means that Harris algorithm is used to rank features (the score is written to KeyPoint::score and is used to retain best nfeatures features); FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints, but it is a little faster to compute. """ if value not in self.SCORE_TYPE_NAMES: raise FeatureDetectorError("ORB score type value must be one of {}".format(self.SCORE_TYPE_NAMES)) self._score_type = value
def __init__(self, detector=DEFAULT_DETECTOR): """ Supply a detector name to use that detector with all its default parameters. """ if detector not in DetectorType.LIST_ALL: raise FeatureDetectorError("No such feature detector available: " + detector) self._detector_name = detector self._adaptation = self.DEFAULT_ADAPTATION self._extractor_name = self.DEFAULT_EXTRACTOR self._normalization = self._default_normalization() self._keypoint_limit = self.DEFAULT_KEYPOINT_LIMIT
def set_wta_k(self, value): """ The number of points that produce each element of the oriented BRIEF descriptor. The default value 2 means the BRIEF where we take a random point pair and compare their brightnesses, so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3 random points (of course, those point coordinates are random, but they are generated from the pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such output will occupy 2 bits, and therefore it will need a special variant of Hamming distance, denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).""" if value not in self.WTA_K_VALUES: raise FeatureDetectorError("ORB WTA_K value must be one of {}".format(self.WTA_K_VALUES)) self._wta_k = value
def create(det_type, options=None): if det_type not in DetectorType.LIST_ALL: raise FeatureDetectorError( "Unknown detector type: {}".format(det_type)) if det_type == DetectorType.ORB: detector = OrbDetector() elif det_type == DetectorType.BRISK: detector = BriskDetector() else: detector = Detector(detector=det_type) if options is not None: detector_options = options.get_detector_options(det_type) detector.set_from_config(detector_options) return detector
def set_n_octave_layers(self, value): """ The number of images within each octave of a gaussian pyramid. """ if int(value) < 0: raise FeatureDetectorError("SURF number of octave layers must be integer >= 1") self._n_octaves = int(value)
def set_octaves(self, value): """ Detection octaves. Use 0 to do single scale. """ if int(value) < 0: raise FeatureDetectorError("BRISK octaves must be integer >= 0") self._octaves = int(value)
def set_n_features(self, value): """ The maximum number of features to retain. """ if int(value) < 1: raise FeatureDetectorError( "ORB number of features must be positive integer") self._n_features = int(value)
def set_patch_size(self, value): """ Size of the patch used by the oriented BRIEF descriptor. Of course, on smaller pyramid layers the perceived image area covered by a feature will be larger. """ if int(value) < 2: raise FeatureDetectorError("ORB patch size must be integer >= 2") self._patch_size = int(value)
def set_edge_blur_size(self, value): """ For color image, the aperture size for edge blur. """ if int(value) < 1: raise FeatureDetectorError( "MSER edge blur size must be positive integer") self._edge_blur_size = int(value)
def set_max_evolution(self, value): """ For color image, the evolution steps. """ if int(value) < 1: raise FeatureDetectorError( "MSER maximum evolution must be positive integer") self._max_evolution = int(value)
def set_max_area(self, value): """ Prune the area which bigger than maxArea. """ if int(value) < 1: raise FeatureDetectorError( "MSER maximum area must be positive integer") self._max_area = int(value)
def set_min_area(self, value): """ Prune the area which smaller than minArea. """ if int(value) < 1: raise FeatureDetectorError( "MSER minimum area must be positive integer") self._min_area = int(value)
def set_thresh(self, value): """ FAST/AGAST detection threshold score. """ if int(value) < 0: raise FeatureDetectorError("BRISK threshold must be integer >= 0") self._thresh = int(value)
def set_first_level(self, value): """ Should be 0 in the current implementation. """ if int(value) != 0: raise FeatureDetectorError("ORB first level value must be 0") self._first_level = int(value)
def set_adaptation(self, adaptation): if adaptation not in AdaptationType.LIST_ALL: raise FeatureDetectorError( "No such feature detector adaptation available: " + adaptation) self._adaptation = adaptation
def set_delta(self, value): """ Compares (sizei - sizei-delta)/sizei-delta. """ if int(value) < 1: raise FeatureDetectorError("MSER delta must be positive integer") self._delta = int(value)
def set_n_octaves(self, value): """ The number of a gaussian pyramid octaves that the detector uses. It is set to 4 by default. If you want to get very large features, use the larger value. If you want just small features, decrease it. """ if int(value) < 0: raise FeatureDetectorError("SURF number of octaves must be integer >= 0") self._n_octaves = int(value)