Build point cloud

pull/1464/head
Piero Toffanin 2022-05-26 10:53:12 -04:00
rodzic a764b8c64c
commit 07a4c3f61c
2 zmienionych plików z 48 dodań i 4 usunięć

Wyświetl plik

@ -40,15 +40,16 @@ def build(input_point_cloud_files, output_path, max_concurrency=8, rerun=False):
shutil.rmtree(tmpdir)
def build_entwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=8):
def build_entwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=8, reproject=None):
kwargs = {
'threads': max_concurrency,
'tmpdir': tmpdir,
'all_inputs': "-i " + " ".join(map(double_quote, input_point_cloud_files)),
'outputdir': output_path
'outputdir': output_path,
'reproject': (" -r %s " % reproject) if reproject is not None else ""
}
system.run('entwine build --threads {threads} --tmp "{tmpdir}" {all_inputs} -o "{outputdir}"'.format(**kwargs))
system.run('entwine build --threads {threads} --tmp "{tmpdir}" {all_inputs} -o "{outputdir}" {reproject}'.format(**kwargs))
def build_untwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=8, rerun=False):
kwargs = {

Wyświetl plik

@ -7,6 +7,7 @@ from opendm.utils import double_quote
from opendm import io
from opendm import log
from opendm import system
from opendm.entwine import build_entwine
import fiona
from shapely.geometry import shape
@ -68,10 +69,43 @@ def build_textured_model(input_obj, output_path, reference_lla = None, model_bou
except Exception as e:
log.ODM_WARNING("Cannot build 3D tiles textured model: %s" % str(e))
def build_pointcloud(input_pointcloud, output_path, max_concurrency, rerun=False):
if not os.path.isfile(input_pointcloud):
log.ODM_WARNING("No input point cloud file to process")
return
if rerun and io.dir_exists(output_path):
log.ODM_WARNING("Removing previous 3D tiles directory: %s" % output_path)
shutil.rmtree(output_path)
log.ODM_INFO("Generating OGC 3D Tiles point cloud")
try:
if not os.path.isdir(output_path):
os.mkdir(output_path)
tmpdir = os.path.join(output_path, "tmp")
entwine_output = os.path.join(output_path, "entwine")
build_entwine([input_pointcloud], tmpdir, entwine_output, max_concurrency, "EPSG:4978")
kwargs = {
'input': entwine_output,
'output': output_path,
}
system.run('entwine convert -i "{input}" -o "{output}"'.format(**kwargs))
for d in [tmpdir, entwine_output]:
if os.path.isdir(d):
shutil.rmtree(d)
except Exception as e:
log.ODM_WARNING("Cannot build 3D tiles point cloud: %s" % str(e))
def build_3dtiles(args, tree, reconstruction, rerun=False):
tiles_output_path = tree.ogc_tiles
model_output_path = os.path.join(tiles_output_path, "textured_model")
model_output_path = os.path.join(tiles_output_path, "model")
pointcloud_output_path = os.path.join(tiles.output_path, "pointcloud")
if rerun and os.path.exists(tiles_output_path):
shutil.rmtree(tiles_output_path)
@ -79,6 +113,8 @@ def build_3dtiles(args, tree, reconstruction, rerun=False):
if not os.path.isdir(tiles_output_path):
os.mkdir(tiles_output_path)
# Model
if not os.path.isdir(model_output_path) or rerun:
reference_lla = os.path.join(tree.opensfm, "reference_lla.json")
model_bounds_file = os.path.join(tree.odm_georeferencing, 'odm_georeferenced_model.bounds.gpkg')
@ -88,5 +124,12 @@ def build_3dtiles(args, tree, reconstruction, rerun=False):
input_obj = os.path.join(tree.odm_25dtexturing, tree.odm_textured_model_obj)
build_textured_model(input_obj, model_output_path, reference_lla, model_bounds_file, rerun)
else:
log.ODM_WARNING("OGC 3D Tiles model %s already generated" % model_output_path)
# Point cloud
if not os.path.isdir(pointcloud_output_path) or rerun:
build_pointcloud(tree.odm_georeferencing_model_laz, pointcloud_output_path, args.max_concurrency, rerun)
else:
log.ODM_WARNING("OGC 3D Tiles model %s already generated" % model_output_path)