forked from luigifreda/pyslam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feature_tracker_configs.py
194 lines (160 loc) · 9.29 KB
/
feature_tracker_configs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
"""
* This file is part of PYSLAM
*
* Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com>
*
* PYSLAM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PYSLAM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PYSLAM. If not, see <http://www.gnu.org/licenses/>.
"""
from feature_tracker import feature_tracker_factory, FeatureTrackerTypes
from feature_manager import feature_manager_factory
from feature_types import FeatureDetectorTypes, FeatureDescriptorTypes, FeatureInfo
from feature_matcher import feature_matcher_factory, FeatureMatcherTypes
from parameters import Parameters
# some default parameters
kNumFeatures=Parameters.kNumFeatures
kRatioTest=Parameters.kFeatureMatchRatioTest
kTrackerType = FeatureTrackerTypes.DES_BF # default descriptor-based, brute force matching with knn
#kTrackerType = FeatureTrackerTypes.DES_FLANN # default descriptor-based, FLANN-based matching
"""
A collection of ready-to-used feature tracker configurations
"""
class FeatureTrackerConfigs(object):
# Test/Template configuration: you can use this to quickly test
# - your custom parameters and
# - favourite descriptor and detector (check the file feature_types.py)
TEST = dict(num_features=kNumFeatures,
num_levels = 8, # N.B: some detectors/descriptors do not allow to set num_levels or they set it on their own
scale_factor = 1.2, # N.B: some detectors/descriptors do not allow to set scale_factor or they set it on their own
detector_type = FeatureDetectorTypes.ORB2,
descriptor_type = FeatureDescriptorTypes.ORB2,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
# =====================================
# LK trackers (these can only be used with VisualOdometry() ... at the present time)
LK_SHI_TOMASI = dict(num_features=kNumFeatures,
num_levels = 3,
detector_type = FeatureDetectorTypes.SHI_TOMASI,
descriptor_type = FeatureDescriptorTypes.NONE,
tracker_type = FeatureTrackerTypes.LK)
LK_FAST = dict(num_features=kNumFeatures,
num_levels = 3,
detector_type = FeatureDetectorTypes.FAST,
descriptor_type = FeatureDescriptorTypes.NONE,
tracker_type = FeatureTrackerTypes.LK)
# =====================================
# Descriptor-based 'trackers'
SHI_TOMASI_ORB = dict(num_features=kNumFeatures, # N.B.: here, keypoints are not oriented! (i.e. keypoint.angle=0 always)
num_levels = 8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.SHI_TOMASI,
descriptor_type = FeatureDescriptorTypes.ORB,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
SHI_TOMASI_FREAK = dict(num_features=kNumFeatures,
num_levels=8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.SHI_TOMASI,
descriptor_type = FeatureDescriptorTypes.FREAK,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
FAST_ORB = dict(num_features=kNumFeatures, # N.B.: here, keypoints are not oriented! (i.e. keypoint.angle=0 always)
num_levels = 8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.FAST,
descriptor_type = FeatureDescriptorTypes.ORB,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
FAST_FREAK = dict(num_features=kNumFeatures,
num_levels = 8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.FAST,
descriptor_type = FeatureDescriptorTypes.FREAK,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
BRISK_TFEAT = dict(num_features=kNumFeatures,
num_levels = 4,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.BRISK,
descriptor_type = FeatureDescriptorTypes.TFEAT,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
ORB = dict(num_features=kNumFeatures,
num_levels = 8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.ORB,
descriptor_type = FeatureDescriptorTypes.ORB,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
ORB2 = dict(num_features=kNumFeatures,
num_levels = 8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.ORB2,
descriptor_type = FeatureDescriptorTypes.ORB2,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
ORB2_FREAK = dict(num_features=kNumFeatures,
num_levels = 8,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.ORB2,
descriptor_type = FeatureDescriptorTypes.FREAK,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
BRISK = dict(num_features=kNumFeatures,
num_levels = 8,
detector_type = FeatureDetectorTypes.BRISK,
descriptor_type = FeatureDescriptorTypes.BRISK,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
KAZE = dict(num_features=kNumFeatures,
num_levels = 8,
detector_type = FeatureDetectorTypes.KAZE,
descriptor_type = FeatureDescriptorTypes.KAZE,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
AKAZE = dict(num_features=kNumFeatures,
num_levels = 8,
detector_type = FeatureDetectorTypes.AKAZE,
descriptor_type = FeatureDescriptorTypes.AKAZE,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
SIFT = dict(num_features=kNumFeatures,
detector_type = FeatureDetectorTypes.SIFT,
descriptor_type = FeatureDescriptorTypes.SIFT,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
ROOT_SIFT = dict(num_features=kNumFeatures,
detector_type = FeatureDetectorTypes.ROOT_SIFT,
descriptor_type = FeatureDescriptorTypes.ROOT_SIFT,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
SURF = dict(num_features=kNumFeatures,
num_levels = 8,
detector_type = FeatureDetectorTypes.SURF,
descriptor_type = FeatureDescriptorTypes.SURF,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
SUPERPOINT = dict(num_features=kNumFeatures, # N.B.: here, keypoints are not oriented! (i.e. keypoint.angle=0 always)
num_levels = 1,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.SUPERPOINT,
descriptor_type = FeatureDescriptorTypes.SUPERPOINT,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)
CONTEXTDESC = dict(num_features=kNumFeatures,
num_levels = 1,
scale_factor = 1.2,
detector_type = FeatureDetectorTypes.CONTEXTDESC,
descriptor_type = FeatureDescriptorTypes.CONTEXTDESC,
match_ratio_test = kRatioTest,
tracker_type = kTrackerType)