22
22
import kapture_localization .utils .path_to_kapture # noqa: F401
23
23
import kapture .utils .logging
24
24
from kapture .utils .paths import safe_remove_file
25
+
25
26
logger = logging .getLogger ('localization_pipeline' )
27
+ DEFAULT_TOPK = 20
26
28
27
29
28
30
def localize_pipeline (kapture_map_path : str ,
@@ -252,9 +254,9 @@ def localize_pipeline(kapture_map_path: str,
252
254
run_python_command (local_export_LTVL2020_path , export_LTVL2020_args , python_binary )
253
255
254
256
255
- def localize_pipeline_command_line ():
257
+ def localize_pipeline_get_parser ():
256
258
"""
257
- Parse the command line arguments to localize images on a colmap map using the given kapture data.
259
+ get the argparse object for the kapture_pipeline_localize.py command
258
260
"""
259
261
parser = argparse .ArgumentParser (description = 'localize images given in kapture format on a colmap map' )
260
262
parser_verbosity = parser .add_mutually_exclusive_group ()
@@ -303,9 +305,8 @@ def localize_pipeline_command_line():
303
305
' can infer the python binary from the files itself, shebang or extension).' )
304
306
parser_python_bin .add_argument ('--auto-python-binary' , action = 'store_true' , default = False ,
305
307
help = 'use sys.executable as python binary.' )
306
- default_topk = 20
307
308
parser .add_argument ('--topk' ,
308
- default = default_topk ,
309
+ default = DEFAULT_TOPK ,
309
310
type = int ,
310
311
help = 'the max number of top retained images when computing image pairs from global features' )
311
312
parser .add_argument ('--config' , default = 1 , type = int ,
@@ -335,6 +336,14 @@ def localize_pipeline_command_line():
335
336
parser .add_argument ('--keypoints-type' , default = None , help = 'kapture keypoints type.' )
336
337
parser .add_argument ('--descriptors-type' , default = None , help = 'kapture descriptors type.' )
337
338
parser .add_argument ('--global-features-type' , default = None , help = 'kapture global features type.' )
339
+ return parser
340
+
341
+
342
+ def localize_pipeline_command_line ():
343
+ """
344
+ Parse the command line arguments to localize images on a colmap map using the given kapture data.
345
+ """
346
+ parser = localize_pipeline_get_parser ()
338
347
args = parser .parse_args ()
339
348
340
349
logger .setLevel (args .verbose )
@@ -343,7 +352,8 @@ def localize_pipeline_command_line():
343
352
kapture .utils .logging .getLogger ().setLevel (args .verbose )
344
353
kapture_localization .utils .logging .getLogger ().setLevel (args .verbose )
345
354
346
- if args .pairsfile_path is not None and args .topk != default_topk :
355
+ # only show the warning if the user attempted to change the topk value since it'll have no effect
356
+ if args .pairsfile_path is not None and args .topk != DEFAULT_TOPK :
347
357
logger .warning (f'pairsfile was given explicitely, paramerer topk={ args .topk } will be ignored' )
348
358
349
359
args_dict = vars (args )
0 commit comments