Cameras as Relative Positional Encoding

Ruilong Li, Brent Yi, Junchen Liu, Hang Gao, Yi Ma, Angjoo Kanazawa

TL;DR

This paper introduces Projective Positional Encoding (PRoPE), a method that treats full camera geometry—including both where a camera is (extrinsics) and how it sees (intrinsics)—as a relative relationship within a Transformer's attention mechanism. By moving away from absolute coordinate systems, PRoPE significantly improves the performance and generalization of multiview vision models across tasks like novel view synthesis and depth estimation.

The Challenge of 3D Perception in Transformers

Transformers are the "engine" behind many modern 3D vision tasks, but they have a fundamental limitation: they are permutation-invariant. To understand a 3D scene from multiple images, a Transformer needs to know the "position" of each visual token in 3D space.

Traditionally, researchers have used absolute encodings called "raymaps" (like Plücker coordinates), which describe each pixel's ray in a global coordinate system. However, absolute encodings are brittle; they depend on an arbitrary "world origin." If you shift that origin, the numbers change, even if the physical scene doesn't. This makes it hard for models to generalize to new environments.

Analogy between LLM positional encoding and multiview geometry

While some "relative" encodings exist, they typically only account for the camera's pose (rotation and translation). They often ignore intrinsics like focal length and field-of-view, which are crucial for real-world applications involving different cameras or zoom lenses.

Introducing PRoPE

The authors propose PRoPE (Projective Positional Encoding). Instead of telling the model where a camera is in the world, PRoPE tells the model how one camera's viewing "frustum" (the 3D cone of what it sees) relates to another.

Key technical highlights include:

  • Projective Relationships: PRoPE uses the 4x4 projective transformation matrix ($P_i P_j^{-1}$) to define the relationship between any two views. This mathematically captures both the relative movement between cameras and their respective zoom levels.
  • Attention-Level Injection: Similar to how RoPE (Rotary Positional Embedding) works in Large Language Models like Llama, PRoPE injects this geometric information directly into the self-attention blocks. This allows the model to weigh the importance of pixels from different views based on their geometric alignment.
  • Hybrid Encoding: The authors also explore "CamRay," a token-level encoding that provides local ray directions without tying them to a global coordinate frame, allowing for a "best of both worlds" approach.

Experimental Validation

The researchers evaluated PRoPE across a diverse set of benchmarks, including Novel View Synthesis (RealEstate10K and Objaverse), Stereo Depth Estimation (RGBD, SUN3D, and Scenes11), and Spatial Cognition (a custom task using the DL3DV dataset to spot "imposter" images).

Key Insights and Results

  • Frustums > Poses: The "aha moment" here is that a camera isn't just a point in space; it's a viewing volume. By encoding the relationship between these volumes (frustums) rather than just the points (poses), the model naturally understands how focal lengths affect the scene.
  • Relative is Robust: Relative encodings act as a powerful regularizer. Because the model doesn't learn to rely on a specific global origin, it becomes much better at handling "out-of-distribution" scenarios, such as seeing 16 images at test time when it was only trained on 2.
  • Intrinsics are the Missing Link: Previous relative methods struggled when focal lengths varied. PRoPE fixes this, showing that attention-level conditioning on intrinsics is vital for "intrinsic-aware" 3D reasoning.
  • Performance Leaps: On RealEstate10K, PRoPE outperformed standard Plücker raymaps significantly, raising PSNR from 20.48 to 22.80. When tested on "zoomed-in" views not seen during training, PRoPE maintained high quality while absolute raymaps saw performance tank.
  • Stereo Depth & Scaling: Integrating PRoPE into the state-of-the-art UniMatch model reduced the "Absolute Relative Error" on the RGBD dataset by roughly 15%. Furthermore, the benefits of PRoPE didn't vanish with more compute; even when scaled up 100x, the PRoPE-equipped models maintained a clear lead over traditional baselines.

Limitations and Future Work

While PRoPE is a significant step forward, the authors note a few areas for growth:

  • Numerical Stability: Very long focal lengths (telephoto lenses) can lead to ill-conditioned matrices, which might require specialized numerical handling.
  • Distortion: The current model assumes a standard pinhole camera. Extending PRoPE to handle lens distortion (like fisheye lenses) would be a valuable next step.
  • Frequency Encoding: Unlike 1D RoPE, it is currently non-trivial to incorporate "multi-frequency" encodings into PRoPE due to the non-commutative nature of 3D projective transforms.

Summary updated

BibTeX
@inproceedings{li2025cameras,
  author = {Ruilong Li and Brent Yi and Junchen Liu and Hang Gao and Yi Ma and Angjoo Kanazawa},
  title = {{Cameras as Relative Positional Encoding}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=kK8cFKu1U7},
}
Figure