diff --git a/.github/workflows/publish-snap.yml b/.github/workflows/publish-snap.yml index d8e17c52..6cc29a5f 100644 --- a/.github/workflows/publish-snap.yml +++ b/.github/workflows/publish-snap.yml @@ -21,7 +21,6 @@ jobs: id: build uses: diddlesnaps/snapcraft-multiarch-action@v1 with: - snapcraft-args: --enable-experimental-package-repositories architecture: ${{ matrix.architecture }} - name: Review uses: diddlesnaps/snapcraft-review-tools-action@v1 diff --git a/.github/workflows/test-build-prs.yaml b/.github/workflows/test-build-prs.yaml index 66b95f80..fbf42ed3 100644 --- a/.github/workflows/test-build-prs.yaml +++ b/.github/workflows/test-build-prs.yaml @@ -33,7 +33,6 @@ jobs: id: build uses: diddlesnaps/snapcraft-multiarch-action@v1 with: - snapcraft-args: --enable-experimental-package-repositories architecture: ${{ matrix.architecture }} - name: Review uses: diddlesnaps/snapcraft-review-tools-action@v1 diff --git a/VERSION b/VERSION index 73462a5a..f225a78a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.1 +2.5.2 diff --git a/opendm/config.py b/opendm/config.py index 0569fb45..30f6b01b 100755 --- a/opendm/config.py +++ b/opendm/config.py @@ -587,6 +587,11 @@ def config(argv=None, parser=None): default=False, help='Print additional messages to the console. ' 'Default: %(default)s') + + parser.add_argument('--copy-to', + metavar='', + action=StoreValue, + help='Copy output results to this folder after processing.') parser.add_argument('--time', action=StoreTrue, diff --git a/opendm/osfm.py b/opendm/osfm.py index f85569a9..f293fa48 100644 --- a/opendm/osfm.py +++ b/opendm/osfm.py @@ -451,7 +451,7 @@ def get_submodel_argv(args, submodels_path = None, submodel_name = None): reading the contents of --cameras """ assure_always = ['orthophoto_cutline', 'dem_euclidean_map', 'skip_3dmodel', 'skip_report'] - remove_always = ['split', 'split_overlap', 'rerun_from', 'rerun', 'gcp', 'end_with', 'sm_cluster', 'rerun_all', 'pc_csv', 'pc_las', 'pc_ept', 'tiles'] + remove_always = ['split', 'split_overlap', 'rerun_from', 'rerun', 'gcp', 'end_with', 'sm_cluster', 'rerun_all', 'pc_csv', 'pc_las', 'pc_ept', 'tiles', 'copy-to'] read_json_always = ['cameras'] argv = sys.argv diff --git a/opendm/utils.py b/opendm/utils.py index 16c90363..66378ae4 100644 --- a/opendm/utils.py +++ b/opendm/utils.py @@ -1,3 +1,4 @@ +import os, shutil from opendm import log from opendm.photo import find_largest_photo_dim from osgeo import gdal @@ -51,4 +52,44 @@ def double_quote(s): # use double quotes, and prefix double quotes with a \ # the string $"b is then quoted as "$\"b" - return '"' + s.replace('"', '\\\"') + '"' \ No newline at end of file + return '"' + s.replace('"', '\\\"') + '"' + +def get_processing_results_paths(): + return [ + "odm_georeferencing", + "odm_orthophoto", + "odm_dem", + "odm_report", + "odm_texturing", + "entwine_pointcloud", + "dsm_tiles", + "dtm_tiles", + "orthophoto_tiles", + "images.json", + "cameras.json", + ] + +def copy_paths(paths, destination, rerun): + if not os.path.isdir(destination): + os.makedirs(destination) + + for p in paths: + basename = os.path.basename(p) + dst_path = os.path.join(destination, basename) + + if rerun: + try: + if os.path.isfile(dst_path) or os.path.islink(dst_path): + os.remove(dst_path) + elif os.path.isdir(dst_path): + shutil.rmtree(dst_path) + except Exception as e: + log.ODM_WARNING("Cannot remove file %s: %s, skipping..." % (dst_path, str(e))) + + if not os.path.exists(dst_path): + if os.path.isfile(p): + log.ODM_INFO("Copying %s --> %s" % (p, dst_path)) + shutil.copy(p, dst_path) + elif os.path.isdir(p): + shutil.copytree(p, dst_path) + log.ODM_INFO("Copying %s --> %s" % (p, dst_path)) diff --git a/run.py b/run.py index d140adf4..5e2d17ac 100755 --- a/run.py +++ b/run.py @@ -11,7 +11,7 @@ from opendm import config from opendm import system from opendm import io from opendm.progress import progressbc -from opendm.utils import double_quote +from opendm.utils import double_quote, get_processing_results_paths import os @@ -49,18 +49,11 @@ if __name__ == '__main__': if args.rerun_all: log.ODM_INFO("Rerun all -- Removing old data") os.system("rm -rf " + - " ".join([ - double_quote(os.path.join(args.project_path, "odm_georeferencing")), + " ".join([double_quote(os.path.join(args.project_path, p)) for p in get_processing_results_paths()] + [ double_quote(os.path.join(args.project_path, "odm_meshing")), - double_quote(os.path.join(args.project_path, "odm_orthophoto")), - double_quote(os.path.join(args.project_path, "odm_dem")), - double_quote(os.path.join(args.project_path, "odm_report")), - double_quote(os.path.join(args.project_path, "odm_texturing")), double_quote(os.path.join(args.project_path, "opensfm")), - double_quote(os.path.join(args.project_path, "odm_filterpoints")), double_quote(os.path.join(args.project_path, "odm_texturing_25d")), - double_quote(os.path.join(args.project_path, "openmvs")), - double_quote(os.path.join(args.project_path, "entwine_pointcloud")), + double_quote(os.path.join(args.project_path, "odm_filterpoints")), double_quote(os.path.join(args.project_path, "submodels")), ])) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 16841e33..93b9e42f 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -23,8 +23,6 @@ architectures: - build-on: amd64 run-on: amd64 -# Requires snapcraft to be called with --enable-experimental-package-repositories -# until the feature is released package-repositories: - type: apt ppa: ubuntugis/ubuntugis-unstable diff --git a/stages/odm_report.py b/stages/odm_report.py index a50c2629..9e07c4f1 100644 --- a/stages/odm_report.py +++ b/stages/odm_report.py @@ -14,7 +14,7 @@ from opendm.point_cloud import export_info_json from opendm.cropper import Cropper from opendm.orthophoto import get_orthophoto_vars, get_max_memory, generate_png from opendm.tiles.tiler import generate_colored_hillshade -from opendm.utils import get_raster_stats +from opendm.utils import get_raster_stats, copy_paths, get_processing_results_paths def hms(seconds): h = seconds // 3600 @@ -195,4 +195,11 @@ class ODMReport(types.ODM_Stage): else: log.ODM_WARNING("Cannot generate overlap diagram, point cloud stats missing") - octx.export_report(os.path.join(tree.odm_report, "report.pdf"), odm_stats, self.rerun()) \ No newline at end of file + octx.export_report(os.path.join(tree.odm_report, "report.pdf"), odm_stats, self.rerun()) + + # TODO: does this warrant a new stage? + if args.copy_to: + try: + copy_paths([os.path.join(args.project_path, p) for p in get_processing_results_paths()], args.copy_to, self.rerun()) + except Exception as e: + log.ODM_WARNING("Cannot copy to %s: %s" % (args.copy_to, str(e)))