def image_retrieval_benchmark_command_line(): """ Parse the command line arguments to run the image retrieval benchmark on kapture data. """ parser = image_retrieval_benchmark_get_parser() args = parser.parse_args() logger.setLevel(args.verbose) if args.verbose <= logging.INFO: # also let kapture express its logs kapture.utils.logging.getLogger().setLevel(args.verbose) kapture_localization.utils.logging.getLogger().setLevel(args.verbose) args_dict = vars(args) logger.debug('image_retrieval_benchmark.py \\\n' + ' \\\n'.join('--{:20} {:100}'.format(k, str(v)) for k, v in args_dict.items())) if can_use_symlinks(): python_binary = args.python_binary if args.auto_python_binary: python_binary = sys.executable logger.debug(f'python_binary set to {python_binary}') image_retrieval_benchmark( args.kapture_map, args.query, args.merge_path, args.keypoints_path, args.descriptors_path, args.global_features_path, args.matches_path, args.matches_gv_path, args.keypoints_type, args.descriptors_type, args.global_features_type, args.colmap_map, args.output, args.colmap_binary, python_binary, args.topk, args.config, args.benchmark_style, args.skip, args.force) else: raise EnvironmentError( 'Please restart this command as admin, it is required for os.symlink' 'see https://docs.python.org/3.6/library/os.html#os.symlink')
def localize_pipeline_command_line(): """ Parse the command line arguments to localize images on a colmap map using the given kapture data. """ parser = localize_pipeline_get_parser() args = parser.parse_args() logger.setLevel(args.verbose) if args.verbose <= logging.INFO: # also let kapture express its logs kapture.utils.logging.getLogger().setLevel(args.verbose) kapture_localization.utils.logging.getLogger().setLevel(args.verbose) # only show the warning if the user attempted to change the topk value since it'll have no effect if args.pairsfile_path is not None and args.topk != DEFAULT_TOPK: logger.warning(f'pairsfile was given explicitely, paramerer topk={args.topk} will be ignored') args_dict = vars(args) logger.debug('localize.py \\\n' + ' \\\n'.join( '--{:20} {:100}'.format(k, str(v)) for k, v in args_dict.items())) if can_use_symlinks(): python_binary = args.python_binary if args.auto_python_binary: python_binary = sys.executable logger.debug(f'python_binary set to {python_binary}') localize_pipeline(args.kapture_map, args.query, args.merge_path, args.keypoints_path, args.descriptors_path, args.global_features_path, args.pairsfile_path, args.matches_path, args.matches_gv_path, args.keypoints_type, args.descriptors_type, args.global_features_type, args.colmap_map, args.output, args.colmap_binary, python_binary, args.topk, args.config, args.benchmark_style, args.bins, args.skip, args.force) else: raise EnvironmentError('Please restart this command as admin, it is required for os.symlink' 'see https://docs.python.org/3.6/library/os.html#os.symlink')
def image_retrieval_benchmark_command_line(): """ Parse the command line arguments to run the image retrieval benchmark on kapture data. """ parser = argparse.ArgumentParser( description='run the image retrieval benchmark on kapture data') parser_verbosity = parser.add_mutually_exclusive_group() parser_verbosity.add_argument( '-v', '--verbose', nargs='?', default=logging.WARNING, const=logging.INFO, action=kapture.utils.logging.VerbosityParser, help= 'verbosity level (debug, info, warning, critical, ... or int value) [warning]' ) parser_verbosity.add_argument('-q', '--silent', '--quiet', action='store_const', dest='verbose', const=logging.CRITICAL) parser.add_argument( '-f', '-y', '--force', action='store_true', default=False, help= 'silently delete pairfile and localization results if already exists.') parser.add_argument('-i', '--kapture-map', required=True, help='path to the kapture map directory') parser.add_argument( '--query', required=True, help='input path to kapture mapping data root directory') parser.add_argument( '--merge-path', required=False, default=None, help= ('optional, path to the kapture map+query directory. ' 'using this will skip the call to kapture_merge.py and save some time' )) parser.add_argument('-kpt', '--keypoints-path', required=True, help='input path to the orphan keypoints folder') parser.add_argument('-desc', '--descriptors-path', required=True, help='input path to the orphan descriptors folder') parser.add_argument('-gfeat', '--global-features-path', required=True, help='input path to the orphan global features folder') parser.add_argument( '-matches', '--matches-path', required=True, help= 'input path to the orphan matches (no geometric verification) folder') parser.add_argument( '-matches-gv', '--matches-gv-path', required=True, help= 'input path to the orphan matches (with geometric verification) folder' ) parser.add_argument('--colmap-map', required=True, help='path to the colmap map directory') parser.add_argument('-o', '--output', required=True, help='output directory.') parser.add_argument('-colmap', '--colmap_binary', required=False, default="colmap", help='full path to colmap binary ' '(default is "colmap", i.e. assume the binary' ' is in the user PATH).') parser_python_bin = parser.add_mutually_exclusive_group() parser_python_bin.add_argument( '-python', '--python_binary', required=False, default=None, help='full path to python binary ' '(default is "None", i.e. assume the os' ' can infer the python binary from the files itself, shebang or extension).' ) parser_python_bin.add_argument('--auto-python-binary', action='store_true', default=False, help='use sys.executable as python binary.') parser.add_argument( '--topk', default=20, type=int, help= 'the max number of top retained images when computing image pairs from global features' ) parser.add_argument( '--config', default=1, type=int, choices=list(range(len(CONFIGS))), help='what config to use for global sfm image registrator') parser.add_argument( '--prepend_cam', action='store_true', default=False, help=('prepend camera names to filename in LTVL2020 formatted output. ' 'Toggle this only for RobotCar_Seasons and RobotCar Seasons v2')) parser.add_argument('-s', '--skip', choices=[ 'compute_image_pairs', 'compute_matches', 'geometric_verification', 'global_sfm', 'local_sfm', 'pose_approximation', 'evaluate', 'export_LTVL2020' ], nargs='+', default=[], help='steps to skip') args = parser.parse_args() logger.setLevel(args.verbose) if args.verbose <= logging.INFO: # also let kapture express its logs kapture.utils.logging.getLogger().setLevel(args.verbose) kapture_localization.utils.logging.getLogger().setLevel(args.verbose) args_dict = vars(args) logger.debug('image_retrieval_benchmark.py \\\n' + ' \\\n'.join('--{:20} {:100}'.format(k, str(v)) for k, v in args_dict.items())) if can_use_symlinks(): python_binary = args.python_binary if args.auto_python_binary: python_binary = sys.executable logger.debug(f'python_binary set to {python_binary}') image_retrieval_benchmark( args.kapture_map, args.query, args.merge_path, args.keypoints_path, args.descriptors_path, args.global_features_path, args.matches_path, args.matches_gv_path, args.colmap_map, args.output, args.colmap_binary, python_binary, args.topk, args.config, args.prepend_cam, args.skip, args.force) else: raise EnvironmentError( 'Please restart this command as admin, it is required for os.symlink' 'see https://docs.python.org/3.6/library/os.html#os.symlink')
def mapping_pipeline_command_line(): """ Parse the command line arguments to build a colmap map using the given kapture data. """ parser = argparse.ArgumentParser(description=('create a Colmap model (map) from data specified in kapture format.' 'kapture data must contain keypoints, descriptors and ' 'global features')) parser_verbosity = parser.add_mutually_exclusive_group() parser_verbosity.add_argument('-v', '--verbose', nargs='?', default=logging.WARNING, const=logging.INFO, action=kapture.utils.logging.VerbosityParser, help='verbosity level (debug, info, warning, critical, ... or int value) [warning]') parser_verbosity.add_argument('-q', '--silent', '--quiet', action='store_const', dest='verbose', const=logging.CRITICAL) parser.add_argument('-f', '-y', '--force', action='store_true', default=False, help='silently delete pairfile and colmap reconstruction if already exists.') parser.add_argument('-i', '--kapture-map', required=True, help='input path to kapture mapping data root directory') parser.add_argument('-kpt', '--keypoints-path', required=True, help='input path to the orphan keypoints folder') parser.add_argument('-desc', '--descriptors-path', required=True, help='input path to the orphan descriptors folder') parser.add_argument('-gfeat', '--global-features-path', required=True, help='input path to the orphan global features folder') parser.add_argument('-matches', '--matches-path', required=True, help='input path to the orphan matches (no geometric verification) folder') parser.add_argument('-matches-gv', '--matches-gv-path', required=True, help='input path to the orphan matches (with geometric verification) folder') parser.add_argument('--colmap-map', required=True, help='output directory for the pairfile and colmap reconstruction.') parser.add_argument('-colmap', '--colmap_binary', required=False, default="colmap", help='full path to colmap binary ' '(default is "colmap", i.e. assume the binary' ' is in the user PATH).') parser_python_bin = parser.add_mutually_exclusive_group() parser_python_bin.add_argument('-python', '--python_binary', required=False, default=None, help='full path to python binary ' '(default is "None", i.e. assume the os' ' can infer the python binary from the files itself, shebang or extension).') parser_python_bin.add_argument('--auto-python-binary', action='store_true', default=False, help='use sys.executable as python binary.') parser.add_argument('--topk', default=20, type=int, help='the max number of top retained images when computing image pairs from global features') parser.add_argument('-s', '--skip', choices=['compute_image_pairs', 'compute_matches', 'geometric_verification', 'colmap_build_map'], nargs='+', default=[], help='steps to skip') args = parser.parse_args() logger.setLevel(args.verbose) if args.verbose <= logging.INFO: # also let kapture express its logs kapture.utils.logging.getLogger().setLevel(args.verbose) kapture_localization.utils.logging.getLogger().setLevel(args.verbose) args_dict = vars(args) logger.debug('mapping.py \\\n' + ' \\\n'.join( '--{:20} {:100}'.format(k, str(v)) for k, v in args_dict.items())) if can_use_symlinks(): python_binary = args.python_binary if args.auto_python_binary: python_binary = sys.executable logger.debug(f'python_binary set to {python_binary}') mapping_pipeline(args.kapture_map, args.keypoints_path, args.descriptors_path, args.global_features_path, args.matches_path, args.matches_gv_path, args.colmap_map, args.colmap_binary, python_binary, args.topk, args.skip, args.force) else: raise EnvironmentError('Please restart this command as admin, it is required for os.symlink' 'see https://docs.python.org/3.6/library/os.html#os.symlink')
def create_kapture_proxy_command_line(): parser = argparse.ArgumentParser( description='Create a proxy kapture from a source kapture with only sensors data and orphan features.') parser_verbosity = parser.add_mutually_exclusive_group() parser_verbosity.add_argument('-v', '--verbose', nargs='?', default=logging.WARNING, const=logging.INFO, action=kapture.utils.logging.VerbosityParser, help='verbosity level (debug, info, warning, critical, ... or int value) [warning]') parser_verbosity.add_argument('-q', '--silent', '--quiet', action='store_const', dest='verbose', const=logging.CRITICAL) parser.add_argument('-f', '-y', '--force', action='store_true', default=False, help='silently output folder content if it already exist.') parser.add_argument('-i', '--input', required=True, help=('input path to kapture input root directory' ' (only sensors will be used)')) parser.add_argument('-o', '--output', required=True, help='output path to the proxy kapture') parser.add_argument('-kpt', '--keypoints-path', default=None, nargs='+', help='input path to the orphan keypoints folder') parser.add_argument('-desc', '--descriptors-path', default=None, nargs='+', help='input path to the orphan descriptors folder') parser.add_argument('-gfeat', '--global-features-path', default=None, nargs='+', help='input path to the orphan global features folder') parser.add_argument('-matches', '--matches-path', default=None, nargs='+', help=('input path to the orphan matches folder, ' 'if both keypoints-path and matches-paths are given, ' 'the order of the two list must be the same (same as keypoints-type), ' 'use the none if necessary, it will be converted to None in code')) parser.add_argument('--keypoints-type', default=None, nargs='+', help='kapture keypoints types.') parser.add_argument('--descriptors-type', default=None, nargs='+', help='kapture descriptors types.') parser.add_argument('--global-features-type', default=None, nargs='+', help='kapture global features types.') args = parser.parse_args() logger.setLevel(args.verbose) if args.verbose <= logging.DEBUG: # also let kapture express its logs kapture.utils.logging.getLogger().setLevel(args.verbose) kapture_localization.utils.logging.getLogger().setLevel(args.verbose) logger.debug(''.join(['\n\t{:13} = {}'.format(k, v) for k, v in vars(args).items()])) if can_use_symlinks(): keypoints_paths = _convert_none_string_array(args.keypoints_path) descriptors_paths = args.descriptors_path global_features_path = args.global_features_path matches_paths = _convert_none_string_array(args.matches_path) keypoints_types = _convert_none_string_array(args.keypoints_type) descriptors_types = _convert_none_string_array(args.descriptors_type) global_features_types = _convert_none_string_array(args.global_features_type) create_kapture_proxy(args.output, args.input, keypoints_paths, descriptors_paths, global_features_path, matches_paths, keypoints_types, descriptors_types, global_features_types, args.force) else: raise EnvironmentError('Please restart this command as admin, it is required for os.symlink' 'see https://docs.python.org/3.6/library/os.html#os.symlink')