From 2701e090f0860077694ab3733a0b3879aae624fe Mon Sep 17 00:00:00 2001 From: Dmytro Mishkin Date: Thu, 1 Jul 2021 16:46:07 +0200 Subject: [PATCH 1/2] New opencv ransac It works much better, than old one... --- python/DeepFeatureMatcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/DeepFeatureMatcher.py b/python/DeepFeatureMatcher.py index 921bd63..761dc65 100644 --- a/python/DeepFeatureMatcher.py +++ b/python/DeepFeatureMatcher.py @@ -76,7 +76,7 @@ def match(self, img_A, img_B, display_results=0, *args): dst = points_A.t().numpy() if points_A.size(1) >= 4: - H_init, _ = cv.findHomography(src, dst, method=cv.RANSAC, ransacReprojThreshold=16*np.sqrt(2)+1, maxIters=5000, confidence=0.9999) + H_init, _ = cv.findHomography(src, dst, method=cv.USAC_MAGSAC, ransacReprojThreshold=16*np.sqrt(2)+1, maxIters=5000, confidence=0.9999) # opencv might return None for H, check for None H_init = np.eye(3, dtype=np.double) if H_init is None else H_init From acf7a3b96c06df6c0ff4681ac96ec513a911d507 Mon Sep 17 00:00:00 2001 From: Dmytro Mishkin Date: Thu, 1 Jul 2021 16:58:13 +0200 Subject: [PATCH 2/2] Update DeepFeatureMatcher.py --- python/DeepFeatureMatcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/DeepFeatureMatcher.py b/python/DeepFeatureMatcher.py index 761dc65..57e7674 100644 --- a/python/DeepFeatureMatcher.py +++ b/python/DeepFeatureMatcher.py @@ -136,7 +136,7 @@ def match(self, img_A, img_B, display_results=0, *args): dst = points_A.t().numpy() if points_A.size(1) >= 4: - H, _ = cv.findHomography(src, dst, method=cv.RANSAC, ransacReprojThreshold=3.0, maxIters=5000, confidence=0.9999) + H, _ = cv.findHomography(src, dst, method=cv.USAC_MAGSAC, ransacReprojThreshold=3.0, maxIters=5000, confidence=0.9999) # opencv might return None for H, check for None H = np.eye(3, dtype=np.double) if H is None else H