Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get description from giving point(x,y) #101

Open
phamkhactu opened this issue Jan 10, 2024 · 2 comments
Open

How to get description from giving point(x,y) #101

phamkhactu opened this issue Jan 10, 2024 · 2 comments

Comments

@phamkhactu
Copy link

Thanks for great work!

I want to get description from point(x,y).

For example in cv2 I can get:

gray_image = cv2.imread(path,0)

sift = cv2.SIFT_create()
keypoint = cv2.KeyPoint(x, y, 20)
keypoints, descriptors = sift.compute(gray_image, [keypoint])

but I don't know the way to get it in LightGlue
I'm happy for your help! Thank you.

@Phil26AT
Copy link
Collaborator

Hey @phamkhactu, LightGlue actually takes the description of each point(x,y) as input to find correspondences between 2 images. However, you can get the description from the extractors, something like this:

from lightglue import LightGlue, SuperPoint
from lightglue.utils import load_image, rbd

# SuperPoint+LightGlue
extractor = SuperPoint(max_num_keypoints=2048).eval().cuda()  # load the extractor
matcher = LightGlue(features='superpoint').eval().cuda()  # load the matcher

# load image as a torch.Tensor on GPU with shape (3,H,W), normalized in [0,1]
image0 = load_image('path/to/image_0.jpg').cuda()

# extract local features
feats0 = extractor.extract(image0)  # auto-resize the image, disable with resize=None
keypoints, descriptors = feats0["keypoints"][0], feats0["descriptors"][0] 

@phamkhactu
Copy link
Author

Hey @phamkhactu, LightGlue actually takes the description of each point(x,y) as input to find correspondences between 2 images. However, you can get the description from the extractors, something like this:

from lightglue import LightGlue, SuperPoint
from lightglue.utils import load_image, rbd

# SuperPoint+LightGlue
extractor = SuperPoint(max_num_keypoints=2048).eval().cuda()  # load the extractor
matcher = LightGlue(features='superpoint').eval().cuda()  # load the matcher

# load image as a torch.Tensor on GPU with shape (3,H,W), normalized in [0,1]
image0 = load_image('path/to/image_0.jpg').cuda()

# extract local features
feats0 = extractor.extract(image0)  # auto-resize the image, disable with resize=None
keypoints, descriptors = feats0["keypoints"][0], feats0["descriptors"][0] 

Hi @Phil26AT

As your describe above, each point has description. But I see that model limited by max_num_keypoints, so with image has 1280x720, some pixel doesn't has description.

I am so sorry if I misunderstand your response.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants