zbc 0be4b5a819 -update: version beta1.0 | vor 4 Monaten | |
---|---|---|
.github | vor 1 Jahr | |
data | vor 4 Monaten | |
docs | vor 1 Jahr | |
notebooks | vor 1 Jahr | |
scripts | vor 1 Jahr | |
superpoint_superglue_deployment | vor 4 Monaten | |
tests | vor 1 Jahr | |
.flake8 | vor 1 Jahr | |
.gitignore | vor 1 Jahr | |
.pre-commit-config.yaml | vor 1 Jahr | |
MANIFEST.in | vor 1 Jahr | |
README.md | vor 1 Jahr | |
count_env.py | vor 4 Monaten | |
demo.py | vor 4 Monaten | |
demo_env.py | vor 4 Monaten | |
environment.yml | vor 1 Jahr | |
generate_test_images.py | vor 4 Monaten | |
image-stitching.py | vor 4 Monaten | |
image_match_demo.py | vor 4 Monaten | |
image_similarity_count.py | vor 4 Monaten | |
params.yml | vor 4 Monaten | |
pyproject.toml | vor 1 Jahr | |
read.py | vor 4 Monaten | |
requirements-dev.txt | vor 1 Jahr | |
requirements.txt | vor 1 Jahr | |
rorate_image_detection.py | vor 4 Monaten | |
setup.cfg | vor 1 Jahr | |
setup.py | vor 4 Monaten | |
small_image_match.py | vor 4 Monaten | |
test.py | vor 4 Monaten |
pip install superpoint_superglue_deployment
import cv2
import numpy as np
from loguru import logger
from superpoint_superglue_deployment import Matcher
def main():
query_image = cv2.imread("./data/images/one_pillar_pagoda_1.jpg")
ref_image = cv2.imread("./data/images/one_pillar_pagoda_2.jpg")
query_gray = cv2.imread("./data/images/one_pillar_pagoda_1.jpg", 0)
ref_gray = cv2.imread("./data/images/one_pillar_pagoda_2.jpg", 0)
superglue_matcher = Matcher(
{
"superpoint": {
"input_shape": (-1, -1),
"keypoint_threshold": 0.003,
},
"superglue": {
"match_threshold": 0.5,
},
"use_gpu": True,
}
)
query_kpts, ref_kpts, _, _, matches = superglue_matcher.match(query_gray, ref_gray)
M, mask = cv2.findHomography(
np.float64([query_kpts[m.queryIdx].pt for m in matches]).reshape(-1, 1, 2),
np.float64([ref_kpts[m.trainIdx].pt for m in matches]).reshape(-1, 1, 2),
method=cv2.USAC_MAGSAC,
ransacReprojThreshold=5.0,
maxIters=10000,
confidence=0.95,
)
logger.info(f"number of inliers: {mask.sum()}")
matches = np.array(matches)[np.all(mask > 0, axis=1)]
matches = sorted(matches, key=lambda match: match.distance)
matched_image = cv2.drawMatches(
query_image,
query_kpts,
ref_image,
ref_kpts,
matches[:50],
None,
flags=2,
)
cv2.imwrite("matched_image.jpg", matched_image)
if __name__ == "__main__":
main()
Command line to test matching two images after installing the library
match_two_images --query_path [path/to/query/image] --ref_path [path/to/reference/image] --use_gpu
mamba env create --file environment.yml
mamba activate superpoint_superglue_deployment