(name)
| 26 | |
| 27 | |
| 28 | def init_feature(name): |
| 29 | chunks = name.split('-') |
| 30 | if chunks[0] == 'sift': |
| 31 | detector = cv2.xfeatures2d.SIFT_create() |
| 32 | norm = cv2.NORM_L2 |
| 33 | elif chunks[0] == 'surf': |
| 34 | detector = cv2.xfeatures2d.SURF_create(800) |
| 35 | norm = cv2.NORM_L2 |
| 36 | elif chunks[0] == 'orb': |
| 37 | detector = cv2.ORB_create(400) |
| 38 | norm = cv2.NORM_HAMMING |
| 39 | elif chunks[0] == 'akaze': |
| 40 | detector = cv2.AKAZE_create() |
| 41 | norm = cv2.NORM_HAMMING |
| 42 | elif chunks[0] == 'brisk': |
| 43 | detector = cv2.BRISK_create() |
| 44 | norm = cv2.NORM_HAMMING |
| 45 | else: |
| 46 | return None, None |
| 47 | if 'flann' in chunks: |
| 48 | if norm == cv2.NORM_L2: |
| 49 | flann_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) |
| 50 | else: |
| 51 | flann_params= dict(algorithm = FLANN_INDEX_LSH, |
| 52 | table_number = 6, # 12 |
| 53 | key_size = 12, # 20 |
| 54 | multi_probe_level = 1) #2 |
| 55 | matcher = cv2.FlannBasedMatcher(flann_params, {}) # bug : need to pass empty dict (#1329) |
| 56 | else: |
| 57 | matcher = cv2.BFMatcher(norm) |
| 58 | return detector, matcher |
| 59 | |
| 60 | |
| 61 | def filter_matches(kp1, kp2, matches, ratio = 0.75): |
no outgoing calls
no test coverage detected