Ray360
Perspective views, cubemap crosses, and seam-aware annotation mapping for stitched 360 images and video frames.
Extract perspective views for a model and map its predictions back to the sphere. Convert between equirectangular panoramas and cubemap crosses while carrying box annotations across cube faces and the panorama seam. View transforms retain the geometry through crop, resize, and letterbox operations.
Python 3.11+ · NumPy core · Optional Pillow image helpers · MIT license
Install · Quick start · API reference · Examples · Contribute
Actual Ray360 output from Jordan Pond by Matthew Petroff / Pannellum. Image credits and reproduction.
Where Ray360 fits
Stitched panorama or decoded video frame
│
▼
Ray360: extract views → crop / resize / letterbox
│
▼
Your application: run a model and collect predictions
│
▼
Ray360: map points and boxes back to the panorama
| Task | Ray360 provides |
|---|---|
| Prepare model inputs | Perspective views, full-sphere view coverage, and preprocessing |
| Convert projections | Equirectangular images ↔ named cube faces and horizontal crosses |
| Map predictions | View-space points and boxes, plus polygon outlines from cubemap cross boxes |
| Render mapped objects | Seam-split polygons, approximate rectangles, and pixel membership masks |
| Process repeated frames | Reusable coordinate maps with a bounded cache |
| Save geometry | Versioned JSON-compatible transforms, regions, and provenance |
Applications supply already-stitched pixels and own inference, video decoding, timestamps, tracking, and export formats. Ray360 does not stitch raw camera feeds or bundle a model. See the scope.
Install
Add Ray360 to a uv project:
uv add ray360
# Include image loading, saving, and overlays:
uv add "ray360[image]"
Or install with pip:
pip install ray360
pip install "ray360[image]" # Optional image helpers
The core depends only on NumPy. Model and decoder dependencies are installed separately by the application. See PyPI and the release history.
For faster sampling of contiguous uint8 images, build the optional Rust backend
from this checkout. Once installed, the same view, preprocessing, and cubemap APIs
use it for eligible inputs and fall back to NumPy for other dtypes and layouts.
Quick start
This example runs with the NumPy-only installation. Replace the synthetic array and example prediction with your stitched image and model output.
import numpy as np
from ray360 import Box2D, Panorama, Perspective
pixels = np.zeros((360, 720, 3), dtype=np.uint8)
panorama = Panorama(pixels, source_id="capture")
# yaw=180 looks across the panorama seam.
view = panorama.view(Perspective(320, 180, yaw=180, hfov=90))
model_view = view.letterbox(320, 320)
# Run your model on model_view.image. Boxes use its pixel coordinates.
predictions = [Box2D(90, 100, 230, 220, label="person", score=0.9)]
region = model_view.map_boxes(predictions)[0]
polygons = region.polygons(panorama.projection)
mask = region.rasterize(panorama.projection)
print(model_view.image.shape) # (320, 320, 3)
print(len(polygons)) # 2 pieces at the seam, still one object
print(mask.shape) # (360, 720)
region.box retains the label, score, tracking ID, and custom attributes. Crop and
resize operations also preserve the transform. Map individual points with
model_view.transform.to_panorama(points) and use its returned validity mask.
The box above is a geometry demonstration, not a model detection. Its two panorama pieces belong to the same spherical region.
Convert cube faces
import numpy as np
from ray360 import Equirectangular, Panorama, from_cubemap, to_cubemap, to_cubemap_cross
panorama = Panorama(np.zeros((360, 720, 3), dtype=np.uint8))
faces = to_cubemap(panorama, size=256)
restored = from_cubemap(faces, Equirectangular(720, 360))
cross = to_cubemap_cross(panorama, size=256)
print(sorted(faces)) # ['back', 'down', 'front', 'left', 'right', 'up']
print(restored.shape) # (360, 720, 3)
print(cross.shape) # (768, 1024, 3)
Faces are square with a 90-degree field of view. Bilinear reconstruction samples
neighboring faces at their boundaries. For model predictions on a cube face, use
panorama.view(cube_projections(size)["front"]) to retain its view transform.
See face orientation and conversion.
to_cubemap_cross() puts all six faces in one image, with top and bottom above
and below front and left, front, right, and back across the middle. To save it
with the image extra, use ray360.image.write_image("cubemap.png", cross).
Reconstruct a cubemap cross with boxes
Use the (x1, y1, x2, y2) coordinates measured on the full-size cross image.
This example uses the Back face of a cross with 1024 pixels per face.
import numpy as np
from PIL import Image
from ray360 import Equirectangular, from_cubemap_cross
from ray360.image import write_image
with Image.open("cubemap.png") as source:
cross = np.asarray(source.convert("RGB"))
image, [outline] = from_cubemap_cross(
cross,
Equirectangular(2048, 1024),
boxes=[(3350, 1410, 3820, 1735)],
draw_boxes=True,
)
write_image("panorama-with-box.png", image)
Each input box has one group of polygons, even when it crosses multiple faces or
the panorama seam. Set draw_boxes=True with the image extra to draw the
outlines. The default returns clean pixels and the same polygon groups.
Read an image and draw mapped predictions
With the image extra installed and a stitched image named stitched.jpg:
from ray360 import Box2D, Perspective
from ray360.image import overlay, read_panorama, write_image
panorama = read_panorama("stitched.jpg")
view = panorama.view(Perspective(640, 360, yaw=180))
regions = view.map_boxes([Box2D(240, 100, 400, 260, label="example")])
result = overlay(panorama.image, regions, projection=panorama.projection)
write_image("mapped.png", result)
Loading returns uint8 RGB without rotating the stored pixels. Saving refuses to
overwrite an existing file unless overwrite=True is supplied.
Video and repeated views
Decode each video frame to a panorama array in your application. Reuse a
MapCache and the same target projections across frames with matching dimensions
and orientation. panorama.views(targets, cache=cache) yields views one at a time.
The PyAV example
shows the decoder boundary and timestamp handling.
coverage_views() defaults to 24 views covering the sphere. Select view size,
field of view, and overlap using your application's accuracy and latency needs.
The default shared map cache is capped at 128 MiB; that limit covers cached maps,
not source images, output arrays, or temporary allocations.
Behavior to know
- Inputs are HW or HWC NumPy arrays. Arrays remain caller-owned, and sampling preserves their dtype. Use nearest sampling for labels, booleans, and 64-bit integers.
- Predictions wholly inside preprocessing padding are discarded; partial boxes are clipped. Ignore point coordinates whose validity mask is false.
- A spherical region remains one object even when it renders as two seam pieces.
Its exported rectangles are approximate. Use
rasterize()for membership at pixel centers. - Projection conversion resamples pixels and may lose detail. Geometry tests do not establish detector accuracy or camera calibration.
ray360.experimentalcontains sampled spherical IoU and NMS. Small objects may receive zero sampled overlap. These functions are outside the supported root API.
Ray360 is an early 0.x library. API changes will be described in the
changelog.
Examples
| Example | What it demonstrates | Dependencies |
|---|---|---|
| basic.py | A synthetic panorama, letterboxing, and a seam-crossing prediction | NumPy; Pillow for optional output |
| detect.py | Application-owned YOLO inference and prediction mapping | Image extra and Ultralytics |
| video_frames.py | Decoding stitched video frames and retaining timestamps | Image extra and PyAV |
| readme_gallery.py | Reproducing the figures on this page | Image extra and the public panorama fixture |
The validation guide includes setup commands and recorded real-image, cubemap, model, and video checks. The normal test suite never downloads media or weights. Integration fixtures are opt-in and checksum-verified.
Documentation
-
API reference: coordinates, shapes, transforms, persistence, and rendering.
-
Scope: supported use cases and criteria for new features.
-
Validation and benchmarks: what was tested and measured.
-
Release guide: maintainer publishing workflow.
Contributing and support
Start a discussion for usage questions, integration ideas, or feedback from a consuming project. Use the issue forms for reproducible bugs and concrete feature proposals.
The contribution guide covers local setup, tests, branch names, and the pull request process. Useful contributions include small geometry reproductions, clearer examples, and measurements on stitched media. Discuss new backends or annotation types before starting a large change.
Report vulnerabilities through the security policy. Ray360 is maintained by Aasman Bashyal and distributed under the MIT license.
Metadata
Release files for ray360 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ray360-0.3.0.tar.gz | 121.8 kB | Without provenance | Details for ray360-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ray360-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for ray360-0.3.0-py3-none-any.whl |
Total release size: 149.1 kB
Release files / ray360-0.3.0.tar.gz
| Download URL | ray360-0.3.0.tar.gz |
|---|---|
| Size | 121.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aafee30844ea9d39239904142a36379665dab8f583c52ab087299f3dbc5b37d9
|
|
BLAKE2b-256 checksum How to use checksums |
ffcae7bb1330d08415cd154da5abda711df27eab8d8b63f3adf060f3f079cb87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ray360-0.3.0-py3-none-any.whl
| Download URL | ray360-0.3.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f32eaa36d3842632cb0b6eced6d0f05405d9e55190c4e0557d9fdf13d1c9720
|
|
BLAKE2b-256 checksum How to use checksums |
b9a8225c7325bcd0ccdec1e1175955b2fe5a034d4cc8956cb27f473f6dd7a04b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ray360 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.