Skip to content

Conversation

@ahojnnes
Copy link
Contributor

@ahojnnes ahojnnes commented Dec 21, 2024

  • Adds support for extracting ALIKED features.
  • Adds support for matching ALIKED features using simple dot-product based nearest neighbor search.
  • Adds support for matching ALIKED and SIFT using LightGlue.

@behnamasadi
Copy link
Contributor

Does this mean no need for SIFT anymore?

@ahojnnes ahojnnes marked this pull request as ready for review May 1, 2025 18:54
@ahojnnes ahojnnes requested review from B1ueber2y, mihaidusmanu, sarlinpe, trueprice and yimingc and removed request for yimingc May 1, 2025 18:55
Copy link
Member

@sarlinpe sarlinpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a massive amount of work, thank you!


// Detect fixed number of top k features independent of detection score.
// Ignored if negative.
int top_k = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this redundant with max_num_features? wouldn't bool force_extract_max_num_features = false be sufficient?

const int width = bitmap_ptr->Width();
const int height = bitmap_ptr->Height();
auto row_major_array = bitmap_ptr->ConvertToRowMajorArray();
// Clone to ensure ownership
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add to the line that calls clone()

const torch::Tensor torch_image =
torch::from_blob(
row_major_array.data(), {height, width, 3}, torch::kUInt8)
.clone()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is cloning needed given that casting to float creates a copy?

Comment on lines +185 to +193
// Normalize to [-1, 1].
torch_keypoints.index({torch::indexing::Ellipsis, 0}) =
(2.0f * torch_keypoints.index({torch::indexing::Ellipsis, 0}) /
image.width) -
1.0f;
torch_keypoints.index({torch::indexing::Ellipsis, 1}) =
(2.0f * torch_keypoints.index({torch::indexing::Ellipsis, 1}) /
image.height) -
1.0f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already done in LightGlue::forward by passing the image size as input?

Copy link
Contributor

@B1ueber2y B1ueber2y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the amazing efforts!

matches->reserve(num_keypoints1);
for (int i1 = 0; i1 < num_keypoints1; ++i1) {
const int i2 = nn12_data[i1];
if (i1 == nn21_data[i2]) {
Copy link
Contributor

@B1ueber2y B1ueber2y May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we also need to check against the similarity here, to avoid the match of i1 == 0 && i2 == 0.

}
}

void MatchGuided(double max_error,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some comments in the virtual class for Match and MatchGuided. From my understanding the current intention of MatchGuided is to make use of the two view geometry to do guided matching and store the matches in inlier matches? Why not output a FeatureMatches instead?

On the other hand, since LightGlue does not benefit from guided matching, we should raise a warning on the call of this method.

I also did not find any usage for this MatchGuided method throughout COLMAP.

@xiemeilong
Copy link

It seems LiftFeat is approximately twice as fast as ALIKED and also achieves higher accuracy. It's also designed to handle challenging scenarios such as drastic lighting changes, low-texture regions, and repetitive patterns. Maybe consider switching from ALIKED to LiftFeat or adding both?

@Ben-Mack
Copy link

Ben-Mack commented May 26, 2025

I'm really interested in this, Looking forward to see this PR merged soon!
Are there any problem blocking this PR?

@xiemeilong
Copy link

Colmap ALIKED + Lightglue produces worse result than hloc.

HLOC ALIKED + Lightglue with default parameters
image

colmap ALIKED + Lightglue with default parameters(not all images registered)
image

colmap ALIKED + Lightglue with --ALIKEDExtraction.max_image_size 1024 --ALIKEDMatching.min_similarity 0.1
image

@ahojnnes
Copy link
Contributor Author

ahojnnes commented Jul 7, 2025

@xiemeilong Thanks for the feedback. There are still some known issues related to torch under Windows that I cannot root cause. I am not sure if these hint at some larger issues also on other platforms. On which platform did you run this comparison? Unrelated to these issues, the current colmap implementation does not auto-rotate the images to be upright (e.g., based on EXIF image orientation information). ALIKED/LightGlue only work reliably up to ~45deg rotation change between images. Can it be that your images are inconsistently rotated?

@xiemeilong
Copy link

@ahojnnes I tested this on Linux, and all images orientations are same. I found that LightGlue doesn't work well with aliked-n32 in my tests, hloc uses aliked-n16 by default.

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

Successfully merging this pull request may close these issues.

9 participants