panorai 1.0b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- panorai-1.0b0/PKG-INFO +355 -0
- panorai-1.0b0/README.md +301 -0
- panorai-1.0b0/panorai/__init__.py +22 -0
- panorai-1.0b0/panorai/cli/__init__.py +0 -0
- panorai-1.0b0/panorai/cli/projection_pipeline_cli.py +413 -0
- panorai-1.0b0/panorai/pipeline/__init__.py +14 -0
- panorai-1.0b0/panorai/pipeline/pipeline.py +521 -0
- panorai-1.0b0/panorai/pipeline/pipeline_data.py +167 -0
- panorai-1.0b0/panorai/pipeline/utils/__init__.py +10 -0
- panorai-1.0b0/panorai/pipeline/utils/preprocess_eq.py +224 -0
- panorai-1.0b0/panorai/pipeline/utils/resizer.py +146 -0
- panorai-1.0b0/panorai/sampler/__init__.py +12 -0
- panorai-1.0b0/panorai/sampler/base_samplers.py +241 -0
- panorai-1.0b0/panorai/sampler/default_samplers.py +22 -0
- panorai-1.0b0/panorai/sampler/registry.py +81 -0
- panorai-1.0b0/panorai/submodules/__init__.py +0 -0
- panorai-1.0b0/panorai/submodules/projections/__init__.py +3 -0
- panorai-1.0b0/panorai/submodules/projections/projection/__init__.py +26 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/__init__.py +38 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/config.py +151 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/grid.py +37 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/interpolation.py +103 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/registry.py +37 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/strategy.py +60 -0
- panorai-1.0b0/panorai/submodules/projections/projection/base/transform.py +53 -0
- panorai-1.0b0/panorai/submodules/projections/projection/default_projections.py +60 -0
- panorai-1.0b0/panorai/submodules/projections/projection/exceptions.py +33 -0
- panorai-1.0b0/panorai/submodules/projections/projection/gnomonic/__init__.py +67 -0
- panorai-1.0b0/panorai/submodules/projections/projection/gnomonic/config.py +124 -0
- panorai-1.0b0/panorai/submodules/projections/projection/gnomonic/grid.py +44 -0
- panorai-1.0b0/panorai/submodules/projections/projection/gnomonic/strategy.py +133 -0
- panorai-1.0b0/panorai/submodules/projections/projection/gnomonic/transform.py +136 -0
- panorai-1.0b0/panorai/submodules/projections/projection/logging_config.py +39 -0
- panorai-1.0b0/panorai/submodules/projections/projection/mercator/__init__.py +11 -0
- panorai-1.0b0/panorai/submodules/projections/projection/mercator/config.py +110 -0
- panorai-1.0b0/panorai/submodules/projections/projection/mercator/grid.py +41 -0
- panorai-1.0b0/panorai/submodules/projections/projection/mercator/strategy.py +58 -0
- panorai-1.0b0/panorai/submodules/projections/projection/mercator/transform.py +114 -0
- panorai-1.0b0/panorai/submodules/projections/projection/processor.py +148 -0
- panorai-1.0b0/panorai/submodules/projections/projection/registry.py +130 -0
- panorai-1.0b0/panorai/submodules/projections/projection/utils.py +137 -0
- panorai-1.0b0/panorai.egg-info/PKG-INFO +355 -0
- panorai-1.0b0/panorai.egg-info/SOURCES.txt +48 -0
- panorai-1.0b0/panorai.egg-info/dependency_links.txt +1 -0
- panorai-1.0b0/panorai.egg-info/entry_points.txt +2 -0
- panorai-1.0b0/panorai.egg-info/requires.txt +17 -0
- panorai-1.0b0/panorai.egg-info/top_level.txt +1 -0
- panorai-1.0b0/setup.cfg +4 -0
- panorai-1.0b0/setup.py +75 -0
- panorai-1.0b0/tests/test_pipeline.py +80 -0
panorai-1.0b0/PKG-INFO
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: panorai
|
|
3
|
+
Version: 1.0b0
|
|
4
|
+
Summary: A Python package for panoramic image projection and blending using Gnomonic (and other) projections.
|
|
5
|
+
Home-page: https://github.com/RobinsonGarcia/PanorAi
|
|
6
|
+
Author: Robinson Luiz Souza Garcia
|
|
7
|
+
Author-email: rlsgarcia@icloud.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/RobinsonGarcia/PanorAi/issues
|
|
10
|
+
Project-URL: Source Code, https://github.com/RobinsonGarcia/PanorAi
|
|
11
|
+
Project-URL: Documentation, https://github.com/RobinsonGarcia/PanorAi/wiki
|
|
12
|
+
Keywords: panorama,image processing,projection,gnomonic,computer vision
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
23
|
+
Classifier: Operating System :: OS Independent
|
|
24
|
+
Requires-Python: >=3.7
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: opencv-python-headless
|
|
28
|
+
Requires-Dist: scikit-image
|
|
29
|
+
Requires-Dist: scipy
|
|
30
|
+
Requires-Dist: joblib
|
|
31
|
+
Requires-Dist: pydantic>=2.0.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
35
|
+
Requires-Dist: flake8; extra == "dev"
|
|
36
|
+
Requires-Dist: black; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
40
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
41
|
+
Dynamic: author
|
|
42
|
+
Dynamic: author-email
|
|
43
|
+
Dynamic: classifier
|
|
44
|
+
Dynamic: description
|
|
45
|
+
Dynamic: description-content-type
|
|
46
|
+
Dynamic: home-page
|
|
47
|
+
Dynamic: keywords
|
|
48
|
+
Dynamic: license
|
|
49
|
+
Dynamic: project-url
|
|
50
|
+
Dynamic: provides-extra
|
|
51
|
+
Dynamic: requires-dist
|
|
52
|
+
Dynamic: requires-python
|
|
53
|
+
Dynamic: summary
|
|
54
|
+
|
|
55
|
+
# Panorai
|
|
56
|
+
|
|
57
|
+
**Panorai** is a Python package for spherical (360°) image processing, specifically focusing on sampling, projection, forward/backward transformations, and unsharp masking for panoramic or spherical data. It provides a modular pipeline to handle various steps, including:
|
|
58
|
+
|
|
59
|
+
- Resizing input images
|
|
60
|
+
- Sampling tangent points on a sphere (e.g., cube-based, Fibonacci-based)
|
|
61
|
+
- Projecting spherical images into local tangential (rectilinear) planes
|
|
62
|
+
- Re-projecting these rectilinear images back into the equirectangular space
|
|
63
|
+
- Configuring and applying unsharp masking to sharpen the projected images
|
|
64
|
+
- Logging and comparing configuration results (e.g., MSE) via an automated test suite
|
|
65
|
+
|
|
66
|
+
This README will guide you through the repository structure, installation, usage, and testing of **Panorai**.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Table of Contents
|
|
71
|
+
|
|
72
|
+
1. [Overview](#overview)
|
|
73
|
+
2. [Directory Structure](#directory-structure)
|
|
74
|
+
3. [Installation](#installation)
|
|
75
|
+
4. [Examples](#examples)
|
|
76
|
+
5. [Key Modules and Classes](#key-modules-and-classes)
|
|
77
|
+
6. [Running Tests](#running-tests)
|
|
78
|
+
7. [Extending Panorai](#extending-panorai)
|
|
79
|
+
8. [License](#license)
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Overview
|
|
84
|
+
|
|
85
|
+
**Panorai** is a Python library designed for advanced geometric transformations, projections, and sampling on spherical and equirectangular data. It provides a highly modular framework for implementing gnomonic projections, backward projections, and blending strategies, suitable for 360-degree image processing and panoramic data transformations.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Directory Structure
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
/
|
|
93
|
+
├── panorai/
|
|
94
|
+
│ ├── __pycache__/
|
|
95
|
+
│ ├── common/
|
|
96
|
+
│ │ ├── __pycache__/
|
|
97
|
+
│ │ ├── __init__.py
|
|
98
|
+
│ │ └── shared_config.py
|
|
99
|
+
│ ├── pipeline/
|
|
100
|
+
│ │ ├── __pycache__/
|
|
101
|
+
│ │ ├── utils/
|
|
102
|
+
│ │ │ ├── __pycache__/
|
|
103
|
+
│ │ │ ├── __init__.py
|
|
104
|
+
│ │ │ └── resizer.py
|
|
105
|
+
│ │ ├── __init__.py
|
|
106
|
+
│ │ ├── pipeline.py
|
|
107
|
+
│ │ ├── pipeline_data.py
|
|
108
|
+
│ │ └── pipeline_old.py
|
|
109
|
+
│ ├── projection/
|
|
110
|
+
│ │ ├── __pycache__/
|
|
111
|
+
│ │ ├── utils/
|
|
112
|
+
│ │ │ ├── __pycache__/
|
|
113
|
+
│ │ │ ├── __init__.py
|
|
114
|
+
│ │ │ ├── remapper.py
|
|
115
|
+
│ │ │ └── unsharp.py
|
|
116
|
+
│ │ ├── __init__.py
|
|
117
|
+
│ │ ├── projector.py
|
|
118
|
+
│ │ └── projector_deprecated.py
|
|
119
|
+
│ ├── readme/
|
|
120
|
+
│ │ └── gnomonic.md
|
|
121
|
+
│ ├── sampler/
|
|
122
|
+
│ │ ├── __pycache__/
|
|
123
|
+
│ │ ├── __init__.py
|
|
124
|
+
│ │ └── sampler.py
|
|
125
|
+
│ ├── __init__.py
|
|
126
|
+
├── panorai.egg-info/
|
|
127
|
+
│ ├── dependency_links.txt
|
|
128
|
+
│ ├── PKG-INFO
|
|
129
|
+
│ ├── SOURCES.txt
|
|
130
|
+
│ └── top_level.txt
|
|
131
|
+
├── tests/
|
|
132
|
+
│ ├── __pycache__/
|
|
133
|
+
│ └── test_config_params.py
|
|
134
|
+
├── .gitignore
|
|
135
|
+
├── best_configs_chart.png
|
|
136
|
+
├── requirements.txt
|
|
137
|
+
├── setup.py
|
|
138
|
+
└── test_results.db
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Notable Contents
|
|
142
|
+
|
|
143
|
+
- **panorai/**
|
|
144
|
+
Main package directory containing submodules:
|
|
145
|
+
|
|
146
|
+
- **pipeline/**: The pipeline logic for forward/backward projection and data handling, plus utility functions like `resizer`.
|
|
147
|
+
- **projection/**: Projector classes (e.g., `GnomonicProjector`) and remapping/unsharp utility code.
|
|
148
|
+
- **sampler/**: Sphere sampling strategies (cube, icosahedron, Fibonacci).
|
|
149
|
+
- **readme/**: Additional notes/documentation (e.g., gnomonic.md).
|
|
150
|
+
|
|
151
|
+
- **setup.py**
|
|
152
|
+
A setuptools-based installation script.
|
|
153
|
+
|
|
154
|
+
- **requirements.txt**
|
|
155
|
+
Lists dependencies needed to run the code (e.g., NumPy, OpenCV, etc.).
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Installation
|
|
160
|
+
|
|
161
|
+
1. Clone the Repository:
|
|
162
|
+
```bash
|
|
163
|
+
git clone https://github.com/yourusername/panorai.git
|
|
164
|
+
cd panorai
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
2. Install Dependencies:
|
|
168
|
+
```bash
|
|
169
|
+
pip install -r requirements.txt
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
3. Install Panorai (Editable Mode or Standard):
|
|
173
|
+
```bash
|
|
174
|
+
pip install -e .
|
|
175
|
+
# or
|
|
176
|
+
python setup.py install
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Examples
|
|
182
|
+
|
|
183
|
+
### 1. Data Preparation
|
|
184
|
+
|
|
185
|
+
Start by loading your input data, typically stored in an `.npz` file containing `rgb`, `depth`, and other channels.
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
import numpy as np
|
|
189
|
+
from panorai.pipeline.pipeline_data import PipelineData
|
|
190
|
+
|
|
191
|
+
# Load data from an NPZ file
|
|
192
|
+
filename = 'path/to/sample.npz' # Replace with your file path
|
|
193
|
+
arr = np.load(filename)
|
|
194
|
+
|
|
195
|
+
rgb = arr['rgb'] # Shape: (H, W, 3)
|
|
196
|
+
depth = np.sqrt(np.sum(arr['z']**2, axis=-1))[:, :, None] # Shape: (H, W, 1)
|
|
197
|
+
xyz = arr['z'] # Shape: (H, W, 3)
|
|
198
|
+
|
|
199
|
+
# Create a PipelineData instance
|
|
200
|
+
data = PipelineData.from_dict({
|
|
201
|
+
"rgb": rgb,
|
|
202
|
+
"depth": depth,
|
|
203
|
+
"xyz_depth": xyz
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 2. Preprocessing Data
|
|
208
|
+
|
|
209
|
+
Adjust for shadow angle and optionally rotate the equirectangular image:
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
from panorai.pipeline.utils.preprocess_eq import PreprocessEquirectangularImage
|
|
213
|
+
|
|
214
|
+
# Visualize the original data
|
|
215
|
+
import matplotlib.pyplot as plt
|
|
216
|
+
plt.imshow(data.data['rgb'])
|
|
217
|
+
plt.show()
|
|
218
|
+
|
|
219
|
+
# Preprocess the data (e.g., handle shadow angle)
|
|
220
|
+
data.preprocess(shadow_angle=30)
|
|
221
|
+
plt.imshow(data.data['rgb'])
|
|
222
|
+
plt.show()
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 3. Using Projections
|
|
226
|
+
|
|
227
|
+
#### 3.1. Forward Projection
|
|
228
|
+
|
|
229
|
+
Project equirectangular data into a gnomonic projection.
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from panorai.submodules.projections import ProjectionRegistry
|
|
233
|
+
|
|
234
|
+
# Access the gnomonic projection
|
|
235
|
+
proj = ProjectionRegistry.get_projection('gnomonic', return_processor=True)
|
|
236
|
+
|
|
237
|
+
# Perform forward projection
|
|
238
|
+
face = proj.forward(data.data['rgb'])
|
|
239
|
+
plt.imshow(face)
|
|
240
|
+
plt.show()
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### 3.2. Backward Projection
|
|
244
|
+
|
|
245
|
+
Reconstruct the equirectangular image from a projection:
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
# Perform backward projection
|
|
249
|
+
eq_img = proj.backward(face)
|
|
250
|
+
plt.imshow(eq_img)
|
|
251
|
+
plt.show()
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### 4. Using the ProjectionPipeline
|
|
255
|
+
|
|
256
|
+
The `ProjectionPipeline` provides a high-level API for projections.
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from panorai.pipeline.pipeline import ProjectionPipeline
|
|
260
|
+
|
|
261
|
+
# Initialize the pipeline
|
|
262
|
+
pipe = ProjectionPipeline(projection_name='gnomonic')
|
|
263
|
+
|
|
264
|
+
# Forward projection
|
|
265
|
+
face = pipe.project(data)
|
|
266
|
+
plt.imshow(face['rgb'].astype(np.uint8))
|
|
267
|
+
plt.show()
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
#### 4.1. Using Samplers
|
|
271
|
+
|
|
272
|
+
Use samplers to generate multiple projections (e.g., cube or icosahedron samplers):
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
pipe = ProjectionPipeline(projection_name='gnomonic', sampler_name='CubeSampler')
|
|
276
|
+
faces = pipe.project(data)
|
|
277
|
+
|
|
278
|
+
# Visualize a specific face
|
|
279
|
+
plt.imshow(faces['point_1']['rgb'].astype(np.uint8))
|
|
280
|
+
plt.show()
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### 4.2. Blending Projections
|
|
284
|
+
|
|
285
|
+
Blend multiple projections into a seamless equirectangular image:
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
# Reconstruct equirectangular image
|
|
289
|
+
reconstructed = pipe.backward(faces)
|
|
290
|
+
plt.imshow(reconstructed['stacked'])
|
|
291
|
+
plt.show()
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### 4.3. Custom Configurations
|
|
295
|
+
|
|
296
|
+
Modify the pipeline configuration to customize the behavior:
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
pipe = ProjectionPipeline(projection_name='gnomonic', sampler_name='IcosahedronSampler')
|
|
300
|
+
faces = pipe.project(data, subdivisions=2, fov_deg=40)
|
|
301
|
+
reconstructed = pipe.backward(faces)
|
|
302
|
+
plt.imshow(reconstructed['stacked'])
|
|
303
|
+
plt.show()
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Key Modules and Classes
|
|
309
|
+
|
|
310
|
+
1. **PipelineData**
|
|
311
|
+
A container for storing and stacking multiple image channels (e.g., `rgb`, `depth`).
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
2. **ProjectionPipeline**
|
|
315
|
+
Manages the forward/backward transformations using a chosen sampler and projector.
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
3. **Samplers**
|
|
319
|
+
- CubeSampler: Tangent points for cube-based projections.
|
|
320
|
+
- IcosahedronSampler: Icosahedron-based tangent points.
|
|
321
|
+
- FibonacciSampler: Fibonacci sphere sampling for uniform distribution.
|
|
322
|
+
|
|
323
|
+
4. **ProjectionRegistry**
|
|
324
|
+
- Project that implements the projection modules
|
|
325
|
+
https://github.com/RobinsonGarcia/projections/tree/main
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Extending Panorai
|
|
330
|
+
|
|
331
|
+
- **Add new samplers**: Implement a new class inheriting from `Sampler` and register it in `SAMPLER_CLASSES`.
|
|
332
|
+
- **Add new projectors**: Implement a new class inheriting from `ProjectionStrategy` and add it to `PROJECTOR_CLASSES`.
|
|
333
|
+
- **HF integration to handle depth estimation**: Implement seamless integration with HF to load and run DA inference
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## License
|
|
339
|
+
|
|
340
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Contact
|
|
345
|
+
|
|
346
|
+
For questions or feedback, contact the maintainers:
|
|
347
|
+
|
|
348
|
+
- **Your Name**: rlsgarcia@icloud.com
|
|
349
|
+
- **GitHub**: [https://github.com/RobinsonGarcia](https://github.com/RobinsonGarcia)
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
Enjoy using Panorai for your panoramic image processing!
|
|
354
|
+
|
|
355
|
+
|
panorai-1.0b0/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Panorai
|
|
2
|
+
|
|
3
|
+
**Panorai** is a Python package for spherical (360°) image processing, specifically focusing on sampling, projection, forward/backward transformations, and unsharp masking for panoramic or spherical data. It provides a modular pipeline to handle various steps, including:
|
|
4
|
+
|
|
5
|
+
- Resizing input images
|
|
6
|
+
- Sampling tangent points on a sphere (e.g., cube-based, Fibonacci-based)
|
|
7
|
+
- Projecting spherical images into local tangential (rectilinear) planes
|
|
8
|
+
- Re-projecting these rectilinear images back into the equirectangular space
|
|
9
|
+
- Configuring and applying unsharp masking to sharpen the projected images
|
|
10
|
+
- Logging and comparing configuration results (e.g., MSE) via an automated test suite
|
|
11
|
+
|
|
12
|
+
This README will guide you through the repository structure, installation, usage, and testing of **Panorai**.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
|
|
18
|
+
1. [Overview](#overview)
|
|
19
|
+
2. [Directory Structure](#directory-structure)
|
|
20
|
+
3. [Installation](#installation)
|
|
21
|
+
4. [Examples](#examples)
|
|
22
|
+
5. [Key Modules and Classes](#key-modules-and-classes)
|
|
23
|
+
6. [Running Tests](#running-tests)
|
|
24
|
+
7. [Extending Panorai](#extending-panorai)
|
|
25
|
+
8. [License](#license)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Overview
|
|
30
|
+
|
|
31
|
+
**Panorai** is a Python library designed for advanced geometric transformations, projections, and sampling on spherical and equirectangular data. It provides a highly modular framework for implementing gnomonic projections, backward projections, and blending strategies, suitable for 360-degree image processing and panoramic data transformations.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Directory Structure
|
|
36
|
+
|
|
37
|
+
```markdown
|
|
38
|
+
/
|
|
39
|
+
├── panorai/
|
|
40
|
+
│ ├── __pycache__/
|
|
41
|
+
│ ├── common/
|
|
42
|
+
│ │ ├── __pycache__/
|
|
43
|
+
│ │ ├── __init__.py
|
|
44
|
+
│ │ └── shared_config.py
|
|
45
|
+
│ ├── pipeline/
|
|
46
|
+
│ │ ├── __pycache__/
|
|
47
|
+
│ │ ├── utils/
|
|
48
|
+
│ │ │ ├── __pycache__/
|
|
49
|
+
│ │ │ ├── __init__.py
|
|
50
|
+
│ │ │ └── resizer.py
|
|
51
|
+
│ │ ├── __init__.py
|
|
52
|
+
│ │ ├── pipeline.py
|
|
53
|
+
│ │ ├── pipeline_data.py
|
|
54
|
+
│ │ └── pipeline_old.py
|
|
55
|
+
│ ├── projection/
|
|
56
|
+
│ │ ├── __pycache__/
|
|
57
|
+
│ │ ├── utils/
|
|
58
|
+
│ │ │ ├── __pycache__/
|
|
59
|
+
│ │ │ ├── __init__.py
|
|
60
|
+
│ │ │ ├── remapper.py
|
|
61
|
+
│ │ │ └── unsharp.py
|
|
62
|
+
│ │ ├── __init__.py
|
|
63
|
+
│ │ ├── projector.py
|
|
64
|
+
│ │ └── projector_deprecated.py
|
|
65
|
+
│ ├── readme/
|
|
66
|
+
│ │ └── gnomonic.md
|
|
67
|
+
│ ├── sampler/
|
|
68
|
+
│ │ ├── __pycache__/
|
|
69
|
+
│ │ ├── __init__.py
|
|
70
|
+
│ │ └── sampler.py
|
|
71
|
+
│ ├── __init__.py
|
|
72
|
+
├── panorai.egg-info/
|
|
73
|
+
│ ├── dependency_links.txt
|
|
74
|
+
│ ├── PKG-INFO
|
|
75
|
+
│ ├── SOURCES.txt
|
|
76
|
+
│ └── top_level.txt
|
|
77
|
+
├── tests/
|
|
78
|
+
│ ├── __pycache__/
|
|
79
|
+
│ └── test_config_params.py
|
|
80
|
+
├── .gitignore
|
|
81
|
+
├── best_configs_chart.png
|
|
82
|
+
├── requirements.txt
|
|
83
|
+
├── setup.py
|
|
84
|
+
└── test_results.db
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Notable Contents
|
|
88
|
+
|
|
89
|
+
- **panorai/**
|
|
90
|
+
Main package directory containing submodules:
|
|
91
|
+
|
|
92
|
+
- **pipeline/**: The pipeline logic for forward/backward projection and data handling, plus utility functions like `resizer`.
|
|
93
|
+
- **projection/**: Projector classes (e.g., `GnomonicProjector`) and remapping/unsharp utility code.
|
|
94
|
+
- **sampler/**: Sphere sampling strategies (cube, icosahedron, Fibonacci).
|
|
95
|
+
- **readme/**: Additional notes/documentation (e.g., gnomonic.md).
|
|
96
|
+
|
|
97
|
+
- **setup.py**
|
|
98
|
+
A setuptools-based installation script.
|
|
99
|
+
|
|
100
|
+
- **requirements.txt**
|
|
101
|
+
Lists dependencies needed to run the code (e.g., NumPy, OpenCV, etc.).
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Installation
|
|
106
|
+
|
|
107
|
+
1. Clone the Repository:
|
|
108
|
+
```bash
|
|
109
|
+
git clone https://github.com/yourusername/panorai.git
|
|
110
|
+
cd panorai
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. Install Dependencies:
|
|
114
|
+
```bash
|
|
115
|
+
pip install -r requirements.txt
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
3. Install Panorai (Editable Mode or Standard):
|
|
119
|
+
```bash
|
|
120
|
+
pip install -e .
|
|
121
|
+
# or
|
|
122
|
+
python setup.py install
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
### 1. Data Preparation
|
|
130
|
+
|
|
131
|
+
Start by loading your input data, typically stored in an `.npz` file containing `rgb`, `depth`, and other channels.
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
import numpy as np
|
|
135
|
+
from panorai.pipeline.pipeline_data import PipelineData
|
|
136
|
+
|
|
137
|
+
# Load data from an NPZ file
|
|
138
|
+
filename = 'path/to/sample.npz' # Replace with your file path
|
|
139
|
+
arr = np.load(filename)
|
|
140
|
+
|
|
141
|
+
rgb = arr['rgb'] # Shape: (H, W, 3)
|
|
142
|
+
depth = np.sqrt(np.sum(arr['z']**2, axis=-1))[:, :, None] # Shape: (H, W, 1)
|
|
143
|
+
xyz = arr['z'] # Shape: (H, W, 3)
|
|
144
|
+
|
|
145
|
+
# Create a PipelineData instance
|
|
146
|
+
data = PipelineData.from_dict({
|
|
147
|
+
"rgb": rgb,
|
|
148
|
+
"depth": depth,
|
|
149
|
+
"xyz_depth": xyz
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 2. Preprocessing Data
|
|
154
|
+
|
|
155
|
+
Adjust for shadow angle and optionally rotate the equirectangular image:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from panorai.pipeline.utils.preprocess_eq import PreprocessEquirectangularImage
|
|
159
|
+
|
|
160
|
+
# Visualize the original data
|
|
161
|
+
import matplotlib.pyplot as plt
|
|
162
|
+
plt.imshow(data.data['rgb'])
|
|
163
|
+
plt.show()
|
|
164
|
+
|
|
165
|
+
# Preprocess the data (e.g., handle shadow angle)
|
|
166
|
+
data.preprocess(shadow_angle=30)
|
|
167
|
+
plt.imshow(data.data['rgb'])
|
|
168
|
+
plt.show()
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3. Using Projections
|
|
172
|
+
|
|
173
|
+
#### 3.1. Forward Projection
|
|
174
|
+
|
|
175
|
+
Project equirectangular data into a gnomonic projection.
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from panorai.submodules.projections import ProjectionRegistry
|
|
179
|
+
|
|
180
|
+
# Access the gnomonic projection
|
|
181
|
+
proj = ProjectionRegistry.get_projection('gnomonic', return_processor=True)
|
|
182
|
+
|
|
183
|
+
# Perform forward projection
|
|
184
|
+
face = proj.forward(data.data['rgb'])
|
|
185
|
+
plt.imshow(face)
|
|
186
|
+
plt.show()
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### 3.2. Backward Projection
|
|
190
|
+
|
|
191
|
+
Reconstruct the equirectangular image from a projection:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
# Perform backward projection
|
|
195
|
+
eq_img = proj.backward(face)
|
|
196
|
+
plt.imshow(eq_img)
|
|
197
|
+
plt.show()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 4. Using the ProjectionPipeline
|
|
201
|
+
|
|
202
|
+
The `ProjectionPipeline` provides a high-level API for projections.
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from panorai.pipeline.pipeline import ProjectionPipeline
|
|
206
|
+
|
|
207
|
+
# Initialize the pipeline
|
|
208
|
+
pipe = ProjectionPipeline(projection_name='gnomonic')
|
|
209
|
+
|
|
210
|
+
# Forward projection
|
|
211
|
+
face = pipe.project(data)
|
|
212
|
+
plt.imshow(face['rgb'].astype(np.uint8))
|
|
213
|
+
plt.show()
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### 4.1. Using Samplers
|
|
217
|
+
|
|
218
|
+
Use samplers to generate multiple projections (e.g., cube or icosahedron samplers):
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
pipe = ProjectionPipeline(projection_name='gnomonic', sampler_name='CubeSampler')
|
|
222
|
+
faces = pipe.project(data)
|
|
223
|
+
|
|
224
|
+
# Visualize a specific face
|
|
225
|
+
plt.imshow(faces['point_1']['rgb'].astype(np.uint8))
|
|
226
|
+
plt.show()
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### 4.2. Blending Projections
|
|
230
|
+
|
|
231
|
+
Blend multiple projections into a seamless equirectangular image:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
# Reconstruct equirectangular image
|
|
235
|
+
reconstructed = pipe.backward(faces)
|
|
236
|
+
plt.imshow(reconstructed['stacked'])
|
|
237
|
+
plt.show()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### 4.3. Custom Configurations
|
|
241
|
+
|
|
242
|
+
Modify the pipeline configuration to customize the behavior:
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
pipe = ProjectionPipeline(projection_name='gnomonic', sampler_name='IcosahedronSampler')
|
|
246
|
+
faces = pipe.project(data, subdivisions=2, fov_deg=40)
|
|
247
|
+
reconstructed = pipe.backward(faces)
|
|
248
|
+
plt.imshow(reconstructed['stacked'])
|
|
249
|
+
plt.show()
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Key Modules and Classes
|
|
255
|
+
|
|
256
|
+
1. **PipelineData**
|
|
257
|
+
A container for storing and stacking multiple image channels (e.g., `rgb`, `depth`).
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
2. **ProjectionPipeline**
|
|
261
|
+
Manages the forward/backward transformations using a chosen sampler and projector.
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
3. **Samplers**
|
|
265
|
+
- CubeSampler: Tangent points for cube-based projections.
|
|
266
|
+
- IcosahedronSampler: Icosahedron-based tangent points.
|
|
267
|
+
- FibonacciSampler: Fibonacci sphere sampling for uniform distribution.
|
|
268
|
+
|
|
269
|
+
4. **ProjectionRegistry**
|
|
270
|
+
- Project that implements the projection modules
|
|
271
|
+
https://github.com/RobinsonGarcia/projections/tree/main
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Extending Panorai
|
|
276
|
+
|
|
277
|
+
- **Add new samplers**: Implement a new class inheriting from `Sampler` and register it in `SAMPLER_CLASSES`.
|
|
278
|
+
- **Add new projectors**: Implement a new class inheriting from `ProjectionStrategy` and add it to `PROJECTOR_CLASSES`.
|
|
279
|
+
- **HF integration to handle depth estimation**: Implement seamless integration with HF to load and run DA inference
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## License
|
|
285
|
+
|
|
286
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Contact
|
|
291
|
+
|
|
292
|
+
For questions or feedback, contact the maintainers:
|
|
293
|
+
|
|
294
|
+
- **Your Name**: rlsgarcia@icloud.com
|
|
295
|
+
- **GitHub**: [https://github.com/RobinsonGarcia](https://github.com/RobinsonGarcia)
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
Enjoy using Panorai for your panoramic image processing!
|
|
300
|
+
|
|
301
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# panorai/__init__.py
|
|
2
|
+
|
|
3
|
+
from .pipeline.pipeline import ProjectionPipeline, PipelineConfig
|
|
4
|
+
from .pipeline.pipeline_data import PipelineData
|
|
5
|
+
from .pipeline.utils.resizer import ResizerConfig
|
|
6
|
+
|
|
7
|
+
from .sampler.registry import SamplerRegistry
|
|
8
|
+
from .submodules.projections import ProjectionRegistry
|
|
9
|
+
|
|
10
|
+
__version__ = "v1.0-beta"
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
# Pipeline
|
|
14
|
+
"ProjectionPipeline",
|
|
15
|
+
"PipelineConfig",
|
|
16
|
+
"PipelineData",
|
|
17
|
+
"ResizerConfig",
|
|
18
|
+
# Sampler
|
|
19
|
+
"SamplerRegistry",
|
|
20
|
+
# Projection
|
|
21
|
+
"ProjectionRegistry",
|
|
22
|
+
]
|
|
File without changes
|