Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix start/end date on Windows and enforce band order normalization #1701

Merged
merged 5 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SuperBuild/cmake/External-OpenSfM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ExternalProject_Add(${_proj_name}
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
GIT_REPOSITORY https://github.com/OpenDroneMap/OpenSfM/
GIT_TAG 319
GIT_TAG 322
#--Update/Patch step----------
UPDATE_COMMAND git submodule update --init --recursive
#--Configure step-------------
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1
3.3.0
7 changes: 6 additions & 1 deletion opendm/multispectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,13 @@ def get_primary_band_name(multi_camera, user_band_name):
if len(multi_camera) < 1:
raise Exception("Invalid multi_camera list")

# multi_camera is already sorted by band_index
# Pick RGB, or Green, or Blue, in this order, if available, otherwise first band
if user_band_name == "auto":
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:
Expand Down
3 changes: 3 additions & 0 deletions opendm/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,3 +925,6 @@ def get_capture_megapixels(self):
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()
44 changes: 41 additions & 3 deletions opendm/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, photos):
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
Expand Down Expand Up @@ -58,8 +58,40 @@ def detect_multi_camera(self):
for band_name in band_indexes:
mc.append({'name': band_name, 'photos': band_photos[band_name]})

# Sort by band index
mc.sort(key=lambda x: band_indexes[x['name']])
# We enforce a normalized band order for all bands that we can identify
# and rely on the manufacturer's band_indexes as a fallback for all others
normalized_band_order = {
'RGB': '0',
'REDGREENBLUE': '0',

'RED': '1',
'R': '1',

'GREEN': '2',
'G': '2',

'BLUE': '3',
'B': '3',

'NIR': '4',
'N': '4',

'REDEDGE': '5',
'RE': '5',

'LWIR': '6',
'L': '6',
}

for band_name in band_indexes:
if band_name.upper() not in normalized_band_order:
log.ODM_WARNING(f"Cannot identify order for {band_name} band, using manufacturer suggested index instead")

# Sort
mc.sort(key=lambda x: normalized_band_order.get(x['name'].upper(), '9' + band_indexes[x['name']]))

for c, d in enumerate(mc):
log.ODM_INFO(f"Band {c + 1}: {d['name']}")

return mc

Expand All @@ -82,6 +114,12 @@ def filter_photos(self):
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:
Expand Down
Loading