Merge pull request #1591 from pierotofy/capt

Quantix multispectral fixes
pull/1596/head
Piero Toffanin 2023-01-28 22:22:05 -05:00 zatwierdzone przez GitHub
commit 6c5677ebc8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 21 dodań i 6 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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)
@ -149,7 +149,8 @@ class ODMOpenSfMStage(types.ODM_Stage):
if reconstruction.multi_camera:
# Undistort only secondary bands
image_list_override = [os.path.join(tree.dataset_raw, p.filename) for p in photos] # if p.band_name.lower() != primary_band_name.lower()
primary_band_name = multispectral.get_primary_band_name(reconstruction.multi_camera, args.primary_band)
image_list_override = [os.path.join(tree.dataset_raw, p.filename) for p in photos if p.band_name.lower() != primary_band_name.lower()]
# We backup the original reconstruction.json, tracks.csv
# then we augment them by duplicating the primary band
@ -161,7 +162,6 @@ class ODMOpenSfMStage(types.ODM_Stage):
s2p, p2s = None, None
if not io.file_exists(added_shots_file) or self.rerun():
primary_band_name = multispectral.get_primary_band_name(reconstruction.multi_camera, args.primary_band)
s2p, p2s = multispectral.compute_band_maps(reconstruction.multi_camera, primary_band_name)
if not args.skip_band_alignment: