From 33853337375b22d62c604850a514ed84bb918b19 Mon Sep 17 00:00:00 2001 From: Dakota Benjamin Date: Thu, 6 Apr 2017 15:37:13 -0400 Subject: [PATCH] Expose DEM gen options to command line --- README.md | 8 ++++---- docker.settings.yaml | 4 ++++ opendm/config.py | 22 ++++++++++++++++++++++ opendm/types.py | 29 ++++++++++++++++------------- scripts/odm_app.py | 3 +++ scripts/odm_georeferencing.py | 12 ++++++++++-- settings.yaml | 4 ++++ 7 files changed, 63 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 97a8f845..223ed970 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,16 @@ In a word, OpenDroneMap is a toolchain for processing raw civilian UAS imagery t 2. Digital Surface Models 3. Textured Digital Surface Models 4. Orthorectified Imagery -5. Classified Point Clouds +5. Classified Point Clouds (coming soon) 6. Digital Elevation Models 7. etc. -So far, it does Point Clouds, Digital Surface Models, Textured Digital Surface Models, and Orthorectified Imagery. Open Drone Map now includes state-of-the-art 3D reconstruction work by Michael Waechter, Nils Moehrle, and Michael Goesele. See their publication at http://www.gcc.tu-darmstadt.de/media/gcc/papers/Waechter-2014-LTB.pdf. +Open Drone Map now includes state-of-the-art 3D reconstruction work by Michael Waechter, Nils Moehrle, and Michael Goesele. See their publication at http://www.gcc.tu-darmstadt.de/media/gcc/papers/Waechter-2014-LTB.pdf. ## QUICKSTART -OpenDroneMap can run natively on Ubuntu 14.04 or later, see [Build and Run Using Docker](#build-and-run-using-docker) for running on Windows / MacOS. A Vagrant VM is also available: https://github.com/OpenDroneMap/odm_vagrant. +OpenDroneMap can run natively on Ubuntu 14.04 or later, see [Build and Run Using Docker](#build-and-run-using-docker) for running on Windows / MacOS. A [Vagrant VM](https://github.com/OpenDroneMap/odm_vagrant) is also available. *Support for Ubuntu 12.04 is currently BROKEN with the addition of OpenSfM and Ceres-Solver. It is likely to remain broken unless a champion is found to fix it.* @@ -68,7 +68,7 @@ Note that using `run.sh` sets these temporarily in the shell. First you need a set of images, taken from a drone or otherwise. Example data can be obtained from https://github.com/OpenDroneMap/odm_data -Next, you need to copy over the settings file `default.settings.yaml` and edit it. The only setting you must edit is the `project-path` key. Set this to an empty directory within projects will be saved. There are many options for tuning your project. See the [wiki](https://github.com/OpenDroneMap/OpenDroneMap/wiki/Run-Time-Parameters) or run `python run.py -h` +Next, you need to edit the `settings.yaml` file. The only setting you must edit is the `project-path` key. Set this to an empty directory within projects will be saved. There are many options for tuning your project. See the [wiki](https://github.com/OpenDroneMap/OpenDroneMap/wiki/Run-Time-Parameters) or run `python run.py -h` Then run: diff --git a/docker.settings.yaml b/docker.settings.yaml index dd9dfb4d..8109ea52 100644 --- a/docker.settings.yaml +++ b/docker.settings.yaml @@ -42,6 +42,10 @@ project_path: '/' #DO NOT CHANGE THIS OR DOCKER WILL NOT WORK. It should be '/' #texturing_keep_unseen_faces: False #texturing_tone_mapping: 'none' #gcp: !!null # YAML tag for None +#dem: False +#dem_sample_radius: 1.0 +#dem_resolution: 2 +#dem_radius: 0.5 #use_exif: False # Set to True if you have a GCP file (it auto-detects) and want to use EXIF #orthophoto_resolution: 20.0 # Pixels/meter #orthophoto_target_srs: !!null # Currently does nothing diff --git a/opendm/config.py b/opendm/config.py index 3f2f3c79..ec32116c 100644 --- a/opendm/config.py +++ b/opendm/config.py @@ -320,6 +320,28 @@ def config(): help='Use this tag to build a DEM using a progressive ' 'morphological filter in PDAL.') + parser.add_argument('--dem-sample-radius', + metavar='', + default=1.0, + type=float, + help='Minimum distance between samples for DEM ' + 'generation.\nDefault=%(default)s') + + parser.add_argument('--dem-resolution', + metavar='', + type=float, + default=2, + help='Length of raster cell edges in X/Y units.' + '\nDefault: %(default)s') + + parser.add_argument('--dem-radius', + metavar='', + type=float, + default=0.5, + help='Radius about cell center bounding points to ' + 'use to calculate a cell value.\nDefault: ' + '%(default)s') + parser.add_argument('--orthophoto-resolution', metavar=' 0.0>', default=20.0, diff --git a/opendm/types.py b/opendm/types.py index e44b6a65..c7fd1728 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -194,7 +194,7 @@ class ODM_GeoRef(object): system.run('{bin}/pdal pipeline -i {json} --readers.ply.filename={f_in} ' '--writers.las.filename={f_out}'.format(**kwargs)) - def convert_to_dem(self, _file, _file_out, pdalJSON): + def convert_to_dem(self, _file, _file_out, pdalJSON, sample_radius, gdal_res, gdal_radius): # Check if exists f_in if not io.file_exists(_file): log.ODM_ERROR('LAS file does not exist') @@ -203,29 +203,32 @@ class ODM_GeoRef(object): kwargs = { 'bin': context.pdal_path, 'f_in': _file, - 'f_out': _file_out, # todo: add options + 'sample_radius': sample_radius, + 'gdal_res': gdal_res, + 'gdal_radius': gdal_radius, + 'f_out': _file_out, 'json': pdalJSON } - pipelineJSON = '{' \ + pipelineJSON = '{{' \ ' "pipeline":[' \ ' "input.las",' \ - ' {' \ + ' {{' \ ' "type":"filters.sample",' \ - ' "radius":"0.5"' \ - ' },' \ - ' {' \ + ' "radius":"{sample_radius}"' \ + ' }},' \ + ' {{' \ ' "type":"filters.pmf",' \ ' "extract":"true"' \ - ' },' \ - ' {' \ - ' "resolution": 2,' \ - ' "radius": 5,' \ + ' }},' \ + ' {{' \ + ' "resolution": {gdal_res},' \ + ' "radius": {gdal_radius},' \ ' "output_type":"idw",' \ ' "filename":"outputfile.tif"' \ - ' }' \ + ' }}' \ ' ]' \ - '}' + '}}'.format(**kwargs) with open(pdalJSON, 'w') as f: f.write(pipelineJSON) diff --git a/scripts/odm_app.py b/scripts/odm_app.py index 9fbde973..8d7a2900 100644 --- a/scripts/odm_app.py +++ b/scripts/odm_app.py @@ -72,6 +72,9 @@ class ODMApp(ecto.BlackBox): gcp_file=p.args.gcp, use_exif=p.args.use_exif, dem=p.args.dem, + sample_radius=p.args.dem_sample_radius, + gdal_res=p.args.dem_resolution, + gdal_radius=p.args.dem_radius, verbose=p.args.verbose), 'orthophoto': ODMOrthoPhotoCell(resolution=p.args.orthophoto_resolution, t_srs=p.args.orthophoto_target_srs, diff --git a/scripts/odm_georeferencing.py b/scripts/odm_georeferencing.py index 041887f4..67e69e25 100644 --- a/scripts/odm_georeferencing.py +++ b/scripts/odm_georeferencing.py @@ -18,6 +18,9 @@ class ODMGeoreferencingCell(ecto.Cell): params.declare("img_size", 'image size used in calibration', 2400) params.declare("use_exif", 'use exif', False) params.declare("dem", 'Generate a dem', False) + params.declare("sample_radius", "Minimum distance between samples for DEM gen", 3) + params.declare("gdal_res", "Length of raster cell edges in X/Y units ", 2) + params.declare("gdal_radius", "Radius about cell center bounding points to use to calculate a cell value", 0.5) params.declare("verbose", 'print additional messages to console', False) def declare_io(self, params, inputs, outputs): @@ -153,14 +156,19 @@ class ODMGeoreferencingCell(ecto.Cell): # If --dem, create a DEM if args.dem: - demcreated = geo_ref.convert_to_dem(tree.odm_georeferencing_model_las, tree.odm_georeferencing_dem, tree.odm_georeferencing_dem_json) + demcreated = geo_ref.convert_to_dem(tree.odm_georeferencing_model_las, + tree.odm_georeferencing_dem, + tree.odm_georeferencing_dem_json, + self.params.sample_radius, + self.params.gdal_res, + self.params.gdal_radius) if not demcreated: log.ODM_WARNING('Something went wrong. Check the logs in odm_georeferencing.') else: log.ODM_INFO('DEM created at {0}'.format(tree.odm_georeferencing_dem)) # XYZ point cloud output - log.ODM_INFO("Creating geo-referenced CSV file (XYZ format, can be used with GRASS to create DEM)") + log.ODM_INFO("Creating geo-referenced CSV file (XYZ format)") with open(tree.odm_georeferencing_xyz_file, "wb") as csvfile: csvfile_writer = csv.writer(csvfile, delimiter=",") reachedpoints = False diff --git a/settings.yaml b/settings.yaml index 7768477d..7eac080f 100644 --- a/settings.yaml +++ b/settings.yaml @@ -43,6 +43,10 @@ project_path: '' # Example: '/home/user/ODMProjects #texturing_tone_mapping: 'none' #gcp: !!null # YAML tag for None #use_exif: False # Set to True if you have a GCP file (it auto-detects) and want to use EXIF +#dem: False +#dem_sample_radius: 1.0 +#dem_resolution: 2 +#dem_radius: 0.5 #orthophoto_resolution: 20.0 # Pixels/meter #orthophoto_target_srs: !!null # Currently does nothing #orthophoto_no_tiled: False