Skip to content

Preserve scan interpolation at borders and match sampling-grid dtype - #511

Open
Afloat16 wants to merge 1 commit into
cvg:masterfrom
Afloat16:fix/scan-interpolation-grid
Open

Afloat16 wants to merge 1 commit into
cvg:masterfrom
Afloat16:fix/scan-interpolation-grid

Conversation

@Afloat16

Copy link
Copy Markdown

InLoc scan interpolation rejects valid keypoints on the first/last scan pixel and constructs a float64 grid even when the scan is float32. The latter makes PyTorch grid_sample raise a scalar-type mismatch before localization can use the points.

Accept the inclusive normalized pixel bounds and convert the sampling grid to the scan tensor's dtype. Keep align_corners=True, bilinear interpolation, nearest-neighbor fallback for missing depth and outside-image rejection unchanged.

Validation on Python 3.12.14 / CPU PyTorch 2.8.0, using the actual hloc.localize_inloc module with native OpenCV, h5py and PyCOLMAP imports:

  • Unchanged master: 4 failed / 4 passed; this branch: 8 passed.
  • Affine-surface references cover float32/float64 scans and interior, corner and edge points; controls cover missing-depth fallback and outside pixels.
  • Changed-file critical Ruff checks, Python compilation and git diff --check pass.

Full localization datasets, reconstruction accuracy, GPU and complete upstream CI were not run.

`interpolate_scan` rejects valid first/last-pixel coordinates even though its align_corners=True grid represents exactly those endpoints. Normalizing float32 keypoints with a NumPy integer divisor also promotes the grid to float64, so float32 scans fail `grid_sample`'s dtype check.
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.

1 participant