From c25388b0c2ca5bd4cd87d49cfa1c5197dfb9af2c Mon Sep 17 00:00:00 2001 From: Dakota Benjamin Date: Thu, 25 Feb 2016 10:18:48 -0500 Subject: [PATCH 1/4] Add rerun-all and rerun-from arguments --- opendm/config.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/opendm/config.py b/opendm/config.py index 99d56b8c..136eeb50 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -29,10 +29,22 @@ 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', + metavar='', + choices=processopts, + help=('Can be one of:' + ' | '.join(processopts))) parser.add_argument('--force-focal', metavar='', @@ -59,7 +71,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='', From dee63447dfee074307cc2c71784c1fc92e34c8bf Mon Sep 17 00:00:00 2001 From: Dakota Benjamin Date: Thu, 25 Feb 2016 11:24:32 -0500 Subject: [PATCH 2/4] Add --rerun-all functionality --- scripts/cmvs.py | 5 +++-- scripts/odm_georeferencing.py | 5 +++-- scripts/odm_meshing.py | 5 +++-- scripts/odm_orthophoto.py | 5 +++-- scripts/odm_texturing.py | 5 +++-- scripts/opensfm.py | 5 +++-- scripts/pmvs.py | 5 +++-- scripts/resize.py | 5 +++-- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/scripts/cmvs.py b/scripts/cmvs.py index 0b3a2d87..baa77c05 100644 --- a/scripts/cmvs.py +++ b/scripts/cmvs.py @@ -28,8 +28,9 @@ 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'] 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..7c63dc3b 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -63,8 +63,9 @@ 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'] 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..527fae5a 100644 --- a/scripts/odm_meshing.py +++ b/scripts/odm_meshing.py @@ -38,8 +38,9 @@ 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'] 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..6d93b7f2 100644 --- a/scripts/odm_orthophoto.py +++ b/scripts/odm_orthophoto.py @@ -28,8 +28,9 @@ 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'] 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..8d965072 100644 --- a/scripts/odm_texturing.py +++ b/scripts/odm_texturing.py @@ -32,8 +32,9 @@ 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'] 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..156f4393 100644 --- a/scripts/opensfm.py +++ b/scripts/opensfm.py @@ -38,8 +38,9 @@ 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'] ### check if reconstruction was done before diff --git a/scripts/pmvs.py b/scripts/pmvs.py index 8c29c503..e0dd18e4 100644 --- a/scripts/pmvs.py +++ b/scripts/pmvs.py @@ -41,8 +41,9 @@ 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'] 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..dfa6ee26 100644 --- a/scripts/resize.py +++ b/scripts/resize.py @@ -36,8 +36,9 @@ 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'] # loop over photos for photo in photos: From 6bf072dfaa966056932108bb870a68babb52dc8a Mon Sep 17 00:00:00 2001 From: Dakota Benjamin Date: Thu, 25 Feb 2016 13:39:38 -0500 Subject: [PATCH 3/4] Add --rerun-from functionality --- opendm/config.py | 7 +++++++ scripts/cmvs.py | 4 +++- scripts/odm_georeferencing.py | 4 +++- scripts/odm_meshing.py | 4 +++- scripts/odm_orthophoto.py | 4 +++- scripts/odm_texturing.py | 4 +++- scripts/opensfm.py | 4 +++- scripts/pmvs.py | 4 +++- scripts/resize.py | 4 +++- 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/opendm/config.py b/opendm/config.py index 136eeb50..2ab5ebbe 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -6,6 +6,12 @@ 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): + print processopts[processopts.index(values):] + setattr(namespace, self.dest, processopts[processopts.index(values):]) + + parser = argparse.ArgumentParser(description='OpenDroneMap') parser.add_argument('--project-path', metavar='', @@ -42,6 +48,7 @@ rerun.add_argument('--rerun-all', help='force rerun of all tasks') rerun.add_argument('--rerun-from', + action=RerunFrom, metavar='', choices=processopts, help=('Can be one of:' + ' | '.join(processopts))) diff --git a/scripts/cmvs.py b/scripts/cmvs.py index baa77c05..0ec2a45f 100644 --- a/scripts/cmvs.py +++ b/scripts/cmvs.py @@ -30,7 +30,9 @@ class ODMCmvsCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'cmvs') or \ - args['rerun_all'] + (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 7c63dc3b..9a1f2009 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -65,7 +65,9 @@ class ODMGeoreferencingCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'odm_georeferencing') or \ - args['rerun_all'] + (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 527fae5a..6d05f9d8 100644 --- a/scripts/odm_meshing.py +++ b/scripts/odm_meshing.py @@ -40,7 +40,9 @@ class ODMeshingCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'odm_meshing') or \ - args['rerun_all'] + (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 6d93b7f2..1ec409e5 100644 --- a/scripts/odm_orthophoto.py +++ b/scripts/odm_orthophoto.py @@ -30,7 +30,9 @@ class ODMOrthoPhotoCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'odm_orthophoto') or \ - args['rerun_all'] + (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 8d965072..774d09a8 100644 --- a/scripts/odm_texturing.py +++ b/scripts/odm_texturing.py @@ -34,7 +34,9 @@ class ODMTexturingCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'odm_texturing') or \ - args['rerun_all'] + (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 156f4393..5afae332 100644 --- a/scripts/opensfm.py +++ b/scripts/opensfm.py @@ -40,7 +40,9 @@ class ODMOpenSfMCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'opensfm') or \ - args['rerun_all'] + (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 e0dd18e4..97469e26 100644 --- a/scripts/pmvs.py +++ b/scripts/pmvs.py @@ -43,7 +43,9 @@ class ODMPmvsCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'pmvs') or \ - args['rerun_all'] + (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 dfa6ee26..1f77fc86 100644 --- a/scripts/resize.py +++ b/scripts/resize.py @@ -38,7 +38,9 @@ class ODMResizeCell(ecto.Cell): # check if we rerun cell or not rerun_cell = (args['rerun'] is not None and args['rerun'] == 'resize') or \ - args['rerun_all'] + (args['rerun_all']) or \ + (args['rerun_from'] is not None and + 'resize' in args['rerun_from']) # loop over photos for photo in photos: From 9250e8c80e3977a337f82455e585f0853b5f082f Mon Sep 17 00:00:00 2001 From: Dakota Benjamin Date: Thu, 25 Feb 2016 13:45:32 -0500 Subject: [PATCH 4/4] Remove debug print line from config --- opendm/config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/opendm/config.py b/opendm/config.py index 2ab5ebbe..eb402837 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -7,8 +7,7 @@ processopts = ['resize', 'opensfm', 'cmvs', 'pmvs', 'odm_orthophoto'] class RerunFrom(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - print processopts[processopts.index(values):] + def __call__(self, parser, namespace, values, option_string=None) setattr(namespace, self.dest, processopts[processopts.index(values):])