Sam 2025-10-07 12:25:09 +00:00 zatwierdzone przez GitHub
commit eb000b9df4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
4 zmienionych plików z 24 dodań i 3 usunięć

Wyświetl plik

@ -116,7 +116,7 @@ if len(all_orthos_and_ortho_cuts) > 1:
'BIGTIFF': 'IF_SAFER',
'BLOCKXSIZE': 512,
'BLOCKYSIZE': 512
})
}, args.merge_skip_blending)
log.ODM_INFO("Wrote %s" % output_file)

Wyświetl plik

@ -828,6 +828,18 @@ def config(argv=None, parser=None):
'Options: %(choices)s. Default: '
'%(default)s'))
# TODO ideally the blending should be optimised so we don't need this param to skip it, e.g.
# 1. Only blend in a buffer zone around cutline edges (e.g., 100-200 pixels)
# 2. Skip blending for interior regions that are far from edges
# 3. This would require detecting which blocks intersect cutline boundaries
# We have block-based processing already in place in orthophoto.py, so need logic to determine
# if a block needs blending based on its proximity to cutlines
parser.add_argument('--merge-skip-blending',
action=StoreTrue,
nargs=0,
default=False,
help='During the orthophoto merging, skip expensive blending operation: %(default)s')
parser.add_argument('--force-gps',
action=StoreTrue,
nargs=0,

Wyświetl plik

@ -263,7 +263,7 @@ def feather_raster(input_raster, output_raster, blend_distance=20):
return output_raster
def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}, merge_skip_blending=False):
"""
Based on https://github.com/mapbox/rio-merge-rgba/
Merge orthophotos around cutlines using a blend buffer.
@ -332,6 +332,10 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
profile["bigtiff"] = orthophoto_vars.get('BIGTIFF', 'IF_SAFER')
profile.update()
# Log here to avoid logging in each block processed
if merge_skip_blending:
log.ODM_INFO("Skipping second and third pass orthophoto blending, as --merge-skip-blending passed")
# create destination file
with rasterio.open(output_orthophoto, "w", **profile) as dstrast:
dstrast.colorinterp = colorinterp
@ -370,6 +374,11 @@ def merge(input_ortho_and_ortho_cuts, output_orthophoto, orthophoto_vars={}):
if np.count_nonzero(dstarr[-1]) == blocksize:
break
# Skip expensive blending operations if flag passed
if merge_skip_blending:
dstrast.write(dstarr, window=dst_window)
continue
# Second pass, write all feathered rasters
# blending the edges
for src, _ in sources:

Wyświetl plik

@ -262,7 +262,7 @@ class ODMMergeStage(types.ODM_Stage):
os.remove(tree.odm_orthophoto_tif)
orthophoto_vars = orthophoto.get_orthophoto_vars(args)
orthophoto.merge(all_orthos_and_ortho_cuts, tree.odm_orthophoto_tif, orthophoto_vars)
orthophoto.merge(all_orthos_and_ortho_cuts, tree.odm_orthophoto_tif, orthophoto_vars, args.merge_skip_blending)
orthophoto.post_orthophoto_steps(args, merged_bounds_file, tree.odm_orthophoto_tif, tree.orthophoto_tiles, args.orthophoto_resolution,
reconstruction, tree, False)
elif len(all_orthos_and_ortho_cuts) == 1: