Git Product home page Git Product logo

superpoint_superglue_deployment's Introduction

Build Status

๐Ÿ“ 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()

matched image sample

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


superpoint_superglue_deployment's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.