From a5764af46be9644adefdad689f8a31d2cf8e9bc0 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 28 Jan 2023 21:36:02 -0500 Subject: [PATCH] Quantix multispectral fixes --- opendm/multispectral.py | 15 +++++++++++++++ stages/run_opensfm.py | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/opendm/multispectral.py b/opendm/multispectral.py index e1d530a3..dddcb3db 100644 --- a/opendm/multispectral.py +++ b/opendm/multispectral.py @@ -563,6 +563,8 @@ def local_normalize(im): def align_image(image, warp_matrix, dimension): + image = resize_match(image, dimension) + if warp_matrix.shape == (3, 3): return cv2.warpPerspective(image, warp_matrix, dimension) else: @@ -594,3 +596,16 @@ def to_8bit(image, force_normalize=False): return image +def resize_match(image, dimension): + h, w = image.shape[0], image.shape[1] + mw, mh = dimension + + if w != mw or h != mh: + fx = mw/w + fy = mh/h + image = cv2.resize(image, None, + fx=fx, + fy=fx, + interpolation=(cv2.INTER_AREA if (fx < 1.0 and fy < 1.0) else cv2.INTER_LANCZOS4)) + + return image \ No newline at end of file diff --git a/stages/run_opensfm.py b/stages/run_opensfm.py index 5ef220c2..90558dd5 100644 --- a/stages/run_opensfm.py +++ b/stages/run_opensfm.py @@ -104,9 +104,9 @@ class ODMOpenSfMStage(types.ODM_Stage): image = func(shot_id, image) return image - def resize_secondary_images(shot_id, image): + def resize_thermal_images(shot_id, image): photo = reconstruction.get_photo(shot_id) - if photo.band_name != primary_band_name: + if photo.is_thermal(): return thermal.resize_to_match(image, largest_photo) else: return image @@ -138,8 +138,8 @@ class ODMOpenSfMStage(types.ODM_Stage): return image if reconstruction.multi_camera: - largest_photo = find_largest_photo([p for p in photos if p.band_name == primary_band_name]) - undistort_pipeline.append(resize_secondary_images) + largest_photo = find_largest_photo([p for p in photos]) + undistort_pipeline.append(resize_thermal_images) if args.radiometric_calibration != "none": undistort_pipeline.append(radiometric_calibrate)