Merge pull request #1771 from pierotofy/homographyfix

Mavic 3M Support
pull/1775/head
Piero Toffanin 2024-06-29 11:36:53 -04:00 zatwierdzone przez GitHub
commit 9acbaf5326
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
6 zmienionych plików z 29 dodań i 22 usunięć

Wyświetl plik

@ -244,7 +244,7 @@ externalproject_add(dem2points
externalproject_add(odm_orthophoto
DEPENDS opencv
GIT_REPOSITORY https://github.com/OpenDroneMap/odm_orthophoto.git
GIT_TAG 317
GIT_TAG 353
PREFIX ${SB_BINARY_DIR}/odm_orthophoto
SOURCE_DIR ${SB_SOURCE_DIR}/odm_orthophoto
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}

Wyświetl plik

@ -1 +1 @@
3.5.2
3.5.3

Wyświetl plik

@ -427,14 +427,14 @@ def find_ecc_homography(image_gray, align_image_gray, number_of_iterations=1000,
pyramid_levels = 0
h,w = image_gray.shape
max_dim = max(h, w)
downscale = 0
max_size = 1280
max_size = 2048
while max_dim / (2**downscale) > max_size:
downscale += 1
if max_dim > max_size:
if max_dim == w:
f = max_size / w
else:
f = max_size / h
if downscale > 0:
f = 1 / (2**downscale)
image_gray = cv2.resize(image_gray, None, fx=f, fy=f, interpolation=cv2.INTER_AREA)
h,w = image_gray.shape
@ -473,7 +473,6 @@ def find_ecc_homography(image_gray, align_image_gray, number_of_iterations=1000,
# Define the motion model, scale the initial warp matrix to smallest level
warp_matrix = np.eye(3, 3, dtype=np.float32)
warp_matrix = warp_matrix * np.array([[1,1,2],[1,1,2],[0.5,0.5,1]], dtype=np.float32)**(1-(pyramid_levels+1))
for level in range(pyramid_levels+1):
ig = gradient(gaussian(image_gray_pyr[level]))
@ -495,14 +494,16 @@ def find_ecc_homography(image_gray, align_image_gray, number_of_iterations=1000,
if level != pyramid_levels:
log.ODM_INFO("Could not compute ECC warp_matrix at pyramid level %s, resetting matrix" % level)
warp_matrix = np.eye(3, 3, dtype=np.float32)
warp_matrix = warp_matrix * np.array([[1,1,2],[1,1,2],[0.5,0.5,1]], dtype=np.float32)**(1-(pyramid_levels+1))
else:
raise e
if level != pyramid_levels:
warp_matrix = warp_matrix * np.array([[1,1,2],[1,1,2],[0.5,0.5,1]], dtype=np.float32)
return warp_matrix
if downscale > 0:
return warp_matrix * (np.array([[1,1,2],[1,1,2],[0.5,0.5,1]], dtype=np.float32) ** downscale)
else:
return warp_matrix
def find_features_homography(image_gray, align_image_gray, feature_retention=0.7, min_match_count=10):
@ -512,13 +513,14 @@ def find_features_homography(image_gray, align_image_gray, feature_retention=0.7
h,w = image_gray.shape
max_dim = max(h, w)
downscale = 0
max_size = 2048
if max_dim > max_size:
if max_dim == w:
f = max_size / w
else:
f = max_size / h
max_size = 4096
while max_dim / (2**downscale) > max_size:
downscale += 1
if downscale > 0:
f = 1 / (2**downscale)
image_gray = cv2.resize(image_gray, None, fx=f, fy=f, interpolation=cv2.INTER_AREA)
h,w = image_gray.shape
@ -570,7 +572,13 @@ def find_features_homography(image_gray, align_image_gray, feature_retention=0.7
# Find homography
h, _ = cv2.findHomography(points_image, points_align_image, cv2.RANSAC)
return h
if h is None:
return None
if downscale > 0:
return h * (np.array([[1,1,2],[1,1,2],[0.5,0.5,1]], dtype=np.float32) ** downscale)
else:
return h
def gradient(im, ksize=5):
im = local_normalize(im)
@ -635,4 +643,4 @@ def resize_match(image, dimension):
fy=fx,
interpolation=(cv2.INTER_AREA if (fx < 1.0 and fy < 1.0) else cv2.INTER_LANCZOS4))
return image
return image

Wyświetl plik

@ -413,7 +413,7 @@ class ODM_Photo:
self.set_attr_from_xmp_tag('speed_z', xtags, [
'@drone-dji:FlightZSpeed',
], float)
# Account for over-estimation
if self.gps_xy_stddev is not None:
self.gps_xy_stddev *= 2.0

Wyświetl plik

@ -285,7 +285,6 @@ class ODM_Reconstruction(object):
if p.filename == filename:
return p
class ODM_GeoRef(object):
@staticmethod
def FromCoordsFile(coords_file):

Wyświetl plik

@ -162,7 +162,7 @@ class ODMLoadDatasetStage(types.ODM_Stage):
(p, ext) = os.path.splitext(r)
if p[-5:] == "_mask" and ext.lower() in context.supported_extensions:
masks[p] = r
photos = []
with open(tree.dataset_list, 'w') as dataset_list:
log.ODM_INFO("Loading %s images" % len(path_files))