Photo2Pano

Calibration-Free Cross-Modal Camera Orientation and Field-of-View Estimation by Matching Photographs to Synthetic Panoramas

Martin Kubička, Martin Čadík, Tomáš Polášek

Brno University of Technology, Faculty of Information Technology

A GeoPose3K test photo: a mountain lake mirroring the surrounding cliffs

Given a photograph and a 360° panorama rendered from a digital elevation model at the camera position, Photo2Pano estimates where the camera was looking, i.e., its yaw, pitch and roll, without knowing its field-of-view.

ground truth Photo2Pano,

Abstract

Many outdoor photos carry a location tag, yet almost none record camera orientation. Naming mountain peaks, anchoring outdoor augmented reality, verifying images, and navigating drones or autonomous vehicles all require the missing 3-DoF orientation. Existing methods match skylines, edges, or semantic segments to a panorama rendered from a digital elevation model (DEM). However, they require a known field-of-view (FoV) and fail when clouds, snow, or foreground objects hide those cues. We present Photo2Pano, a cross-modal transformer that predicts the 3-DoF orientation of an uncalibrated photo from a rendered DEM panorama. Operating without a known FoV, it remains accurate even under partial occlusion, weather, and seasonal changes. Further, we introduce the Photo2Pano dataset, pairing over 20,000 mountain photos with rendered panoramas, ground-truth poses, and FoVs for training and evaluation. Compared with baselines given a known FoV on an established benchmark, Photo2Pano reduces the best mean error almost threefold and the best median by a quarter. Moreover, an auxiliary head estimates the FoV comparably to single-image methods fine-tuned on the Photo2Pano dataset. Code, models and the dataset will be released.

Interactive demo

Ten photos of the GeoPose3K test split with the predictions of Photo2Pano. Compare the first and the second stage with the ground truth, or choose Guess and place the photo in the panorama yourself first.

YawPitchRollError

ground truth prediction your guess outside the 180° window of the second stage. Outlines are drawn with the true field-of-view. Drag the panorama to look around.

Method

Point at a part of the architecture to see its details (on a touch screen, tap it), or run a test photo through it step by step.

The panorama canvas is resampled into 32 perspective tiles of 45° × 45°. A single pretrained vision transformer, PE-Spatial-T, fine-tuned for both modalities, encodes the photo and all tiles, so that both share one embedding space. The field-of-view is never needed: the scale of the photo relative to the panorama is inferred by the attention, not imposed by resampling.

Photo and panorama tokens interact in one cross-attention layer whose weights both directions share: panorama tokens query the photo for matching structures such as ridges, peaks or valleys, and photo tokens query the panorama for the location of their content. An attention pooling summarizes each modality, and MLP heads predict distributions over 1° bins for yaw, pitch, roll and, optionally, the horizontal field-of-view.

After one pass, pitch and roll errors are small, but the yaw requires finding the photo along 360° of terrain. An optional second network of the same architecture re-estimates the orientation on a 180° window around the first-stage yaw at twice the angular resolution. It is trained on windows centred at simulated first-stage errors.

Letterbox padding

Resizing a photo to the square input with preserved aspect ratio pads it with black bars; on the GeoPose3K test split, they cover 31% of the photo tokens. A model trained without a mask gives them more attention than their share: on 40 random test photos, the padding receives 37.9% of the panorama-to-photo attention. Excluding the padding from the attention keys lowers the median error from 9.2° to 4.6° on GeoPose3K and from 8.5° to 4.2° on Venturi. With the mask, no panorama token attends to the padding, yet it still receives almost half of the attention-pooling weight; removing it from the pooling, or the mask at test time, changes the mean error on GeoPose3K by at most 0.8°.

First-stage cross-attention of the model trained without padding mask and of Photo2Pano on two GeoPose3K test photos. On the photo: attention of all panorama tokens, averaged over tokens and heads. On the panorama: attention of the photo tokens outside the padding; green: ground-truth outline of the photo. Without the mask, the attention on the photo concentrates on the padding bands. Errors of the one-stage models.

Explore the attention

Point at the photo to see where its tokens look in the panorama, or at the panorama to see which photo tokens the panorama tokens there attend to. Without the mask, much of this attention goes to the black padding bands. Click or tap a place to keep it while you look at the other image (drag over the photo to move it), and click or tap outside the images to return to the average.

Test photo resized to the input of the network, with black padding

The photo is shown as the network sees it: resized to 512 × 512 px with black padding, 32 × 32 tokens. Attention maps are scaled per map.

Results

On the GeoPose3K test split (516 photos), photo-to-terrain pipelines are very precise when they succeed but fail more often. Photo2Pano does not receive the field-of-view.

MethodMeanMedian<1°<5°<10°<20°
DUSt3Rgeneric matcher59.2946.240.01.28.926.2
MASt3Rgeneric matcher61.1446.840.01.07.824.6
MatchAnythinggeneric matcher64.9149.820.01.79.130.2
VCC-2011-m3Dour reimplementation, true FoV34.245.106.649.264.067.8
CF-VCC-2011true FoV39.303.50≈3951.654.159.5
LandscapeARtrue FoV, textured renderings––39.065.069.0*–
Photo2Pano, one stage15.974.565.251.972.181.0
Photo2Pano, one stage + FoV head19.629.221.730.652.575.8
Photo2Pano, two stages11.902.6211.874.885.589.7
Photo2Pano, two stages + FoV head15.674.375.655.873.185.9

Orientation error in degrees and accuracy in % of the photos. The generic matchers are evaluated with their released weights and do not receive the FoV. CF-VCC-2011 values are read from its published curve. LandscapeAR reports accuracies at 1°, 5° and 9° (*). With the FoV head, the model also estimates the FoV (see Field-of-view below). A constant orientation (oracle) gives 79.1° / 75.6°.

The generic matchers fail mainly in choosing the view of the panorama that shows the photo, not in matching. We matched 100 test photos with two views of their panorama. On the view rendered at the true orientation and FoV of the photo, 65.0% (MatchAnything), 87.6% (MASt3R) and 54.9% (DUSt3R) of the matches are correct. On the view that the matcher selects by its own search, only 23.2%, 0.5% and 9.4% are correct.

Our VCC-2011-m3D is very precise in yaw when it succeeds (median yaw error 1.8°), but 32% of the photos are off by more than 20°, compared with 10% for the two-stage Photo2Pano. Started from the two-stage estimate of Photo2Pano and given the true FoV, it reaches 23.9° / 4.4°. This is better than without the start (34.2° / 5.1°), but worse than the estimate it starts from (11.9° / 2.6°).

Relative to the horizontal field-of-view, the median error of the two-stage model is 5.3% on GeoPose3K and 3.1% on Venturi, i.e., the predicted outline is typically shifted by about 5% and 3% of the photo width.

Fraction of images with an orientation error below a threshold

CF-VCC-2011 and random curves digitized from Brejcha and Čadík (3DV 2018).

Venturi

CF-VCC-2011true FoV12.42
VCC-2011-m3Dtrue FoV2.88
CF-VCC-2011-m3Dtrue FoV1.92
Photo2Pano, one stage12.68
Photo2Pano, two stages7.43

Mean error over all 3,117 frames of the 12 sequences, in degrees. The pipelines with m3D verification remain more accurate on these clear-weather sequences.

Field-of-view

Constant FoVtest median, oracle13.47 / 14.39
GeoCalibfine-tuned7.33 / 9.32
VGGTfine-tuned5.32 / 6.52
AnyCalibfine-tuned4.51 / 5.34
Photo2Pano, FoV head5.40 / 7.65

Median / mean error of the horizontal FoV on GeoPose3K, in degrees. The FoV head raises the one-stage orientation error from 16.0° / 4.6° to 19.6° / 9.2°.

Limitations

Dataset and code

The Photo2Pano dataset pairs 22,654 photos of GeoPose3K, LandscapeAR and Venturi with 19,549 rendered 360° panoramas (one per Venturi sequence) and their ground-truth orientation, field-of-view and camera position. We release all pairs used in this work, without augmentation and including the 2,004 LandscapeAR pairs (12%) that we removed after inspecting all of them, with our splits. The training set has 17,017 pairs (2,594 GeoPose3K photos, including the 196 of its CH1 subset, and 14,423 LandscapeAR photos); the test sets are the GeoPose3K test split (516 photos) and Venturi (12 sequences, 3,117 frames).

<name>_query.jpg      photo, 512 × 512 px, aspect ratio kept, black padding
<name>_panorama.jpg   cylindrical 360° panorama, 4096 × 2048 px canvas
<name>_gt.csv         pitch, yaw, roll, horizontal FoV (degrees)

The code covers training, evaluation and attention maps; the three trained models of the paper (about 25 MB each) are part of the repository.

python predict.py --photo photo.jpg --pano panorama.jpg \
    --stage1 weights/photo2pano_stage1_e80.pth \
    --stage2 weights/photo2pano_stage2_e50.pth

Code on GitHub Trained models Dataset

BibTeX

Acknowledgements

This work was supported by the Ministry of Education, Youth and Sports of the Czech Republic through the e-INFRA CZ (ID:90254).