diff --git a/opendm/config.py b/opendm/config.py index 99d56b8c..eb402837 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -6,6 +6,11 @@ processopts = ['resize', 'opensfm', 'cmvs', 'pmvs', 'odm_meshing', 'odm_texturing', 'odm_georeferencing', 'odm_orthophoto'] +class RerunFrom(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None) + setattr(namespace, self.dest, processopts[processopts.index(values):]) + + parser = argparse.ArgumentParser(description='OpenDroneMap') parser.add_argument('--project-path', metavar='', @@ -29,10 +34,23 @@ parser.add_argument('--end-with', '-e', choices=processopts, help=('Can be one of:' + ' | '.join(processopts))) -parser.add_argument('--rerun', '-r', - metavar='', - choices=processopts, - help=('Can be one of:' + ' | '.join(processopts))) +rerun = parser.add_mutually_exclusive_group() + +rerun.add_argument('--rerun', '-r', + metavar='', + choices=processopts, + help=('Can be one of:' + ' | '.join(processopts))) + +rerun.add_argument('--rerun-all', + action='store_true', + default=False, + help='force rerun of all tasks') + +rerun.add_argument('--rerun-from', + action=RerunFrom, + metavar='', + choices=processopts, + help=('Can be one of:' + ' | '.join(processopts))) parser.add_argument('--force-focal', metavar='', @@ -59,7 +77,7 @@ parser.add_argument('--matcher-threshold', type=float, help=('Ignore matched keypoints if the two images share ' 'less than percent of keypoints. Default:' - ' $(default)s')) + ' $(default)s')) parser.add_argument('--matcher-ratio', metavar='', diff --git a/scripts/cmvs.py b/scripts/cmvs.py index 0b3a2d87..0ec2a45f 100644 --- a/scripts/cmvs.py +++ b/scripts/cmvs.py @@ -28,8 +28,11 @@ class ODMCmvsCell(ecto.Cell): tree = self.inputs.tree # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'cmvs' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'cmvs') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'cmvs' in args['rerun_from']) if not io.file_exists(tree.pmvs_bundle) or rerun_cell: log.ODM_DEBUG('Writting CMVS vis in: %s' % tree.pmvs_bundle) diff --git a/scripts/odm_georeferencing.py b/scripts/odm_georeferencing.py index 40beb484..9a1f2009 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -63,8 +63,11 @@ class ODMGeoreferencingCell(ecto.Cell): return ecto.QUIT # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'odm_georeferencing' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'odm_georeferencing') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'odm_georeferencing' in args['rerun_from']) if not io.file_exists(tree.odm_textured_model_obj_geo) or \ not io.file_exists(tree.odm_textured_model_ply_geo) or rerun_cell: diff --git a/scripts/odm_meshing.py b/scripts/odm_meshing.py index 056deaa7..6d05f9d8 100644 --- a/scripts/odm_meshing.py +++ b/scripts/odm_meshing.py @@ -38,8 +38,11 @@ class ODMeshingCell(ecto.Cell): system.mkdir_p(tree.odm_meshing) # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'odm_meshing' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'odm_meshing') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'odm_meshing' in args['rerun_from']) if not io.file_exists(tree.odm_mesh) or rerun_cell: log.ODM_DEBUG('Writting ODM Mesh file in: %s' % tree.odm_mesh) diff --git a/scripts/odm_orthophoto.py b/scripts/odm_orthophoto.py index 848ff711..1ec409e5 100644 --- a/scripts/odm_orthophoto.py +++ b/scripts/odm_orthophoto.py @@ -28,8 +28,11 @@ class ODMOrthoPhotoCell(ecto.Cell): system.mkdir_p(tree.odm_orthophoto) # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'odm_orthophoto' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'odm_orthophoto') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'odm_orthophoto' in args['rerun_from']) if not io.file_exists(tree.odm_orthophoto_file) or rerun_cell: diff --git a/scripts/odm_texturing.py b/scripts/odm_texturing.py index 89b72650..774d09a8 100644 --- a/scripts/odm_texturing.py +++ b/scripts/odm_texturing.py @@ -32,8 +32,11 @@ class ODMTexturingCell(ecto.Cell): system.mkdir_p(tree.odm_texturing) # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'odm_texturing' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'odm_texturing') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'odm_texturing' in args['rerun_from']) if not io.file_exists(tree.odm_textured_model_obj) or rerun_cell: log.ODM_DEBUG('Writting ODM Textured file in: %s' \ diff --git a/scripts/opensfm.py b/scripts/opensfm.py index 9a9fa2f1..5afae332 100644 --- a/scripts/opensfm.py +++ b/scripts/opensfm.py @@ -38,8 +38,11 @@ class ODMOpenSfMCell(ecto.Cell): system.mkdir_p(tree.pmvs) # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'opensfm' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'opensfm') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'opensfm' in args['rerun_from']) ### check if reconstruction was done before diff --git a/scripts/pmvs.py b/scripts/pmvs.py index 8c29c503..97469e26 100644 --- a/scripts/pmvs.py +++ b/scripts/pmvs.py @@ -41,8 +41,11 @@ class ODMPmvsCell(ecto.Cell): tree = self.inputs.tree # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'pmvs' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'pmvs') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'pmvs' in args['rerun_from']) if not io.file_exists(tree.pmvs_model) or rerun_cell: log.ODM_DEBUG('Creating dense pointcloud in: %s' % tree.pmvs_model) diff --git a/scripts/resize.py b/scripts/resize.py index 9a890a77..1f77fc86 100644 --- a/scripts/resize.py +++ b/scripts/resize.py @@ -36,8 +36,11 @@ class ODMResizeCell(ecto.Cell): log.ODM_DEBUG('Resizing dataset to: %s' % tree.dataset_resize) # check if we rerun cell or not - rerun_cell = args['rerun'] is not None \ - and args['rerun'] == 'resize' + rerun_cell = (args['rerun'] is not None and + args['rerun'] == 'resize') or \ + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'resize' in args['rerun_from']) # loop over photos for photo in photos: