kopia lustrzana https://github.com/OpenDroneMap/ODM
Use max_concurrency option for dem, georef, and ortho modules
rodzic
4262c64840
commit
37504a2a6c
|
@ -72,13 +72,15 @@ class ODMApp(ecto.BlackBox):
|
||||||
'georeferencing': ODMGeoreferencingCell(gcp_file=p.args.gcp,
|
'georeferencing': ODMGeoreferencingCell(gcp_file=p.args.gcp,
|
||||||
use_exif=p.args.use_exif,
|
use_exif=p.args.use_exif,
|
||||||
verbose=p.args.verbose),
|
verbose=p.args.verbose),
|
||||||
'dem': ODMDEMCell(verbose=p.args.verbose),
|
'dem': ODMDEMCell(max_concurrency=p.args.max_concurrency,
|
||||||
|
verbose=p.args.verbose),
|
||||||
'orthophoto': ODMOrthoPhotoCell(resolution=p.args.orthophoto_resolution,
|
'orthophoto': ODMOrthoPhotoCell(resolution=p.args.orthophoto_resolution,
|
||||||
t_srs=p.args.orthophoto_target_srs,
|
t_srs=p.args.orthophoto_target_srs,
|
||||||
no_tiled=p.args.orthophoto_no_tiled,
|
no_tiled=p.args.orthophoto_no_tiled,
|
||||||
compress=p.args.orthophoto_compression,
|
compress=p.args.orthophoto_compression,
|
||||||
bigtiff=p.args.orthophoto_bigtiff,
|
bigtiff=p.args.orthophoto_bigtiff,
|
||||||
build_overviews=p.args.build_overviews,
|
build_overviews=p.args.build_overviews,
|
||||||
|
max_concurrency=p.args.max_concurrency,
|
||||||
verbose=p.args.verbose)
|
verbose=p.args.verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ from opendm.cropper import Cropper
|
||||||
class ODMDEMCell(ecto.Cell):
|
class ODMDEMCell(ecto.Cell):
|
||||||
def declare_params(self, params):
|
def declare_params(self, params):
|
||||||
params.declare("verbose", 'print additional messages to console', False)
|
params.declare("verbose", 'print additional messages to console', False)
|
||||||
|
params.declare("max_concurrency", "Number of threads", context.num_cores)
|
||||||
|
|
||||||
def declare_io(self, params, inputs, outputs):
|
def declare_io(self, params, inputs, outputs):
|
||||||
inputs.declare("tree", "Struct with paths", [])
|
inputs.declare("tree", "Struct with paths", [])
|
||||||
|
@ -44,12 +45,12 @@ class ODMDEMCell(ecto.Cell):
|
||||||
|
|
||||||
# Setup terrain parameters
|
# Setup terrain parameters
|
||||||
terrain_params_map = {
|
terrain_params_map = {
|
||||||
'flatnonforest': (1, 3),
|
'flatnonforest': (1, 3),
|
||||||
'flatforest': (1, 2),
|
'flatforest': (1, 2),
|
||||||
'complexnonforest': (5, 2),
|
'complexnonforest': (5, 2),
|
||||||
'complexforest': (10, 2)
|
'complexforest': (10, 2)
|
||||||
}
|
}
|
||||||
terrain_params = terrain_params_map[args.dem_terrain_type.lower()]
|
terrain_params = terrain_params_map[args.dem_terrain_type.lower()]
|
||||||
slope, cellsize = terrain_params
|
slope, cellsize = terrain_params
|
||||||
|
|
||||||
# define paths and create working directories
|
# define paths and create working directories
|
||||||
|
@ -62,7 +63,7 @@ class ODMDEMCell(ecto.Cell):
|
||||||
|
|
||||||
if not io.file_exists(pc_classify_marker) or rerun_cell:
|
if not io.file_exists(pc_classify_marker) or rerun_cell:
|
||||||
log.ODM_INFO("Classifying {} using {}".format(tree.odm_georeferencing_model_laz, args.pc_classify))
|
log.ODM_INFO("Classifying {} using {}".format(tree.odm_georeferencing_model_laz, args.pc_classify))
|
||||||
commands.classify(tree.odm_georeferencing_model_laz,
|
commands.classify(tree.odm_georeferencing_model_laz,
|
||||||
args.pc_classify == "smrf",
|
args.pc_classify == "smrf",
|
||||||
slope,
|
slope,
|
||||||
cellsize,
|
cellsize,
|
||||||
|
@ -70,7 +71,7 @@ class ODMDEMCell(ecto.Cell):
|
||||||
initialDistance=args.dem_initial_distance,
|
initialDistance=args.dem_initial_distance,
|
||||||
verbose=args.verbose
|
verbose=args.verbose
|
||||||
)
|
)
|
||||||
with open(pc_classify_marker, 'w') as f:
|
with open(pc_classify_marker, 'w') as f:
|
||||||
f.write('Classify: {}\n'.format(args.pc_classify))
|
f.write('Classify: {}\n'.format(args.pc_classify))
|
||||||
f.write('Slope: {}\n'.format(slope))
|
f.write('Slope: {}\n'.format(slope))
|
||||||
f.write('Cellsize: {}\n'.format(cellsize))
|
f.write('Cellsize: {}\n'.format(cellsize))
|
||||||
|
@ -87,7 +88,7 @@ class ODMDEMCell(ecto.Cell):
|
||||||
rerun_cell:
|
rerun_cell:
|
||||||
|
|
||||||
products = []
|
products = []
|
||||||
if args.dsm: products.append('dsm')
|
if args.dsm: products.append('dsm')
|
||||||
if args.dtm: products.append('dtm')
|
if args.dtm: products.append('dtm')
|
||||||
|
|
||||||
radius_steps = [args.dem_resolution]
|
radius_steps = [args.dem_resolution]
|
||||||
|
@ -96,7 +97,7 @@ class ODMDEMCell(ecto.Cell):
|
||||||
|
|
||||||
for product in products:
|
for product in products:
|
||||||
commands.create_dems(
|
commands.create_dems(
|
||||||
[tree.odm_georeferencing_model_laz],
|
[tree.odm_georeferencing_model_laz],
|
||||||
product,
|
product,
|
||||||
radius=map(str, radius_steps),
|
radius=map(str, radius_steps),
|
||||||
gapfill=True,
|
gapfill=True,
|
||||||
|
@ -116,7 +117,7 @@ class ODMDEMCell(ecto.Cell):
|
||||||
'COMPRESS': 'LZW',
|
'COMPRESS': 'LZW',
|
||||||
'BLOCKXSIZE': 512,
|
'BLOCKXSIZE': 512,
|
||||||
'BLOCKYSIZE': 512,
|
'BLOCKYSIZE': 512,
|
||||||
'NUM_THREADS': 'ALL_CPUS'
|
'NUM_THREADS': self.params.max_concurrency
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.ODM_WARNING('Found existing outputs in: %s' % odm_dem_root)
|
log.ODM_WARNING('Found existing outputs in: %s' % odm_dem_root)
|
||||||
|
|
|
@ -18,6 +18,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
||||||
params.declare("bigtiff", 'Make BigTIFF orthophoto', 'IF_SAFER')
|
params.declare("bigtiff", 'Make BigTIFF orthophoto', 'IF_SAFER')
|
||||||
params.declare("build_overviews", 'Build overviews', False)
|
params.declare("build_overviews", 'Build overviews', False)
|
||||||
params.declare("verbose", 'print additional messages to console', False)
|
params.declare("verbose", 'print additional messages to console', False)
|
||||||
|
params.declare("max_concurrency", "number of threads", context.num_cores)
|
||||||
|
|
||||||
def declare_io(self, params, inputs, outputs):
|
def declare_io(self, params, inputs, outputs):
|
||||||
inputs.declare("tree", "Struct with paths", [])
|
inputs.declare("tree", "Struct with paths", [])
|
||||||
|
@ -125,7 +126,8 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
||||||
'png': tree.odm_orthophoto_file,
|
'png': tree.odm_orthophoto_file,
|
||||||
'tiff': tree.odm_orthophoto_tif,
|
'tiff': tree.odm_orthophoto_tif,
|
||||||
'log': tree.odm_orthophoto_tif_log,
|
'log': tree.odm_orthophoto_tif_log,
|
||||||
'max_memory': max(5, (100 - virtual_memory().percent) / 2)
|
'max_memory': max(5, (100 - virtual_memory().percent) / 2),
|
||||||
|
'threads': self.params.max_concurrency
|
||||||
}
|
}
|
||||||
|
|
||||||
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
|
||||||
|
@ -135,7 +137,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
||||||
'{predictor} '
|
'{predictor} '
|
||||||
'-co BLOCKXSIZE=512 '
|
'-co BLOCKXSIZE=512 '
|
||||||
'-co BLOCKYSIZE=512 '
|
'-co BLOCKYSIZE=512 '
|
||||||
'-co NUM_THREADS=ALL_CPUS '
|
'-co NUM_THREADS={threads} '
|
||||||
'-a_srs \"{proj}\" '
|
'-a_srs \"{proj}\" '
|
||||||
'--config GDAL_CACHEMAX {max_memory}% '
|
'--config GDAL_CACHEMAX {max_memory}% '
|
||||||
'{png} {tiff} > {log}'.format(**kwargs))
|
'{png} {tiff} > {log}'.format(**kwargs))
|
||||||
|
@ -149,7 +151,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
|
||||||
'BIGTIFF': self.params.bigtiff,
|
'BIGTIFF': self.params.bigtiff,
|
||||||
'BLOCKXSIZE': 512,
|
'BLOCKXSIZE': 512,
|
||||||
'BLOCKYSIZE': 512,
|
'BLOCKYSIZE': 512,
|
||||||
'NUM_THREADS': 'ALL_CPUS'
|
'NUM_THREADS': self.params.max_concurrency
|
||||||
})
|
})
|
||||||
|
|
||||||
if self.params.build_overviews:
|
if self.params.build_overviews:
|
||||||
|
|
Ładowanie…
Reference in New Issue