Giter VIP home page Giter VIP logo

Comments (4)

Phil26AT avatar Phil26AT commented on May 24, 2024 3

Hi @Ram-198

I am not very familiar with the functions you used, but you could do something similar with pycolmap:

import pycolmap
import cv2

image0 = load_image('path/to/image0.jpg')
image1 = load_image('path/to/image1.jpg')

# run lightglue to obtain m_kpts0, m_kpts1 (see demo notebook)

K0 = pycolmap.infer_camera_from_image('path/to/image0.jpg').calibration_matrix()
K1 = pycolmap.infer_camera_from_image('path/to/image1.jpg').calibration_matrix()

H, inliers = cv2.findHomography(m_kpts0, m_kpts1, cv2.USAC_MAGSAC, 0.5, 0.999, 100000)

ret = pycolmap.homography_decomposition(H, K0, K1, m_kpts0, m_kpts1)

R, t = ret['R'], ret['t']

from lightglue.

aelsaer avatar aelsaer commented on May 24, 2024 2

Thank you @Phil26AT for providing this code snippet. I think cv2.findHomography takes 4 arguments while cv2.FindFundamentalMat takes 6. And a minor comment, considering that m_kpts0, m_kpts1 are tensors, they need to be transformed to numpy thus, m_kpts0.numpy() , m_kpts1.numpy() will work. Thanks again @Phil26AT! LightGlue is outstanding.

from lightglue.

yayaYsmile avatar yayaYsmile commented on May 24, 2024

Thank you @Phil26AT for providing this code snippet. I think cv2.findHomography takes 4 arguments while cv2.FindFundamentalMat takes 6. And a minor comment, considering that m_kpts0, m_kpts1 are tensors, they need to be transformed to numpy thus, m_kpts0.numpy() , m_kpts1.numpy() will work. Thanks again @Phil26AT! LightGlue is outstanding.

Hi!
When calculating the camera matrix and converting the tensor m_kpts0, m_kpts1 to numpy it seems that the tensor on the GPU can't be converted directly with numpy, it has to be converted to a tensor on the CPU and then to numpy: torch.cpu().numpy(). However this seems to make the computation slow, is there any other way to solve this problem?

from lightglue.

aelsaer avatar aelsaer commented on May 24, 2024

Hello @yayaYsmile. As far as I'm aware, if you're working with PyTorch tensors, Kornia is a good option since it allows for operations directly on tensors. However, in terms of outlier removal, I believe Kornia primarily offers RANSAC. It's possible they may have added more methods in newer versions, so it might be worth checking their documentation or source code for any updates.

from lightglue.

Related Issues (20)

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.