diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 4823dd72..c558894a 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -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} diff --git a/VERSION b/VERSION index 87ce4929..444877d4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.2 +3.5.3 diff --git a/opendm/multispectral.py b/opendm/multispectral.py index 3d2373d3..ff29fa3f 100644 --- a/opendm/multispectral.py +++ b/opendm/multispectral.py @@ -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 \ No newline at end of file + return image diff --git a/opendm/photo.py b/opendm/photo.py index 0baaf259..943ac942 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -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 diff --git a/opendm/types.py b/opendm/types.py index 3e437c0f..cc588912 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -285,7 +285,6 @@ class ODM_Reconstruction(object): if p.filename == filename: return p - class ODM_GeoRef(object): @staticmethod def FromCoordsFile(coords_file): diff --git a/stages/dataset.py b/stages/dataset.py index 4e5eb360..a99bca35 100644 --- a/stages/dataset.py +++ b/stages/dataset.py @@ -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))