Skip to content

Commit 2930927

Browse files
authored
Merge pull request #1696 from pierotofy/321
More memory efficient find_features_homography
2 parents 07b641d + 83fef16 commit 2930927

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.0
1+
3.2.1

opendm/multispectral.py

+22
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,28 @@ def find_features_homography(image_gray, align_image_gray, feature_retention=0.7
504504

505505
# Detect SIFT features and compute descriptors.
506506
detector = cv2.SIFT_create(edgeThreshold=10, contrastThreshold=0.1)
507+
508+
h,w = image_gray.shape
509+
max_dim = max(h, w)
510+
511+
max_size = 2048
512+
if max_dim > max_size:
513+
if max_dim == w:
514+
f = max_size / w
515+
else:
516+
f = max_size / h
517+
image_gray = cv2.resize(image_gray, None, fx=f, fy=f, interpolation=cv2.INTER_AREA)
518+
h,w = image_gray.shape
519+
520+
if align_image_gray.shape[0] != image_gray.shape[0]:
521+
fx = image_gray.shape[1]/align_image_gray.shape[1]
522+
fy = image_gray.shape[0]/align_image_gray.shape[0]
523+
524+
align_image_gray = cv2.resize(align_image_gray, None,
525+
fx=fx,
526+
fy=fy,
527+
interpolation=(cv2.INTER_AREA if (fx < 1.0 and fy < 1.0) else cv2.INTER_LANCZOS4))
528+
507529
kp_image, desc_image = detector.detectAndCompute(image_gray, None)
508530
kp_align_image, desc_align_image = detector.detectAndCompute(align_image_gray, None)
509531

0 commit comments

Comments
 (0)