From 4db777915f1fad8a949e9538a258cb55bad9864d Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 31 May 2019 11:25:44 -0400 Subject: [PATCH] Added entwine module, add Pillow, opensfm update --- Dockerfile | 3 ++- SuperBuild/cmake/External-Entwine.cmake | 2 +- configure.sh | 3 ++- opendm/entwine.py | 26 +++++++++++++++++++++++++ portable.Dockerfile | 3 ++- stages/splitmerge.py | 7 +++---- 6 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 opendm/entwine.py diff --git a/Dockerfile b/Dockerfile index 40d383f8..e5085b3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,8 @@ RUN pip install -U \ xmltodict \ rasterio \ attrs==19.1.0 \ - pyodm==1.5.1 + pyodm==1.5.1 \ + Pillow RUN pip install --upgrade cryptography && python -m easy_install --upgrade pyOpenSSL diff --git a/SuperBuild/cmake/External-Entwine.cmake b/SuperBuild/cmake/External-Entwine.cmake index c1a27acb..48d24ad3 100644 --- a/SuperBuild/cmake/External-Entwine.cmake +++ b/SuperBuild/cmake/External-Entwine.cmake @@ -8,7 +8,7 @@ ExternalProject_Add(${_proj_name} STAMP_DIR ${_SB_BINARY_DIR}/stamp #--Download step-------------- DOWNLOAD_DIR ${SB_DOWNLOAD_DIR} - URL https://github.com/connormanning/entwine/archive/098c1ee82cf5b08dcd15ce9b6b910a179c85c6fb.zip + URL https://github.com/connormanning/entwine/archive/d0ed334514a00b234a6fd60b97e1b04353b560f0.zip #--Update/Patch step---------- UPDATE_COMMAND "" #--Configure step------------- diff --git a/configure.sh b/configure.sh index cc663cd9..f86fcc8c 100755 --- a/configure.sh +++ b/configure.sh @@ -80,7 +80,8 @@ install() { repoze.lru \ rasterio \ attrs==19.1.0 \ - pyodm==1.5.1 + pyodm==1.5.1 \ + Pillow # Fix: /usr/local/lib/python2.7/dist-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown. pip install --upgrade cryptography diff --git a/opendm/entwine.py b/opendm/entwine.py new file mode 100644 index 00000000..462372d9 --- /dev/null +++ b/opendm/entwine.py @@ -0,0 +1,26 @@ +import os +import shutil +from pipes import quote +from opendm import io +from opendm import log +from opendm import system +from opendm import concurrency + +def build(input_point_cloud_files, output_path, max_concurrency=8): + if len(input_point_cloud_files) == 0: + log.ODM_WARNING("No input point cloud files to process") + return + + tmpdir = io.related_file_path(output_path, postfix="-tmp") + + kwargs = { + 'threads': max_concurrency, + 'tmpdir': tmpdir, + 'input': "-i " + ", -i ".join(map(quote, input_point_cloud_files)), + 'outputdir': output_path + } + + system.run("entwine build --threads {threads} --tmp {tmpdir} {input} -o {outputdir}".format(**kwargs)) + + if os.path.exists(tmpdir): + shutil.rmtree(tmpdir) \ No newline at end of file diff --git a/portable.Dockerfile b/portable.Dockerfile index e8d33442..65577c07 100644 --- a/portable.Dockerfile +++ b/portable.Dockerfile @@ -76,7 +76,8 @@ RUN pip install -U \ xmltodict \ rasterio \ attrs==19.1.0 \ - pyodm==1.5.1 + pyodm==1.5.1 \ + Pillow RUN pip install --upgrade cryptography && python -m easy_install --upgrade pyOpenSSL diff --git a/stages/splitmerge.py b/stages/splitmerge.py index bac215f5..8fdd0778 100644 --- a/stages/splitmerge.py +++ b/stages/splitmerge.py @@ -13,6 +13,7 @@ from opensfm.large import metadataset from opendm.cropper import Cropper from opendm.concurrency import get_max_memory from opendm.remote import LocalRemoteExecutor +from opendm import entwine from pipes import quote class ODMSplitStage(types.ODM_Stage): @@ -177,10 +178,8 @@ class ODMMergeStage(types.ODM_Stage): all_point_clouds = get_submodel_paths(tree.submodels_path, "odm_georeferencing", "odm_georeferenced_model.laz") try: - # TODO: use entwine to create a tileset instead of - # merging, which is memory inefficient and creates - # monster files. - pdal.merge_point_clouds(all_point_clouds, tree.odm_georeferencing_model_laz, args.verbose) + # pdal.merge_point_clouds(all_point_clouds, tree.odm_georeferencing_model_laz, args.verbose) + entwine.build(all_point_clouds, tree.path("entwine_pointcloud"), max_concurrency=args.max_concurrency) except Exception as e: log.ODM_WARNING("Could not merge point cloud: %s (skipping)" % str(e)) else: