Skip to content

Commit

Permalink
added RANSAC in geometric_verification
Browse files Browse the repository at this point in the history
Former-commit-id: ecec9a2
  • Loading branch information
lcmrl committed Jan 23, 2024
1 parent 8d7032c commit ddc655e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/roma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# User configuration file

general:
tile_size: (2400, 2000)
geom_verification: ransac
min_inliers_per_pair: 10
min_inlier_ratio_per_pair: 0.25

extractor:
name: "no_extractor"

matcher:
name: "roma"
1 change: 1 addition & 0 deletions src/deep_image_matching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class GeometricVerification(Enum):
NONE = 0
PYDEGENSAC = 1
MAGSAC = 2
RANSAC = 3


class Quality(Enum):
Expand Down
16 changes: 16 additions & 0 deletions src/deep_image_matching/utils/geometric_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,20 @@ def geometric_verification(
)
inlMask = np.ones(len(kpts0), dtype=bool)

if method == GeometricVerification.RANSAC:
try:
F, inliers = cv2.findFundamentalMat(
kpts0, kpts1, cv2.RANSAC, threshold, confidence, max_iters
)
inlMask = (inliers > 0).squeeze()
if not quiet:
logger.debug(
f"RANSAC found {inlMask.sum()} inliers ({inlMask.sum()*100/len(kpts0):.2f}%)"
)
except Exception as err:
logger.error(
f"{err}. Unable to perform geometric verification with RANSAC."
)
inlMask = np.ones(len(kpts0), dtype=bool)

return F, inlMask

0 comments on commit ddc655e

Please sign in to comment.