Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix inconsistent image resizing between CPU/GPU implementations of SIFT#1642

Merged
ahojnnes merged 4 commits into
colmap:devcolmap/colmap:devfrom
Yzhbuaa:fix_image_resize_siftGPUYzhbuaa/colmap:fix_image_resize_siftGPUCopy head branch name to clipboard
Jan 8, 2023
Merged

Fix inconsistent image resizing between CPU/GPU implementations of SIFT#1642
ahojnnes merged 4 commits into
colmap:devcolmap/colmap:devfrom
Yzhbuaa:fix_image_resize_siftGPUYzhbuaa/colmap:fix_image_resize_siftGPUCopy head branch name to clipboard

Conversation

@Yzhbuaa

@Yzhbuaa Yzhbuaa commented Sep 28, 2022

Copy link
Copy Markdown
Contributor

This is an important fix which could improves reconstruction quality in many cases.

Fix the issue of inconsistent resize behavior between CPU version of SIFT and siftGPU.

The 'max_image_size' is passed to '-maxd' flag of siftGPU. The '-maxd' flag means maximum working dimension of SIFT algorithm. The problem is that the maximum working dimension of SIFT algorithm is twice the maximum of the image width/height(The SIFT algorithm first doubles the width and height of its input image).

The issue will cause that many reconstructions which used siftGPU features suffer from potentially lower feature quality and less feature numbers due to unexpected image down-sampling.

Check siftGPU manual for more details.

image

@ahojnnes

ahojnnes commented Oct 1, 2022

Copy link
Copy Markdown
Contributor

While I am aware of discrepancies between CPU and GPU implementations, I am not so sure that this fix is correct. I would imagine that one has to consider the upsampling factor for the first scale in the pyramid to do this calculation correctly (that would be first_octave)?

@Yzhbuaa

Yzhbuaa commented Oct 2, 2022

Copy link
Copy Markdown
Contributor Author

I think you are right, we need to take the 'first_octave' option into account to unify the downsampling ratio setting between CPU and GPU implementation.

By default('first_octave = -1'), if we set the 'max_image_size' to 3200, and we provide images whose dimension are 1920 * 1080. The CPU implementation would not perform downsamping to the original images(which is the work of ImageResizerThread), while the GPU implementation would downsample the original images on its side(cause 3840 exceeds the threshold 3200 we provided).

@ahojnnes ahojnnes changed the title Fix image resize issue in siftGPU Fix inconsistent image resizing between CPU/GPU implementations of SIFT Jan 8, 2023
@ahojnnes
ahojnnes enabled auto-merge (squash) January 8, 2023 13:01
Comment thread src/feature/sift.cc
// Set maximum image dimension.
// Note the max dimension of SiftGPU is the maximum dimension of the
// first octave in the pyramid (which is the 'first_octave').
const double compensation_ratio = std::pow(2, -options.first_octave);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello Johannes, I am a little confused by this line's modification. No image up-sampling happens in the GPU version SIFT when 'first_ocatve' > 1. In that case, image resizing happens only in ImageResizerThread. So I think the compensation_ratio should be 1 when 'first_ocatve' > 1. Otherwise, image will be downsampled more than we've
expected.

@ahojnnes ahojnnes Jan 8, 2023

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.

Yes, I overlooked the fact that SIFT doesn't handle the upsampling. Should be fixed here: #1751

@Yzhbuaa
Yzhbuaa disabled auto-merge January 8, 2023 14:35
@ahojnnes
ahojnnes merged commit c36cec3 into colmap:dev Jan 8, 2023
@bartoszek

Copy link
Copy Markdown

This breaks feature_extractor, .*_matcher on Linux host: {cuda:11.8.0, gcc:13.2.1 nvidia:535.104.05. gpu:gtx970}
feature_extractor fails with:

FilterH:        an illegal memory access was encountered
FilterV:        an illegal memory access was encountered
PyramidCU::GenerateFeatureList: an illegal memory access was encountered

.*_matcher fails with:

ERROR: Not enough GPU memory to match 3 features. Reduce the maximum number of matches.

even with the lowest setting for max_num_matches=3

Reference: #2125

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.