Skip feathered raster generation when possible

pull/1760/head
Piero Toffanin 2024-05-17 14:55:26 -04:00
rodzic f9136f7a0d
commit e4e27c21f2
3 zmienionych plików z 17 dodań i 6 usunięć

Wyświetl plik

@ -1 +1 @@
3.5.0
3.5.1

Wyświetl plik

@ -793,3 +793,9 @@ 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
return os.path.islink(os.path.join(opensfm_root, "exif")) 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"))

Wyświetl plik

@ -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