diff --git a/VERSION b/VERSION index 1545d966..d5c0c991 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.0 +3.5.1 diff --git a/opendm/osfm.py b/opendm/osfm.py index 7a3f2e03..0d49e1e4 100644 --- a/opendm/osfm.py +++ b/opendm/osfm.py @@ -793,3 +793,12 @@ def get_all_submodel_paths(submodels_path, *all_paths): result.append([os.path.join(submodels_path, f, ap) for ap in all_paths]) return result + +def is_submodel(opensfm_root): + # A bit hackish, but works without introducing additional markers / flags + # Look at the path of the opensfm directory and see if "submodel_" is part of it + parts = os.path.abspath(opensfm_root).split(os.path.sep) + + return (len(parts) >= 2 and parts[-2][:9] == "submodel_") or \ + os.path.isfile(os.path.join(opensfm_root, "split_merge_stop_at_reconstruction.txt")) or \ + os.path.isfile(os.path.join(opensfm_root, "features", "empty")) \ No newline at end of file diff --git a/stages/odm_orthophoto.py b/stages/odm_orthophoto.py index cf362bb3..e66d89db 100644 --- a/stages/odm_orthophoto.py +++ b/stages/odm_orthophoto.py @@ -7,6 +7,7 @@ from opendm import context from opendm import types from opendm import gsd from opendm import orthophoto +from opendm.osfm import is_submodel from opendm.concurrency import get_max_memory_mb from opendm.cutline import compute_cutline from opendm.utils import double_quote @@ -114,6 +115,7 @@ class ODMOrthoPhotoStage(types.ODM_Stage): # Cutline computation, before cropping # We want to use the full orthophoto, not the cropped one. + submodel_run = is_submodel(tree.opensfm) if args.orthophoto_cutline: cutline_file = os.path.join(tree.odm_orthophoto, "cutline.gpkg") @@ -122,15 +124,18 @@ class ODMOrthoPhotoStage(types.ODM_Stage): cutline_file, args.max_concurrency, scale=0.25) - - orthophoto.compute_mask_raster(tree.odm_orthophoto_tif, cutline_file, - os.path.join(tree.odm_orthophoto, "odm_orthophoto_cut.tif"), - blend_distance=20, only_max_coords_feature=True) + + if submodel_run: + orthophoto.compute_mask_raster(tree.odm_orthophoto_tif, cutline_file, + os.path.join(tree.odm_orthophoto, "odm_orthophoto_cut.tif"), + blend_distance=20, only_max_coords_feature=True) + else: + log.ODM_INFO("Not a submodel run, skipping mask raster generation") orthophoto.post_orthophoto_steps(args, bounds_file_path, tree.odm_orthophoto_tif, tree.orthophoto_tiles, resolution) # Generate feathered orthophoto also - if args.orthophoto_cutline: + if args.orthophoto_cutline and submodel_run: orthophoto.feather_raster(tree.odm_orthophoto_tif, os.path.join(tree.odm_orthophoto, "odm_orthophoto_feathered.tif"), blend_distance=20