kopia lustrzana https://github.com/OpenDroneMap/ODM
Skip DSM smoothing in 2.5D model with fast-orthophoto
rodzic
2d1c7e8cf9
commit
96d09996e3
|
@ -35,7 +35,8 @@ error = None
|
||||||
|
|
||||||
def create_dem(input_point_cloud, dem_type, output_type='max', radiuses=['0.56'], gapfill=True,
|
def create_dem(input_point_cloud, dem_type, output_type='max', radiuses=['0.56'], gapfill=True,
|
||||||
outdir='', resolution=0.1, max_workers=1, max_tile_size=2048,
|
outdir='', resolution=0.1, max_workers=1, max_tile_size=2048,
|
||||||
verbose=False, decimation=None, keep_unfilled_copy=False):
|
verbose=False, decimation=None, keep_unfilled_copy=False,
|
||||||
|
apply_smoothing=True):
|
||||||
""" Create DEM from multiple radii, and optionally gapfill """
|
""" Create DEM from multiple radii, and optionally gapfill """
|
||||||
global error
|
global error
|
||||||
error = None
|
error = None
|
||||||
|
@ -238,9 +239,12 @@ def create_dem(input_point_cloud, dem_type, output_type='max', radiuses=['0.56']
|
||||||
'-co NUM_THREADS={threads} '
|
'-co NUM_THREADS={threads} '
|
||||||
'--config GDAL_CACHEMAX {max_memory}% '
|
'--config GDAL_CACHEMAX {max_memory}% '
|
||||||
'{tiles_vrt} {geotiff}'.format(**kwargs))
|
'{tiles_vrt} {geotiff}'.format(**kwargs))
|
||||||
|
|
||||||
post_process(geotiff_path, output_path)
|
if apply_smoothing:
|
||||||
os.remove(geotiff_path)
|
median_smoothing(geotiff_path, output_path)
|
||||||
|
os.remove(geotiff_path)
|
||||||
|
else:
|
||||||
|
os.rename(geotiff_path, output_path)
|
||||||
|
|
||||||
if os.path.exists(geotiff_tmp_path):
|
if os.path.exists(geotiff_tmp_path):
|
||||||
if not keep_unfilled_copy:
|
if not keep_unfilled_copy:
|
||||||
|
@ -278,14 +282,14 @@ def compute_euclidean_map(geotiff_path, output_path, overwrite=False):
|
||||||
return output_path
|
return output_path
|
||||||
|
|
||||||
|
|
||||||
def post_process(geotiff_path, output_path, smoothing_iterations=1):
|
def median_smoothing(geotiff_path, output_path, smoothing_iterations=1):
|
||||||
""" Apply median smoothing """
|
""" Apply median smoothing """
|
||||||
start = datetime.now()
|
start = datetime.now()
|
||||||
|
|
||||||
if not os.path.exists(geotiff_path):
|
if not os.path.exists(geotiff_path):
|
||||||
raise Exception('File %s does not exist!' % geotiff_path)
|
raise Exception('File %s does not exist!' % geotiff_path)
|
||||||
|
|
||||||
log.ODM_INFO('Starting post processing (smoothing)...')
|
log.ODM_INFO('Starting smoothing...')
|
||||||
|
|
||||||
with rasterio.open(geotiff_path) as img:
|
with rasterio.open(geotiff_path) as img:
|
||||||
nodata = img.nodatavals[0]
|
nodata = img.nodatavals[0]
|
||||||
|
@ -324,6 +328,6 @@ def post_process(geotiff_path, output_path, smoothing_iterations=1):
|
||||||
else:
|
else:
|
||||||
imgout.write(arr.astype(dtype), 1)
|
imgout.write(arr.astype(dtype), 1)
|
||||||
|
|
||||||
log.ODM_INFO('Completed post processing to create %s in %s' % (os.path.relpath(output_path), datetime.now() - start))
|
log.ODM_INFO('Completed smoothing to create %s in %s' % (os.path.relpath(output_path), datetime.now() - start))
|
||||||
|
|
||||||
return output_path
|
return output_path
|
|
@ -7,7 +7,7 @@ from opendm import context
|
||||||
from scipy import signal, ndimage
|
from scipy import signal, ndimage
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def create_25dmesh(inPointCloud, outMesh, dsm_radius=0.07, dsm_resolution=0.05, depth=8, samples=1, maxVertexCount=100000, verbose=False, available_cores=None, method='gridded'):
|
def create_25dmesh(inPointCloud, outMesh, dsm_radius=0.07, dsm_resolution=0.05, depth=8, samples=1, maxVertexCount=100000, verbose=False, available_cores=None, method='gridded', smooth_dsm=True):
|
||||||
# Create DSM from point cloud
|
# Create DSM from point cloud
|
||||||
|
|
||||||
# Create temporary directory
|
# Create temporary directory
|
||||||
|
@ -31,7 +31,8 @@ def create_25dmesh(inPointCloud, outMesh, dsm_radius=0.07, dsm_resolution=0.05,
|
||||||
outdir=tmp_directory,
|
outdir=tmp_directory,
|
||||||
resolution=dsm_resolution,
|
resolution=dsm_resolution,
|
||||||
verbose=verbose,
|
verbose=verbose,
|
||||||
max_workers=available_cores
|
max_workers=available_cores,
|
||||||
|
apply_smoothing=smooth_dsm
|
||||||
)
|
)
|
||||||
|
|
||||||
if method == 'gridded':
|
if method == 'gridded':
|
||||||
|
|
|
@ -68,7 +68,8 @@ class ODMeshingStage(types.ODM_Stage):
|
||||||
samples=self.params.get('samples'),
|
samples=self.params.get('samples'),
|
||||||
verbose=self.params.get('verbose'),
|
verbose=self.params.get('verbose'),
|
||||||
available_cores=args.max_concurrency,
|
available_cores=args.max_concurrency,
|
||||||
method='poisson' if args.fast_orthophoto else 'gridded')
|
method='poisson' if args.fast_orthophoto else 'gridded',
|
||||||
|
smooth_dsm=not args.fast_orthophoto)
|
||||||
else:
|
else:
|
||||||
log.ODM_WARNING('Found a valid ODM 2.5D Mesh file in: %s' %
|
log.ODM_WARNING('Found a valid ODM 2.5D Mesh file in: %s' %
|
||||||
tree.odm_25dmesh)
|
tree.odm_25dmesh)
|
||||||
|
|
Ładowanie…
Reference in New Issue