@@ -35,21 +35,12 @@ def resized_image(image, config):
3535
3636
3737def root_feature (desc , l2_normalization = False ):
38- if l2_normalization :
39- s2 = np .linalg .norm (desc , axis = 1 )
40- desc = (desc .T / s2 ).T
41- s = np .sum (desc , 1 )
42- desc = np .sqrt (desc .T / s ).T
43- return desc
44-
45-
46- def root_feature_sift_gpu (desc , l2_normalization = False ):
4738 if l2_normalization :
4839 s2 = np .linalg .norm (desc , axis = 1 )
4940 idx = np .where (s2 == 0 )
5041 s2 [idx ] = 1
5142 desc = (desc .T / s2 ).T
52- s = np .max (desc , 1 )
43+ s = np .sum (desc , 1 )
5344 idx = np .where (s == 0 )
5445 s [idx ] = 1
5546 desc = np .sqrt (desc .T / s ).T
@@ -150,7 +141,7 @@ def extract_features_sift(image, config):
150141
151142def extract_features_sift_gpu (image , config ):
152143 check_gpu_initialization (config , image )
153- keypoints = sift_gpu .detect_image (image )
144+ keypoints = sift_gpu .detect_image (image , config )
154145 idx = np .where (np .sum (keypoints .desc , 1 ) != 0 )
155146 keypoints = keypoints [idx ]
156147
@@ -160,8 +151,8 @@ def extract_features_sift_gpu(image, config):
160151 np .expand_dims (keypoints [:].angle , axis = 1 )], axis = 1 )
161152 desc = np .array (keypoints [:].desc , dtype = np .float32 )
162153 if config ['feature_root' ]:
163- desc = root_feature_sift_gpu (desc )
164- return points , desc , keypoints
154+ desc = root_feature (desc )
155+ return points , desc
165156
166157
167158def extract_features_surf (image , config ):
@@ -317,17 +308,14 @@ def extract_features(color_image, config):
317308 elif feature_type == 'ORB' :
318309 points , desc = extract_features_orb (image , config )
319310 elif feature_type == 'SIFT_GPU' :
320- points , desc , keypoints = extract_features_sift_gpu (image , config )
311+ points , desc = extract_features_sift_gpu (image , config )
321312 else :
322313 raise ValueError ('Unknown feature type '
323314 '(must be SURF, SIFT, AKAZE, HAHOG, SIFT_GPU or ORB)' )
324315
325316 xs = points [:, 0 ].round ().astype (int )
326317 ys = points [:, 1 ].round ().astype (int )
327318 colors = color_image [ys , xs ]
328- if keypoints is not None :
329- return normalize_features (points , desc , colors ,
330- image .shape [1 ], image .shape [0 ]), keypoints
331319 return normalize_features (points , desc , colors ,
332320 image .shape [1 ], image .shape [0 ])
333321
0 commit comments