Ejemplo n.º 1
0
 def __init__(
         self,
         num_features=kMinNumFeatureDefault,
         num_levels=3,  # number of pyramid levels for detector  
         scale_factor=1.2,  # detection scale factor (if it can be set, otherwise it is automatically computed) 
         detector_type=FeatureDetectorTypes.FAST,
         descriptor_type=FeatureDescriptorTypes.NONE,
         match_ratio_test=kRatioTest,
         tracker_type=FeatureTrackerTypes.LK):
     super().__init__(num_features=num_features,
                      num_levels=num_levels,
                      scale_factor=scale_factor,
                      detector_type=detector_type,
                      descriptor_type=descriptor_type,
                      tracker_type=tracker_type)
     self.feature_manager = feature_manager_factory(
         num_features=num_features,
         num_levels=num_levels,
         scale_factor=scale_factor,
         detector_type=detector_type,
         descriptor_type=descriptor_type)
     #if num_levels < 3:
     #    Printer.green('LkFeatureTracker: forcing at least 3 levels on LK pyr optic flow')
     #    num_levels = 3
     optic_flow_num_levels = max(kLkPyrOpticFlowNumLevelsMin, num_levels)
     Printer.green('LkFeatureTracker: num levels on LK pyr optic flow: ',
                   optic_flow_num_levels)
     # we use LK pyr optic flow for matching
     self.lk_params = dict(winSize=(21, 21),
                           maxLevel=optic_flow_num_levels,
                           criteria=(cv2.TERM_CRITERIA_EPS
                                     | cv2.TERM_CRITERIA_COUNT, 30, 0.01))
Ejemplo n.º 2
0
    def __init__(
            self,
            num_features=kMinNumFeatureDefault,
            num_levels=1,  # number of pyramid levels for detector  
            scale_factor=1.2,  # detection scale factor (if it can be set, otherwise it is automatically computed)                
            detector_type=FeatureDetectorTypes.FAST,
            descriptor_type=FeatureDescriptorTypes.ORB,
            match_ratio_test=kRatioTest,
            tracker_type=FeatureTrackerTypes.DES_FLANN):
        super().__init__(num_features=num_features,
                         num_levels=num_levels,
                         scale_factor=scale_factor,
                         detector_type=detector_type,
                         descriptor_type=descriptor_type,
                         match_ratio_test=match_ratio_test,
                         tracker_type=tracker_type)
        self.feature_manager = feature_manager_factory(
            num_features=num_features,
            num_levels=num_levels,
            scale_factor=scale_factor,
            detector_type=detector_type,
            descriptor_type=descriptor_type)

        if tracker_type == FeatureTrackerTypes.DES_FLANN:
            self.matching_algo = FeatureMatcherTypes.FLANN
        elif tracker_type == FeatureTrackerTypes.DES_BF:
            self.matching_algo = FeatureMatcherTypes.BF
        else:
            raise ValueError("Unmanaged matching algo for feature tracker %s" %
                             self.tracker_type)

        # init matcher
        self.matcher = feature_matcher_factory(norm_type=self.norm_type,
                                               ratio_test=match_ratio_test,
                                               type=self.matching_algo)
Ejemplo n.º 3
0
#img = cv2.imread('../data/kitti06-12.png',cv2.IMREAD_COLOR)
#img = cv2.imread('../data/kitti06-435.png',cv2.IMREAD_COLOR)
img = cv2.imread('../data/kitti06-12-color.png', cv2.IMREAD_COLOR)
#img = cv2.imread('../data/mars1.png')

num_features = 2000

# select your tracker configuration (see the file feature_tracker_configs.py)
feature_tracker_config = FeatureTrackerConfigs.TEST
feature_tracker_config['num_features'] = num_features

feature_manager_config = FeatureManagerConfigs.extract_from(
    feature_tracker_config)
print('feature_manager_config: ', feature_manager_config)
feature_manager = feature_manager_factory(**feature_manager_config)

des = None

# loop for measuring time performance
N = 20
for i in range(N):
    timer.start()

    # just detect keypoints
    #kps = feature_manager.detect(img)

    # detect keypoints and compute descriptors
    kps, des = feature_manager.detectAndCompute(img)

    timer.refresh()