Skip to content

Add Python bindings for feature extractor#4130

Merged
ahojnnes merged 4 commits into
mainfrom
user/jsch/feature-extraction-bindings
Feb 24, 2026
Merged

Add Python bindings for feature extractor#4130
ahojnnes merged 4 commits into
mainfrom
user/jsch/feature-extraction-bindings

Conversation

@ahojnnes

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ahojnnes, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the Python bindings for feature extraction within pycolmap. It introduces a new, unified FeatureExtractor class that serves as a central point for all feature extraction operations, deprecating older, specific extractor classes like Sift and Aliked. This change aims to provide a more consistent and extensible API for users, making it easier to switch between different feature extraction algorithms and integrate new ones in the future. The update also improves flexibility by allowing various image input formats, including NumPy arrays, directly into the extraction process.

Highlights

  • Unified Feature Extractor Interface: Introduced a new FeatureExtractor Python binding, providing a unified and extensible interface for various feature extraction methods (e.g., SIFT, ALIKED).
  • Deprecation of Specific Extractors: Deprecated the direct use of pycolmap.Sift and pycolmap.Aliked classes, encouraging users to leverage the new FeatureExtractor.create() method for consistency and future compatibility.
  • Flexible Image Input: Added extract methods to the FeatureExtractor binding, supporting feature extraction from Bitmap objects and various NumPy array types (uint8 and float32).
  • Feature Extraction Options Enhancement: Enhanced FeatureExtractionOptions to allow specifying the FeatureExtractorType directly during initialization, streamlining configuration.
  • Code Refactoring: Refactored the BitmapFromArray utility function into a dedicated header file (pycolmap/sensor/bitmap.h) for improved modularity and organization.
Changelog
  • src/pycolmap/feature/extraction.cc
    • Included colmap/feature/extractor.h and pycolmap/sensor/bitmap.h for new functionalities.
    • Removed the include for colmap/feature/utils.h.
    • Defined PyFeatureExtractor as a trampoline class to enable Python inheritance for FeatureExtractor.
    • Added a deprecation warning to the Sift constructor, guiding users to the new FeatureExtractor.create() method.
    • Removed the Aliked class and its associated Python bindings, consolidating its functionality under the new FeatureExtractor.
    • Modified FeatureExtractionOptions to accept FeatureExtractorType in its constructor and exposed the type property.
    • Bound the FeatureExtractor class, including a static create method and extract overloads for Bitmap, uint8_t NumPy arrays, and float32 NumPy arrays.
  • src/pycolmap/sensor/bitmap.cc
    • Updated the include path for bitmap.h to pycolmap/sensor/bitmap.h.
    • Removed an unused pitch variable within the BitmapFromArray function.
  • src/pycolmap/sensor/bitmap.h
    • Created a new header file to declare the BitmapFromArray utility function, improving code organization.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request introduces Python bindings for the FeatureExtractor class, allowing for more flexible feature extraction from various image formats (Bitmap, uint8 NumPy arrays, float32 NumPy arrays). It also deprecates the Sift and Aliked classes in favor of the new FeatureExtractor.create() method, streamlining the API. The changes include necessary header updates, the addition of a PyFeatureExtractor trampoline class for Pybind11, and the removal of the standalone Aliked class implementation. The BitmapFromArray function in src/pycolmap/sensor/bitmap.cc was also slightly refactored.

Comment thread src/pycolmap/feature/extraction.cc

@B1ueber2y B1ueber2y left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. In the future, we might benefit from a better coverage of pycolmap testing infra in the future to better catch any backwards breakage for these modules not tested in the end-to-end pipeline.

Comment thread src/pycolmap/feature/extraction.cc Outdated
@ahojnnes ahojnnes enabled auto-merge (squash) February 24, 2026 11:07
@ahojnnes ahojnnes merged commit 7195e83 into main Feb 24, 2026
14 checks passed
@ahojnnes ahojnnes deleted the user/jsch/feature-extraction-bindings branch February 24, 2026 11:11
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.

3 participants