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

About coordinates normalization #49

Open
nnop opened this issue Jun 23, 2024 · 0 comments
Open

About coordinates normalization #49

nnop opened this issue Jun 23, 2024 · 0 comments

Comments

@nnop
Copy link

nnop commented Jun 23, 2024

Hi, Johan,

I have a question about the coordinates normalization in RoMa.

RoMa/roma/models/matcher.py

Lines 565 to 572 in 36389ef

def to_normalized_coordinates(self, coords, H_A, W_A, H_B, W_B):
if isinstance(coords, (list, tuple)):
kpts_A, kpts_B = coords[0], coords[1]
else:
kpts_A, kpts_B = coords[...,:2], coords[...,2:]
kpts_A = torch.stack((2/W_A * kpts_A[...,0] - 1, 2/H_A * kpts_A[...,1] - 1),axis=-1)
kpts_B = torch.stack((2/W_B * kpts_B[...,0] - 1, 2/H_B * kpts_B[...,1] - 1),axis=-1)
return kpts_A, kpts_B

As you're using colmap coordinate fasion, the left- and right-most pixel should be 0.5 and W-0.5.
The current code is converting them to [-1+1/W, 1-1/W].
Shouldn't the conversion be: (2*x-1) / (W-1) - 1?
That would make the left- and right-most pixel exactly [-1, 1].

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

1 participant