kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge pull request #1155 from pierotofy/multid2m
Add support for maxConcurrency in dem2mesh
Former-commit-id: e0a3384d28
pull/1161/head
commit
0ab5d1cb67
|
@ -36,7 +36,7 @@ def create_25dmesh(inPointCloud, outMesh, dsm_radius=0.07, dsm_resolution=0.05,
|
||||||
)
|
)
|
||||||
|
|
||||||
if method == 'gridded':
|
if method == 'gridded':
|
||||||
mesh = dem_to_mesh_gridded(os.path.join(tmp_directory, 'mesh_dsm.tif'), outMesh, maxVertexCount, verbose)
|
mesh = dem_to_mesh_gridded(os.path.join(tmp_directory, 'mesh_dsm.tif'), outMesh, maxVertexCount, verbose, maxConcurrency=max(1, available_cores))
|
||||||
elif method == 'poisson':
|
elif method == 'poisson':
|
||||||
dsm_points = dem_to_points(os.path.join(tmp_directory, 'mesh_dsm.tif'), os.path.join(tmp_directory, 'dsm_points.ply'), verbose)
|
dsm_points = dem_to_points(os.path.join(tmp_directory, 'mesh_dsm.tif'), os.path.join(tmp_directory, 'dsm_points.ply'), verbose)
|
||||||
mesh = screened_poisson_reconstruction(dsm_points, outMesh, depth=depth,
|
mesh = screened_poisson_reconstruction(dsm_points, outMesh, depth=depth,
|
||||||
|
@ -74,7 +74,7 @@ def dem_to_points(inGeotiff, outPointCloud, verbose=False):
|
||||||
return outPointCloud
|
return outPointCloud
|
||||||
|
|
||||||
|
|
||||||
def dem_to_mesh_gridded(inGeotiff, outMesh, maxVertexCount, verbose=False):
|
def dem_to_mesh_gridded(inGeotiff, outMesh, maxVertexCount, verbose=False, maxConcurrency=1):
|
||||||
log.ODM_INFO('Creating mesh from DSM: %s' % inGeotiff)
|
log.ODM_INFO('Creating mesh from DSM: %s' % inGeotiff)
|
||||||
|
|
||||||
mesh_path, mesh_filename = os.path.split(outMesh)
|
mesh_path, mesh_filename = os.path.split(outMesh)
|
||||||
|
@ -87,19 +87,32 @@ def dem_to_mesh_gridded(inGeotiff, outMesh, maxVertexCount, verbose=False):
|
||||||
|
|
||||||
outMeshDirty = os.path.join(mesh_path, "{}.dirty{}".format(basename, ext))
|
outMeshDirty = os.path.join(mesh_path, "{}.dirty{}".format(basename, ext))
|
||||||
|
|
||||||
kwargs = {
|
# This should work without issues most of the times,
|
||||||
'bin': context.dem2mesh_path,
|
# but just in case we lower maxConcurrency if it fails.
|
||||||
'outfile': outMeshDirty,
|
while True:
|
||||||
'infile': inGeotiff,
|
try:
|
||||||
'maxVertexCount': maxVertexCount,
|
kwargs = {
|
||||||
'verbose': '-verbose' if verbose else ''
|
'bin': context.dem2mesh_path,
|
||||||
}
|
'outfile': outMeshDirty,
|
||||||
|
'infile': inGeotiff,
|
||||||
|
'maxVertexCount': maxVertexCount,
|
||||||
|
'maxConcurrency': maxConcurrency,
|
||||||
|
'verbose': '-verbose' if verbose else ''
|
||||||
|
}
|
||||||
|
system.run('{bin} -inputFile {infile} '
|
||||||
|
'-outputFile {outfile} '
|
||||||
|
'-maxTileLength 2000 '
|
||||||
|
'-maxVertexCount {maxVertexCount} '
|
||||||
|
'-maxConcurrency {maxConcurrency} '
|
||||||
|
' {verbose} '.format(**kwargs))
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
maxConcurrency = math.floor(maxConcurrency / 2)
|
||||||
|
if maxConcurrency >= 1:
|
||||||
|
log.ODM_WARNING("dem2mesh failed, retrying with lower concurrency (%s) in case this is a memory issue" % maxConcurrency)
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
system.run('{bin} -inputFile {infile} '
|
|
||||||
'-outputFile {outfile} '
|
|
||||||
'-maxTileLength 4000 '
|
|
||||||
'-maxVertexCount {maxVertexCount} '
|
|
||||||
' {verbose} '.format(**kwargs))
|
|
||||||
|
|
||||||
# Cleanup and reduce vertex count if necessary
|
# Cleanup and reduce vertex count if necessary
|
||||||
# (as dem2mesh cannot guarantee that we'll have the target vertex count)
|
# (as dem2mesh cannot guarantee that we'll have the target vertex count)
|
||||||
|
|
Ładowanie…
Reference in New Issue