Image#
Classes for equirectangular panoramas and perspective projections.
PanoramaImage#
PanoramaImage
#
An equirectangular panorama image.
Attributes:
| Name | Type | Description |
|---|---|---|
panorama_id |
Identifier for this panorama. |
|
loaded_image |
The panorama as PIL Image. |
|
loaded_image_array |
The panorama as numpy array. |
Initialize a panorama image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panorama_id
|
str
|
Identifier for this panorama. |
required |
image
|
Union[str, Image, ndarray]
|
Path to image file, PIL Image, or numpy array. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If image type is not supported. |
Source code in src/panoocr/image/models.py
generate_perspective_image
#
Generate a perspective projection from this panorama.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
perspective
|
PerspectiveMetadata
|
Configuration for the perspective projection. |
required |
Returns:
| Type | Description |
|---|---|
PerspectiveImage
|
PerspectiveImage with the generated projection. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the panorama image has not been loaded. |
Source code in src/panoocr/image/models.py
get_image
#
PerspectiveImage#
PerspectiveImage
#
PerspectiveImage(panorama_id: str, source_panorama_image_array: ndarray, perspective_metadata: PerspectiveMetadata)
A perspective projection from an equirectangular panorama.
Attributes:
| Name | Type | Description |
|---|---|---|
panorama_id |
Identifier for the source panorama. |
|
perspective_metadata |
Configuration for the perspective projection. |
|
perspective_image |
The generated perspective image as PIL Image. |
|
perspective_image_array |
The generated perspective image as numpy array. |
Initialize a perspective image from a panorama.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panorama_id
|
str
|
Identifier for the source panorama. |
required |
source_panorama_image_array
|
ndarray
|
The equirectangular panorama as numpy array. |
required |
perspective_metadata
|
PerspectiveMetadata
|
Configuration for the perspective projection. |
required |
Source code in src/panoocr/image/models.py
PerspectiveMetadata#
PerspectiveMetadata
dataclass
#
PerspectiveMetadata(pixel_width: int, pixel_height: int, horizontal_fov: float, vertical_fov: float, yaw_offset: float, pitch_offset: float)
Metadata for a perspective projection from an equirectangular panorama.
Attributes:
| Name | Type | Description |
|---|---|---|
pixel_width |
int
|
Width of the perspective image in pixels. |
pixel_height |
int
|
Height of the perspective image in pixels. |
horizontal_fov |
float
|
Horizontal field of view in degrees. |
vertical_fov |
float
|
Vertical field of view in degrees. |
yaw_offset |
float
|
Horizontal rotation offset in degrees (-180 to 180). |
pitch_offset |
float
|
Vertical rotation offset in degrees (-90 to 90). |
to_file_suffix
#
Generate a unique file suffix for this perspective configuration.
Source code in src/panoocr/image/models.py
to_dict
#
Convert to dictionary.
Source code in src/panoocr/image/models.py
from_dict
classmethod
#
Create from dictionary.
Source code in src/panoocr/image/models.py
Perspective Generation#
generate_perspectives
#
generate_perspectives(fov: float = 45, resolution: int = 2048, overlap: float = 0.5, pitch_angles: Optional[List[float]] = None, vertical_fov: Optional[float] = None) -> List[PerspectiveMetadata]
Generate a set of perspective views covering 360° horizontally.
This is the main API for creating custom perspective configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fov
|
float
|
Horizontal field of view in degrees (default: 45°). |
45
|
resolution
|
int
|
Pixel width and height of each perspective (default: 2048). |
2048
|
overlap
|
float
|
Overlap ratio between adjacent perspectives, 0-1 (default: 0.5). - 0.0 = no overlap (perspectives touch at edges) - 0.5 = 50% overlap (recommended for good coverage) - 1.0 = 100% overlap (each point covered by 2 perspectives) |
0.5
|
pitch_angles
|
Optional[List[float]]
|
List of pitch angles in degrees (default: [0]). Use multiple values to cover up/down, e.g., [-30, 0, 30]. |
None
|
vertical_fov
|
Optional[float]
|
Vertical field of view in degrees (default: same as fov). |
None
|
Returns:
| Type | Description |
|---|---|
List[PerspectiveMetadata]
|
List of PerspectiveMetadata objects covering the panorama. |
Examples:
>>> # Standard 45° FOV with 50% overlap (16 perspectives)
>>> perspectives = generate_perspectives(fov=45)
>>> # Wide angle for large text (8 perspectives)
>>> perspectives = generate_perspectives(fov=90, resolution=2500)
>>> # Zoomed in for small text (32 perspectives)
>>> perspectives = generate_perspectives(fov=22.5, resolution=1024)
>>> # Cover ceiling and floor too
>>> perspectives = generate_perspectives(fov=60, pitch_angles=[-45, 0, 45])
>>> # Dense coverage with 75% overlap
>>> perspectives = generate_perspectives(fov=45, overlap=0.75)
Source code in src/panoocr/image/perspectives.py
combine_perspectives
#
Combine multiple perspective lists into a single list.
Useful for multi-scale detection at different FOV settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*perspective_lists
|
List[PerspectiveMetadata]
|
Variable number of perspective lists to combine. |
()
|
Returns:
| Type | Description |
|---|---|
List[PerspectiveMetadata]
|
Combined list of all perspectives. |
Source code in src/panoocr/image/perspectives.py
Presets#
Pre-configured perspective sets:
from panoocr import (
DEFAULT_IMAGE_PERSPECTIVES,
ZOOMED_IN_IMAGE_PERSPECTIVES,
ZOOMED_OUT_IMAGE_PERSPECTIVES,
WIDEANGLE_IMAGE_PERSPECTIVES,
)
DEFAULT_IMAGE_PERSPECTIVES # 16 perspectives, 45° FOV, 2048x2048
ZOOMED_IN_IMAGE_PERSPECTIVES # 32 perspectives, 22.5° FOV, 1024x1024
ZOOMED_OUT_IMAGE_PERSPECTIVES # 12 perspectives, 60° FOV, 2500x2500
WIDEANGLE_IMAGE_PERSPECTIVES # 8 perspectives, 90° FOV, 2500x2500