Skip to content

Commit

Permalink
More memory efficient find_features_homography
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Sep 8, 2023
1 parent 5016214 commit 2fea4d9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions opendm/multispectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,28 @@ def find_features_homography(image_gray, align_image_gray, feature_retention=0.7

# Detect SIFT features and compute descriptors.
detector = cv2.SIFT_create(edgeThreshold=10, contrastThreshold=0.1)

h,w = image_gray.shape
max_dim = max(h, w)

max_size = 1280
if max_dim > max_size:
if max_dim == w:
f = max_size / w
else:
f = max_size / h
image_gray = cv2.resize(image_gray, None, fx=f, fy=f, interpolation=cv2.INTER_AREA)
h,w = image_gray.shape

if align_image_gray.shape[0] != image_gray.shape[0]:
fx = image_gray.shape[1]/align_image_gray.shape[1]
fy = image_gray.shape[0]/align_image_gray.shape[0]

align_image_gray = cv2.resize(align_image_gray, None,
fx=fx,
fy=fy,
interpolation=(cv2.INTER_AREA if (fx < 1.0 and fy < 1.0) else cv2.INTER_LANCZOS4))

kp_image, desc_image = detector.detectAndCompute(image_gray, None)
kp_align_image, desc_align_image = detector.detectAndCompute(align_image_gray, None)

Expand Down

0 comments on commit 2fea4d9

Please sign in to comment.