Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@sarlinpe
Copy link
Member

@sarlinpe sarlinpe commented Jul 6, 2025

This PR moves the image import step (creating images, cameras, rigs, pose priors in the database) outside of the feature extraction. Benefits:

  • reduces code complexity
  • makes it possible to first import images and then run feature extraction outside of COLMAP based on the imported images -- this was possible only in pycolmap and incurred code duplication
  • guarantees that images are always sorted by name since image import is not multi-threaded

One downside of this is that we now need to read image pixels twice (to read the EXIF for import and later for extraction) but this is likely negligible, and we can later make it possible to read EXIF without the pixels.

Some points should be discussed:

  1. Are we OK with such breaking change of the CLI?
  2. If not, should we have feature_extractor call image_importer if the database is empty? We will still break the argument names of the mask_path and camera_mask_path options, but these are not widely used.
  3. Are we OK adding an extra step in the GUI?
  4. Do we want to make mask_path and camera_mask_path part of the SiftExtractionOptions?

TODO:

  • Add image importer widget -- once the above points are resolved.
  • Merge ImageReader and ImageImporter -- in a follow-up PR.
  • Add tests for FeatureExtractorController::ReadImageData -- in a follow-up PR.
  • Update the documentation.

if (exists_mask) {
if (!image_data.mask.Read(mask_path, false)) {
LOG(ERROR) << image.Name() << " Failed to read the mask file";
image_data.mask.Deallocate(); // Skip the mask but not the image!
Copy link
Member Author

@sarlinpe sarlinpe Jul 6, 2025

Choose a reason for hiding this comment

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

Previously, no features would be extracted for an image when its mask cannot be found or read. This seems wrong to me.

Comment on lines +87 to +107
enum class FeatureExtractionStatus {
FAILURE,
SUCCESS,
IMAGE_EXISTS,
BITMAP_ERROR,
};

std::string FeatureExtractionStatusToString(FeatureExtractionStatus status) {
switch (status) {
case FeatureExtractionStatus::SUCCESS:
return "SUCCESS";
case FeatureExtractionStatus::FAILURE:
return "FAILURE: Failed to process the image.";
case FeatureExtractionStatus::IMAGE_EXISTS:
return "IMAGE_EXISTS: Features for image were already extracted.";
case FeatureExtractionStatus::BITMAP_ERROR:
return "BITMAP_ERROR: Failed to read the image file format.";
default:
return "Unknown";
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

All of this is unnecessary if we decide to not propagate the image data through the queues when it is unsuccessful. The only downside of this is that error messages won't appear in the order of the FeatureWriterThread.

@sarlinpe sarlinpe requested review from B1ueber2y and ahojnnes and removed request for ahojnnes July 7, 2025 06:33
@ahojnnes
Copy link
Contributor

ahojnnes commented Jul 7, 2025

Thanks, this is a good initiative and I had the same in mind in the past. The main motivation for keeping them coupled was the one you already mentioned in that I wanted to avoid reading images twice. Another one is that an image in the database has valid features. I don't think we can start assuming images to be ordered by name, in particular, as we want to support the use case, where one can run multiple rounds of image import / feature extraction.

@ahojnnes
Copy link
Contributor

ahojnnes commented Jul 7, 2025

Another note is that this PR will have a lot of conflicts with the changes here: #3068

I should probably extract the non-ALIKED/LightGlue related refactoring into a separate PR until we land the torch changes (which still need some more testing due to cross-platform issues).

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. I like the overall idea. Reading images twice will not be a problem after switching to OpenImageIO as it supports reading EXIF header info without reading pixels. I also think that adding an extra step in the CLI is fine and makes sense to make the feature extractor more flexible in python side.

Many lines in the PR are commented out for now. I assume that it is still in progress?

@sarlinpe sarlinpe marked this pull request as draft July 14, 2025 22:07
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.

4 participants