Merge pull request #1696 from pierotofy/321

More memory efficient find_features_homography
pull/1704/head
Piero Toffanin 2023-09-08 13:30:43 -04:00 zatwierdzone przez GitHub
commit 2930927207
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 23 dodań i 1 usunięć

Wyświetl plik

@ -1 +1 @@
3.2.0
3.2.1

Wyświetl plik

@ -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 = 2048
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)