📝 simple library to make life easy when deploying superpoint, superglue models
⚙️ Installation
pip install superpoint_superglue_deployment
🎉 TODO
- interface to deploy superpoint, superglue
- testing on real data
🏃 How to Run
Basic usage
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
🎛 Development environment
mamba env create --file environment.yml
mamba activate superpoint_superglue_deployment
💎 References
Metadata
Release files for superpoint-superglue-deployment 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| superpoint_superglue_deployment-0.0.3.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| superpoint_superglue_deployment-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.2 kB
Release files / superpoint_superglue_deployment-0.0.3.tar.gz
| Download URL | superpoint_superglue_deployment-0.0.3.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6010b82194bba7a0701b73899842d1662db77526ad407f2daf376896ae9ba369
|
|
BLAKE2b-256 checksum How to use checksums |
e8e6f8a7dddc6188d18c14c90dcee306558d7670cbc38739522e8e844297f845
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.17
|
Release files / superpoint_superglue_deployment-0.0.3-py3-none-any.whl
| Download URL | superpoint_superglue_deployment-0.0.3-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aecef08b6374cbe270ed40adb77db9e4b9efe517b74483bc53cb782600b569d2
|
|
BLAKE2b-256 checksum How to use checksums |
0ca4c6b844c2ab211de96cb765b30eaff2f100e0e01e0e4f0bf62fb2206a18c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.17
|