text stringlengths 0 1.47k |
|---|
# v0.2 object-pose |
"ObjectPose", |
"ObjectPoseEstimator", |
"estimate_object_pose", |
"add_metric", |
"adds_metric", |
"add_auc", |
# v0.2 camera localization |
"CameraPhotometric", |
"localize_camera", |
"coarse_localize_camera", |
# v0.3 multi-splat bundle registration |
"bundle_register", |
"pairwise_consistency", |
"BundleResult", |
# v0.3 scene-scale spatial index |
"SpatialIndex", |
"build_index", |
# v1.2 SH Wigner rotation |
"rotate_sh", |
"sh_rotation_matrix", |
# MAC maximal-clique seed (init="mac") |
"mac_pose", |
"mac_feature_align", |
] |
# ===== file: splatreg/align.py ===== |
"""Global coarse-init aligner, the basin finder that runs BEFORE the fine LM refine. |
``register`` solves splat-to-splat alignment as *coarse global init → fine multi-residual |
LM*. This module is the coarse half: given two Gaussian splats it returns a 4x4 transform |
(Sim(3) by default, SE(3) optional) that lands ``source`` inside the convergence basin of |
``target``, close enough (typically within ~10-15deg / a few % scale) that the LM finishes |
the job. It is deliberately approximate: the goal is a *good init*, not a precise pose. |
Algorithm (ported from the A/B-bench metric-side pred->GT global aligner, |
``project_ab_bench_fscore_alignment``: super-Fibonacci SO(3) candidate sweep + GPU-batched |
trimmed ICP, tuned defaults 256 rotations / 40 ICP iters / 12288 points): |
1. Centre both clouds on their centroids (``Gaussians.means``). |
2. Estimate scale as the ratio of the two clouds' RMS radius about their centroids |
(Sim(3) only; SE(3) fixes scale to 1). |
3. Seed SO(3) with a deterministic near-uniform super-Fibonacci grid (Alexa, CVPR 2022) |
plus a handful of PCA principal-axis sign-flip candidates. A ~26deg covering provably |
lands one seed in the global basin, so even featureless / symmetric clouds recover. |
4. Run *all* seeds through one GPU-batched trimmed point-to-point ICP (batched |
nearest-neighbour via ``torch.cdist`` + a batched closed-form Umeyama step each iter, |
outlier-trimmed). Score each converged seed by the trimmed symmetric Chamfer between the |
transformed source and the target. |
5. Keep the lowest-Chamfer seed and recover the exact closed-form similarity that maps the |
subsampled source onto that winner; return it as a 4x4 matrix. |
**Fully on-device (GPU-native).** Everything, the super-Fibonacci/PCA seeds, the batched ICP |
sweep, and the final closed-form Umeyama recovery, runs in torch on ``source``'s device; there |
is no ``.cpu()`` / numpy round-trip in the compute path (the final recovery is done in float64 |
on-device for SVD precision). Self-contained: torch only, no gsplat / pytorch3d / scipy / numpy |
/ SLAM imports. Deterministic, no RNG (closed-form seeds, strided subsample, first-index |
tie-break), so it is reproducible. |
""" |
from __future__ import annotations |
import math |
import torch |
from .core.types import Gaussians |
# Defaults tuned (A/B-bench) for 0 failures on the hardest case — a near-featureless sphere |
# under an arbitrary uniform-SO(3) transform. |
DEFAULT_N_ROTATIONS = 1024 # super-Fibonacci SO(3) seeds (~16deg covering); + a few PCA seeds. |
# Why 1024 (was 256): on a near-isotropic sphere shell the PCA axes are degenerate (eigenvalue |
# spread ~1.06) so the sign-flip seeds collapse to a single identity seed, and a 256-seed (~26deg) |
# covering is too coarse for any point-to-point-ICP seed to fall into the (tiny but real) correct |
# basin — every seed plateaus at Chamfer ~7 mm (a genuinely WRONG pose, not symmetry ambiguity). |
# A 1024-seed (~16deg) covering puts a seed inside that basin, driving the trimmed-ICP score from |
# 0.0056 to 0.00003 and the Chamfer to <0.06 mm at every symmetric cell. GPU-affordable (the |
# batched ICP sweep is chunked at _SEED_BATCH); verified to keep NOISE/OUTLIERS at 9/9. |
DEFAULT_ICP_ITERS = 40 # trimmed-ICP iterations per seed |
DEFAULT_N_POINTS = 12288 # deterministic strided target subsample for the fit (denser -> lower floor) |
_SUB_SOURCE = 4096 # deterministic strided source subsample driving the fit |
_ICP_TRIM_KEEP = 0.85 # fraction of best correspondences kept each iter (outlier reject) |
_SEED_BATCH = 64 # seeds processed per chunk in the batched ICP (bounds peak memory) |
_PSI = 1.533751168755204288118041 |
# ── super-Fibonacci SO(3) grid (on-device torch) ────────────────────────────────────── |
def _superfib_quats(n: int, device, dtype) -> torch.Tensor: |
"""Super-Fibonacci unit quaternions ``(n, 4)`` as ``(x, y, z, w)``, on ``device``.""" |
phi = math.sqrt(2.0) |
i = torch.arange(int(n), device=device, dtype=dtype) |
s = i + 0.5 |
t = s / float(n) |
r = torch.sqrt(t) |
rr = torch.sqrt((1.0 - t).clamp_min(0.0)) |
alpha = (2.0 * math.pi / phi) * s |
beta = (2.0 * math.pi / _PSI) * s |
return torch.stack( |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.