Skip to content

© 2026 Rami Kronbi · Beirut, Lebanon

Back
Computer vision

360° spherical panorama stitching

Turns one handheld phone sweep into a 360° panorama you can walk around in a browser.

My partBuilt solo

The second version, on a simulated sweep. Frames are first placed with the integrated gyro, then bundle adjustment solves all orientations and the focal length together. Mean rotation error: gyro 2.01°, pairwise chain 1.35°, bundle adjusted 0.04°.

In short

A CPU-only Python and OpenCV pipeline that turns handheld phone video or stills into an equirectangular panorama and generates a Three.js viewer.

What it is
A CPU-only Python and OpenCV pipeline that turns handheld phone video or stills into an equirectangular panorama and generates a self-contained Three.js viewer.
Why it matters
General-purpose stitchers hide the geometric decisions behind a single call, which makes it hard to explain why a panorama tilts, ghosts, or drifts under real handheld capture.
My part
I built the pipeline, the viewer, the 186 tests, and the technical documentation on my own.
Full equirectangular panorama reconstructed from a handheld phone sweep of an interior room.
Equirectangular panorama recovered from a 309-frame phone sweep. 4096 × 2048 output; 36.9% of the sphere imaged.

Step by step

  1. 1

    Extract

    Frames are pulled from a phone video by interval, count, frame rate, or measured motion. Camera intrinsics come from EXIF when available, otherwise from an explicit field of view or calibration file.

    A single extracted phone-video frame that becomes an input to the pipeline.
    Extract — one frame pulled from the phone video.
  2. 2

    Match

    ORB features are matched between adjacent frames, filtered with Lowe’s ratio test, and validated by RANSAC. If an adjacent pair fails, the matcher tries across the gap and interpolates the missing step rather than silently discarding the frame.

    A pair of adjacent frames with ORB feature matches drawn between them.
    Match — ORB matches that survive Lowe’s ratio and RANSAC.
  3. 3

    Rotate

    The relative rotation is recovered from R = K⁻¹HK under a pure-rotation model. Numerical noise means the matrix is rarely a perfect rotation, so singular-value decomposition projects it back onto the rotation manifold before chaining.

    Side-by-side close-up where the end of a simulated sweep meets its start: misaligned and doubled without bundle adjustment, continuous with it.
    Simulated: where the sweep meets its start, chaining leaves a 2.09° break; after bundle adjustment it is 0.03°.
  4. 4

    Warp

    Each source frame is inverse-warped onto an equirectangular canvas. Each output pixel is a world direction; that direction is rotated into the camera, projected onto the image plane, and sampled.

    A mosaic of intermediate stitched frames laid onto the equirectangular canvas.
    Rotate and warp — every frame placed on the equirectangular canvas by its chained rotation, before smoothing.
  5. 5

    Blend

    Overlaps are blended, multiband, feathered, or sharp, and the parts of the sphere the sweep never saw are inpainted from their surroundings.

    View — the reconstructed geometry in the Three.js viewer.
  6. 6

    Smooth

    A moving average over the chained global rotations damps per-pair pitch and roll wobble. It is deliberately simple: not bundle adjustment, loop closure, or exposure matching.

    Side-by-side comparison of the panorama with and without temporal smoothing.
    Smooth — long horizontal edges before and after.
    Log-scale plot of rotation error per frame against ground truth for gyro only, pairwise chaining and bundle adjustment on a simulated 73-frame sweep.
    Simulated: the gyro drifts to 4.3° by the last frame and pairwise chaining ends 2.1° off; bundle adjustment stays under 0.14° throughout.
  7. 7

    View

    The final 4096 × 2048 panorama is served through a self-contained Three.js viewer that makes the recovered geometry directly inspectable in a browser.

    The recovered panorama shown as a horizontal band, illustrating incomplete spherical coverage.
    The captured band is only about 37% of the full sphere.

Results

0.04°
Rotation error, v2
mean, bundle adjusted, on a simulated 73-frame sweep; 2.01° gyro only, 1.35° pairwise chaining
309
Sample frames
phone video, single handheld sweep
333°
Recovered sweep
from a horizontal pan
921
Median RANSAC inliers
per adjacent pair
15 of 308
Interpolated pairs
recovered across a gap
36.9%
Sphere imaged
phone-height horizontal band
4096 × 2048
Output resolution
equirectangular
~2 minutes
End-to-end time
Ryzen 7 5800H, CPU only
13.5×
Pitch wobble reduction
temporal smoothing, on the sample run
5.2×
Roll wobble reduction
temporal smoothing, on the sample run
For engineersHow it is built, its limits, and its keywords.

How it works

Frames are extracted, matched with ORB features and RANSAC, related by homography under a pure-rotation camera model, projected back onto a sphere, and rendered in a browser viewer. Temporal smoothing damps the pitch and roll wobble left after per-pair estimation. A second version uses a gyro to guide matching and find loop closures, then bundle-adjusts every orientation and the focal length at once; so far it runs on simulated sweeps.

Limits

  • Pure-rotation camera model — translation while sweeping introduces parallax that no homography can explain.
  • A phone-height horizontal sweep sees a band around the viewer, so the poles are never captured; filling is not reconstruction.
  • Blank walls and repeated textures weaken ORB matching and can force interpolation.
  • The phone pipeline has no bundle adjustment or loop closure; drift is damped rather than corrected. The gyro-guided, bundle-adjusted version has only run on simulated data: no lens distortion, rolling shutter, or camera-gyro time offset, and a real capture would need a synced sensor log.
  • No exposure matching; brightness changes remain visible across seams.

Keywords

  • panorama stitching
  • equirectangular projection
  • OpenCV
  • ORB features
  • RANSAC
  • temporal smoothing
  • Three.js viewer

Read the write-up →