From 6e23de03a0abf0a5edbbda65497898105fc7edfc Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sun, 10 Jul 2022 12:21:31 -0400 Subject: [PATCH 1/3] Bug fixes, more memory efficient DEM smoothing --- opendm/boundary.py | 2 +- opendm/dem/commands.py | 2 +- stages/odm_filterpoints.py | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/opendm/boundary.py b/opendm/boundary.py index 55dc81b3..86ea5ae2 100644 --- a/opendm/boundary.py +++ b/opendm/boundary.py @@ -22,7 +22,7 @@ def compute_boundary_from_shots(reconstruction_json, buffer=0, reconstruction_of for shot_image in reconstruction['shots']: shot = reconstruction['shots'][shot_image] - if shot['gps_dop'] < 999999: + if shot.get('gps_dop', 999999) < 999999: camera = reconstruction['cameras'][shot['camera']] p = ogr.Geometry(ogr.wkbPoint) diff --git a/opendm/dem/commands.py b/opendm/dem/commands.py index aedf80cc..aa096e8b 100755 --- a/opendm/dem/commands.py +++ b/opendm/dem/commands.py @@ -333,7 +333,7 @@ def median_smoothing(geotiff_path, output_path, smoothing_iterations=1): dtype = img.dtypes[0] arr = img.read()[0] - nodata_locs = numpy.where(arr == nodata) + nodata_locs = arr == nodata # Median filter (careful, changing the value 5 might require tweaking) # the lines below. There's another numpy function that takes care of diff --git a/stages/odm_filterpoints.py b/stages/odm_filterpoints.py index 75b4a0ad..416007ad 100644 --- a/stages/odm_filterpoints.py +++ b/stages/odm_filterpoints.py @@ -28,9 +28,12 @@ class ODMFilterPoints(types.ODM_Stage): if reconstruction.is_georeferenced(): if not 'boundary' in outputs: avg_gsd = gsd.opensfm_reconstruction_average_gsd(tree.opensfm_reconstruction) - outputs['boundary'] = compute_boundary_from_shots(tree.opensfm_reconstruction, avg_gsd * 20, reconstruction.get_proj_offset()) # 20 is arbitrary - if outputs['boundary'] is None: - log.ODM_WARNING("Cannot compute boundary from camera shots") + if avg_gsd is not None: + outputs['boundary'] = compute_boundary_from_shots(tree.opensfm_reconstruction, avg_gsd * 20, reconstruction.get_proj_offset()) # 20 is arbitrary + if outputs['boundary'] is None: + log.ODM_WANING("Cannot compute boundary from camera shots") + else: + log.ODM_WARNING("Cannot compute boundary (GSD cannot be estimated)") else: log.ODM_WARNING("--auto-boundary set but so is --boundary, will use --boundary") else: From b7ae59b429dea8d60d3265406e52a143555004ed Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sun, 10 Jul 2022 12:40:33 -0400 Subject: [PATCH 2/3] Update ExifRead, speed camelCase --> snake_case, fix var used before assignment --- opendm/photo.py | 26 +++++++++++++------------- requirements.txt | 2 +- stages/odm_filterpoints.py | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/opendm/photo.py b/opendm/photo.py index 3f8d31e2..e93b17b8 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -142,9 +142,9 @@ class ODM_Photo: self.dls_roll = None # Aircraft speed - self.speedX = None - self.speedY = None - self.speedZ = None + self.speed_x = None + self.speed_y = None + self.speed_z = None # self.center_wavelength = None # self.bandwidth = None @@ -277,9 +277,9 @@ class ODM_Photo: if 'MakerNote SpeedX' in tags and \ 'MakerNote SpeedY' in tags and \ 'MakerNote SpeedZ' in tags: - self.speedX = self.float_value(tags['MakerNote SpeedX']) - self.speedY = self.float_value(tags['MakerNote SpeedY']) - self.speedZ = self.float_value(tags['MakerNote SpeedZ']) + self.speed_x = self.float_value(tags['MakerNote SpeedX']) + self.speed_y = self.float_value(tags['MakerNote SpeedY']) + self.speed_z = self.float_value(tags['MakerNote SpeedZ']) except Exception as e: log.ODM_WARNING("Cannot read extended EXIF tags for %s: %s" % (self.filename, str(e))) @@ -386,13 +386,13 @@ class ODM_Photo: if '@drone-dji:FlightXSpeed' in xtags and \ '@drone-dji:FlightYSpeed' in xtags and \ '@drone-dji:FlightZSpeed' in xtags: - self.set_attr_from_xmp_tag('speedX', xtags, [ + self.set_attr_from_xmp_tag('speed_x', xtags, [ '@drone-dji:FlightXSpeed' ], float) - self.set_attr_from_xmp_tag('speedY', xtags, [ + self.set_attr_from_xmp_tag('speed_y', xtags, [ '@drone-dji:FlightYSpeed', ], float) - self.set_attr_from_xmp_tag('speedZ', xtags, [ + self.set_attr_from_xmp_tag('speed_z', xtags, [ '@drone-dji:FlightZSpeed', ], float) @@ -776,7 +776,7 @@ class ODM_Photo: # Speed is not useful without GPS if self.has_speed() and has_gps: - d['speed'] = [self.speedY, self.speedX, self.speedZ] + d['speed'] = [self.speed_y, self.speed_x, self.speed_z] if rolling_shutter: d['rolling_shutter'] = get_rolling_shutter_readout(self.camera_make, self.camera_model, rolling_shutter_readout) @@ -794,9 +794,9 @@ class ODM_Photo: self.kappa is not None def has_speed(self): - return self.speedX is not None and \ - self.speedY is not None and \ - self.speedZ is not None + return self.speed_x is not None and \ + self.speed_y is not None and \ + self.speed_z is not None def has_geo(self): return self.latitude is not None and \ diff --git a/requirements.txt b/requirements.txt index c08df405..474059be 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ attrs==20.3.0 beautifulsoup4==4.9.3 cloudpickle==1.6.0 edt==2.0.2 -ODMExifRead==3.0.3 +ODMExifRead==3.0.4 Fiona==1.8.17 ; sys_platform == 'linux' or sys_platform == 'darwin' https://github.com/OpenDroneMap/windows-deps/raw/main/Fiona-1.8.19-cp38-cp38-win_amd64.whl ; sys_platform == 'win32' joblib==0.17.0 diff --git a/stages/odm_filterpoints.py b/stages/odm_filterpoints.py index 416007ad..47748860 100644 --- a/stages/odm_filterpoints.py +++ b/stages/odm_filterpoints.py @@ -16,6 +16,8 @@ class ODMFilterPoints(types.ODM_Stage): if not os.path.exists(tree.odm_filterpoints): system.mkdir_p(tree.odm_filterpoints) + inputPointCloud = "" + # check if reconstruction was done before if not io.file_exists(tree.filtered_point_cloud) or self.rerun(): if args.fast_orthophoto: From 44d0039de80ed74aeb760df66e2b209e22e4a056 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sun, 10 Jul 2022 12:45:11 -0400 Subject: [PATCH 3/3] Fix None check in GPSAltitudeRef --- opendm/photo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendm/photo.py b/opendm/photo.py index e93b17b8..5451c76d 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -217,7 +217,7 @@ class ODM_Photo: self.camera_model = "unknown" if 'GPS GPSAltitude' in tags: self.altitude = self.float_value(tags['GPS GPSAltitude']) - if 'GPS GPSAltitudeRef' in tags and self.int_value(tags['GPS GPSAltitudeRef']) > 0: + if 'GPS GPSAltitudeRef' in tags and self.int_value(tags['GPS GPSAltitudeRef']) is not None and self.int_value(tags['GPS GPSAltitudeRef']) > 0: self.altitude *= -1 if 'GPS GPSLatitude' in tags and 'GPS GPSLatitudeRef' in tags: self.latitude = self.dms_to_decimal(tags['GPS GPSLatitude'], tags['GPS GPSLatitudeRef'])