diff --git a/opendm/config.py b/opendm/config.py index 75234fe6..3f138818 100755 --- a/opendm/config.py +++ b/opendm/config.py @@ -752,6 +752,14 @@ def config(argv=None, parser=None): 'It\'s recommended to choose a band which has sharp details and is in focus. ' 'Default: %(default)s')) + parser.add_argument('--skip-band-alignment', + action=StoreTrue, + nargs=0, + default=False, + help=('When processing multispectral datasets, ODM will automatically align images for each band. ' + 'If your images have been postprocessed and are already aligned, you should use this option, which will skip the alignment computations. ' + 'Default: %(default)s')) + args = parser.parse_args(argv) # check that the project path setting has been set properly diff --git a/stages/run_opensfm.py b/stages/run_opensfm.py index dfb85ad9..d7459ff3 100644 --- a/stages/run_opensfm.py +++ b/stages/run_opensfm.py @@ -81,6 +81,10 @@ class ODMOpenSfMStage(types.ODM_Stage): def align_to_primary_band(shot_id, image): photo = reconstruction.get_photo(shot_id) + # No need to align if requested by user + if args.skip_band_alignment: + return image + # No need to align primary if photo.band_name == primary_band_name: return image @@ -109,11 +113,16 @@ class ODMOpenSfMStage(types.ODM_Stage): # We finally restore the original files later added_shots_file = octx.path('added_shots_done.txt') - + if not io.file_exists(added_shots_file) or self.rerun(): primary_band_name = multispectral.get_primary_band_name(reconstruction.multi_camera, args.primary_band) s2p, p2s = multispectral.compute_band_maps(reconstruction.multi_camera, primary_band_name) - alignment_info = multispectral.compute_alignment_matrices(reconstruction.multi_camera, primary_band_name, tree.dataset_raw, s2p, p2s, max_concurrency=args.max_concurrency) + + if not args.skip_band_alignment: + alignment_info = multispectral.compute_alignment_matrices(reconstruction.multi_camera, primary_band_name, tree.dataset_raw, s2p, p2s, max_concurrency=args.max_concurrency) + else: + log.ODM_WARNING("Skipping band alignment") + alignment_info = {} log.ODM_INFO("Adding shots to reconstruction")