Exemplo n.º 1
0
def import_opensfm_command_line():
    """
    Imports openSfM to kapture.
    """
    parser = argparse.ArgumentParser(description='Imports openSfM to kapture')
    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('-i',
                        '--input',
                        '--opensfm',
                        required=True,
                        help='path to OpenSfM root directory.')
    parser.add_argument('-o',
                        '-k',
                        '--output',
                        '--kapture',
                        required=True,
                        help='output directory where to save kapture files.')
    parser.add_argument(
        '--transfer',
        type=TransferAction,
        default=TransferAction.link_absolute,
        help=f'How to import images [link_absolute], choose among: '
        f'{", ".join(a.name for a in TransferAction)}')
    parser.add_argument('-f',
                        '-y',
                        '--force',
                        action='store_true',
                        default=False,
                        help='Force delete kapture if already exists.')
    args = parser.parse_args()
    ####################################################################################################################
    logger.setLevel(args.verbose)
    if args.verbose <= logging.DEBUG:
        # for debug, let kapture express itself.
        kapture.utils.logging.getLogger().setLevel(args.verbose)

    logger.debug('\\\n'.join('--{:20} {:100}'.format(k, str(v))
                             for k, v in vars(args).items() if k != 'command'))

    args.input = path.normpath(path.abspath(args.input))
    args.output = path.normpath(path.abspath(args.output))

    import_opensfm(args.input, args.output, args.force, args.transfer)
Exemplo n.º 2
0
 def test_import_opensfm(self) -> None:
     """
     Test the import_opensfm function on small sample
     """
     # convert and then load
     file_operation = TransferAction.skip if self.isWindows else TransferAction.link_relative
     import_opensfm(
         self._opensfm_sample_path,
         self._kapture_rebuilt_path,
         force_overwrite_existing=False,
         images_import_method=file_operation
     )
     kapture_data_expected = csv.kapture_from_dir(self._kapture_sample_path)
     kapture_data_actual = csv.kapture_from_dir(self._kapture_rebuilt_path)
     # check in detail what could be wrong
     self.assertTrue(equal_sensors(kapture_data_expected.sensors, kapture_data_actual.sensors))
     self.assertTrue(equal_records_gnss(kapture_data_expected.records_gnss, kapture_data_actual.records_gnss))
     # check all at once
     self.assertTrue(equal_kapture(kapture_data_expected, kapture_data_actual))