From a56b52d0df56aa73b6da5bc9d0a71bceb8112791 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Fri, 29 Sep 2023 13:54:01 -0400 Subject: [PATCH] Pick green band by default, improve mavic 3M support --- opendm/multispectral.py | 10 ++++++---- opendm/photo.py | 3 +++ opendm/types.py | 14 +++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/opendm/multispectral.py b/opendm/multispectral.py index d08a54a0..3d2373d3 100644 --- a/opendm/multispectral.py +++ b/opendm/multispectral.py @@ -181,11 +181,13 @@ def get_primary_band_name(multi_camera, user_band_name): if len(multi_camera) < 1: raise Exception("Invalid multi_camera list") - # Pick RGB, or Blue if available, otherwise first band + # Pick RGB, or Green, or Blue, in this order, if available, otherwise first band if user_band_name == "auto": - for band in multi_camera: - if band['name'].lower() in ['rgb', 'redgreenblue', 'blue', 'b']: - return band['name'] + for aliases in [['rgb', 'redgreenblue'], ['green', 'g'], ['blue', 'b']]: + for band in multi_camera: + if band['name'].lower() in aliases: + return band['name'] + return multi_camera[0]['name'] for band in multi_camera: diff --git a/opendm/photo.py b/opendm/photo.py index 8bd55b34..a7e638be 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -925,3 +925,6 @@ class ODM_Photo: return self.width * self.height / 1e6 else: return 0.0 + + def is_make_model(self, make, model): + return self.camera_make.lower() == make.lower() and self.camera_model.lower() == model.lower() diff --git a/opendm/types.py b/opendm/types.py index 2df0d11d..64f061a9 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -27,7 +27,7 @@ class ODM_Reconstruction(object): self.gcp = None self.multi_camera = self.detect_multi_camera() self.filter_photos() - + def detect_multi_camera(self): """ Looks at the reconstruction photos and determines if this @@ -90,10 +90,8 @@ class ODM_Reconstruction(object): # Sort mc.sort(key=lambda x: normalized_band_order.get(x['name'].upper(), '9' + band_indexes[x['name']])) - c = 1 - for d in mc: - log.ODM_INFO(f"Band {c}: {d['name']}") - c += 1 + for c, d in enumerate(mc): + log.ODM_INFO(f"Band {c + 1}: {d['name']}") return mc @@ -116,6 +114,12 @@ class ODM_Reconstruction(object): if 'rgb' in bands or 'redgreenblue' in bands: if 'red' in bands and 'green' in bands and 'blue' in bands: bands_to_remove.append(bands['rgb'] if 'rgb' in bands else bands['redgreenblue']) + + # Mavic 3M's RGB camera lens are too different than the multispectral ones + # so we drop the RGB channel instead + elif self.photos[0].is_make_model("DJI", "M3M") and 'red' in bands and 'green' in bands: + bands_to_remove.append(bands['rgb'] if 'rgb' in bands else bands['redgreenblue']) + else: for b in ['red', 'green', 'blue']: if b in bands: