Skip to content

Commit ae6726e

Browse files
authored
Merge pull request #1760 from pierotofy/fastcut
Skip feathered raster generation when possible
2 parents f9136f7 + 6da366f commit ae6726e

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.5.0
1+
3.5.1

opendm/osfm.py

+9
Original file line numberDiff line numberDiff line change
@@ -793,3 +793,12 @@ def get_all_submodel_paths(submodels_path, *all_paths):
793793
result.append([os.path.join(submodels_path, f, ap) for ap in all_paths])
794794

795795
return result
796+
797+
def is_submodel(opensfm_root):
798+
# A bit hackish, but works without introducing additional markers / flags
799+
# Look at the path of the opensfm directory and see if "submodel_" is part of it
800+
parts = os.path.abspath(opensfm_root).split(os.path.sep)
801+
802+
return (len(parts) >= 2 and parts[-2][:9] == "submodel_") or \
803+
os.path.isfile(os.path.join(opensfm_root, "split_merge_stop_at_reconstruction.txt")) or \
804+
os.path.isfile(os.path.join(opensfm_root, "features", "empty"))

stages/odm_orthophoto.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from opendm import types
88
from opendm import gsd
99
from opendm import orthophoto
10+
from opendm.osfm import is_submodel
1011
from opendm.concurrency import get_max_memory_mb
1112
from opendm.cutline import compute_cutline
1213
from opendm.utils import double_quote
@@ -114,6 +115,7 @@ def process(self, args, outputs):
114115

115116
# Cutline computation, before cropping
116117
# We want to use the full orthophoto, not the cropped one.
118+
submodel_run = is_submodel(tree.opensfm)
117119
if args.orthophoto_cutline:
118120
cutline_file = os.path.join(tree.odm_orthophoto, "cutline.gpkg")
119121

@@ -122,15 +124,18 @@ def process(self, args, outputs):
122124
cutline_file,
123125
args.max_concurrency,
124126
scale=0.25)
125-
126-
orthophoto.compute_mask_raster(tree.odm_orthophoto_tif, cutline_file,
127-
os.path.join(tree.odm_orthophoto, "odm_orthophoto_cut.tif"),
128-
blend_distance=20, only_max_coords_feature=True)
127+
128+
if submodel_run:
129+
orthophoto.compute_mask_raster(tree.odm_orthophoto_tif, cutline_file,
130+
os.path.join(tree.odm_orthophoto, "odm_orthophoto_cut.tif"),
131+
blend_distance=20, only_max_coords_feature=True)
132+
else:
133+
log.ODM_INFO("Not a submodel run, skipping mask raster generation")
129134

130135
orthophoto.post_orthophoto_steps(args, bounds_file_path, tree.odm_orthophoto_tif, tree.orthophoto_tiles, resolution)
131136

132137
# Generate feathered orthophoto also
133-
if args.orthophoto_cutline:
138+
if args.orthophoto_cutline and submodel_run:
134139
orthophoto.feather_raster(tree.odm_orthophoto_tif,
135140
os.path.join(tree.odm_orthophoto, "odm_orthophoto_feathered.tif"),
136141
blend_distance=20

0 commit comments

Comments
 (0)