|
1 | 1 | # openptv-python |
2 | 2 |
|
3 | | -Python version of the OpenPTV library - this is *a work in progress* |
| 3 | +Unified Python/OpenPTV repository for the combined `openptv_python` core library and `pyptv` GUI. |
4 | 4 |
|
5 | | -## What This Repo Provides |
| 5 | +Current repository version: 0.5.0 |
6 | 6 |
|
7 | | -`openptv-python` keeps the Python API as the main interface and combines three |
8 | | -execution modes behind that API: |
| 7 | +## Overview |
9 | 8 |
|
10 | | -- **Pure Python**: the reference implementation and the easiest path for reading, |
11 | | - debugging, and extending the code. Always available as fallback. |
12 | | -- **Python + Numba**: several hot kernels are JIT-compiled automatically on first |
13 | | - use, so the Python implementation still benefits from acceleration. |
14 | | -- **Native `optv` bindings** (default): selected operations reuse the native OpenPTV |
15 | | - implementation. Installed by default on supported platforms (Linux, macOS, Windows). |
| 9 | +This repository now exposes one shared API and one shared version stream. The main pieces are: |
16 | 10 |
|
17 | | -At the moment, automatic native delegation is implemented for image |
18 | | -preprocessing and full-frame target recognition. The rest of the library keeps |
19 | | -the same Python API and remains usable even when those native paths are not in |
20 | | -use. |
| 11 | +- `openptv_python`: the Python library layer, used for pure-Python execution, Numba-accelerated kernels, and shared parameter/data handling. |
| 12 | +- `pyptv`: the GUI and batch-processing layer, built on top of the same Python API. |
| 13 | +- `optv`: native bindings used where available for delegated operations such as image preprocessing and full-frame target recognition. |
21 | 14 |
|
22 | | -If `optv` is not available on your platform, the package automatically falls back |
23 | | -to pure Python/Numba implementations without any configuration needed. |
| 15 | +The current setup is intentionally structured so that the same codebase can run in three modes: |
24 | 16 |
|
25 | | -## How this is started |
| 17 | +1. Pure Python for readability, debugging, and visual inspection. |
| 18 | +2. Pure Python plus Numba for accelerated kernels where available. |
| 19 | +3. Native `optv` delegation for selected operations when the bindings are installed. |
26 | 20 |
|
27 | | -This work started from the https://github.com/OpenPTV/openptv/tree/pure_python branch. It now serves as the single repository for the Python core library and the GUI layer. |
| 21 | +The GUI version shown in PyPTV comes from the shared version module in `src/openptv_python/version.py`. |
28 | 22 |
|
29 | | -## Supported Python Versions |
| 23 | +## Versioning |
30 | 24 |
|
31 | | -The project currently supports Python `>=3.11,<3.14`. |
| 25 | +Versioning is now centralized: |
32 | 26 |
|
33 | | -## Installation |
34 | | - |
35 | | -### Default user install |
| 27 | +- Canonical version source: [src/openptv_python/version.py](src/openptv_python/version.py) |
| 28 | +- Package version: 0.5.0 |
| 29 | +- Release boundary: this is the first combined version after merging the older `openptv_python` and `pyptv` package streams |
36 | 30 |
|
37 | | -#### Recommended: uv |
38 | | - |
39 | | -Create the environment and install the runtime dependencies: |
| 31 | +To bump the version, run: |
40 | 32 |
|
41 | 33 | ```bash |
42 | | -uv venv |
43 | | -source .venv/bin/activate |
44 | | -uv sync |
| 34 | +python src/pyptv/bump_version.py --patch |
45 | 35 | ``` |
46 | 36 |
|
47 | | -This gives you the standard runtime stack: NumPy, SciPy, Numba, YAML, and the native `optv` bindings for accelerated image preprocessing and target recognition. |
| 37 | +Use `--minor` or `--major` for larger increments. The script updates the shared version module and `pyproject.toml` together. |
| 38 | + |
| 39 | +## Installation |
48 | 40 |
|
49 | | -If you also want the GUI application, install the GUI extra: |
| 41 | +The project supports Python `>=3.11,<3.14`. |
50 | 42 |
|
51 | | -```bash |
52 | | -uv sync --extra gui |
53 | | -``` |
| 43 | +### Recommended: uv |
54 | 44 |
|
55 | | -#### Alternative: pip |
| 45 | +Runtime install: |
56 | 46 |
|
57 | 47 | ```bash |
58 | | -conda create -n openptv-python -c conda-forge python=3.12 |
59 | | -conda activate openptv-python |
60 | | -pip install . |
| 48 | +uv venv |
| 49 | +source .venv/bin/activate |
| 50 | +uv sync |
61 | 51 | ``` |
62 | 52 |
|
63 | | -Optional GUI application: |
| 53 | +GUI extras: |
64 | 54 |
|
65 | 55 | ```bash |
66 | | -pip install ".[gui]" |
| 56 | +uv sync --extra gui |
67 | 57 | ``` |
68 | 58 |
|
69 | | -### Developer install |
70 | | - |
71 | | -#### Recommended: uv |
| 59 | +Developer setup: |
72 | 60 |
|
73 | 61 | ```bash |
74 | 62 | uv venv |
75 | 63 | source .venv/bin/activate |
76 | 64 | uv sync --extra dev |
77 | 65 | ``` |
78 | 66 |
|
79 | | -#### Alternative: conda + pip |
| 67 | +### Alternative: pip |
80 | 68 |
|
81 | 69 | ```bash |
82 | 70 | conda create -n openptv-python -c conda-forge python=3.12 |
83 | 71 | conda activate openptv-python |
84 | | -pip install -e ".[dev]" |
| 72 | +pip install . |
85 | 73 | ``` |
86 | 74 |
|
87 | | -### What gets installed |
88 | | - |
89 | | -- The default install includes `optv` bindings for automatic native delegation on supported platforms (Linux, macOS, Windows). |
90 | | -- The optional `gui` extra adds the PyPTV GUI and its runtime dependencies. |
91 | | -- The optional `dev` extra adds test, docs, typing, pre-commit, and GUI tooling for contributors. |
92 | | -- If `optv` fails to install on your platform, the package falls back to pure Python/Numba implementations automatically. |
93 | | - |
94 | | -## Backend Behavior |
95 | | - |
96 | | -### Pure Python backend |
97 | | - |
98 | | -This is the base implementation for the whole library. It is always the source |
99 | | -of truth for the Python API and remains the fallback behavior for code paths |
100 | | -that are not delegated to `optv`. |
101 | | - |
102 | | -### Python + Numba backend |
103 | | - |
104 | | -Numba accelerates selected computational kernels inside the Python |
105 | | -implementation. This is automatic; there is no separate API to enable it. |
106 | | -Expect the first call to a JIT-compiled function to be slower due to |
107 | | -compilation, with later calls running faster. |
108 | | - |
109 | | -### Native `optv` backend |
110 | | - |
111 | | -When `optv` imports successfully, `openptv-python` automatically reuses native |
112 | | -implementations for: |
| 75 | +GUI extras: |
113 | 76 |
|
114 | | -- image preprocessing |
115 | | -- full-frame target recognition / segmentation |
116 | | - |
117 | | -These native paths are validated against the Python implementation by parity |
118 | | -tests, so results stay backend-independent. |
119 | | - |
120 | | -### Backend Capability Table |
121 | | - |
122 | | -| Operation | Pure Python | Python + Numba | Native `optv` | |
123 | | -| --- | --- | --- | --- | |
124 | | -| Image preprocessing | Yes | Yes | Yes, automatic delegation | |
125 | | -| Target recognition / segmentation | Yes | Yes | Yes, automatic delegation | |
126 | | -| Point reconstruction | Yes | Partial internal kernels | Not used by default | |
127 | | -| Correspondence search / stereo matching | Yes | Partial internal kernels | Not used by default | |
128 | | -| Tracking | Yes | Partial internal kernels | Not used by default | |
129 | | -| Sequence parameter I/O | Yes | No | Available in native bindings | |
130 | | - |
131 | | -`Not used by default` means the native path exists in benchmarks or conversion |
132 | | -helpers, but the regular `openptv-python` runtime path still uses the Python |
133 | | -implementation unless that operation is explicitly integrated later. |
134 | | - |
135 | | -## Getting Started |
136 | | - |
137 | | -### 1. Install the project |
138 | | - |
139 | | -Use one of the installation methods above. |
| 77 | +```bash |
| 78 | +pip install "[gui]" |
| 79 | +``` |
140 | 80 |
|
141 | | -### 2. Verify imports |
| 81 | +Developer extras: |
142 | 82 |
|
143 | 83 | ```bash |
144 | | -uv run python - <<'PY' |
145 | | -import openptv_python |
146 | | -import numba |
147 | | -import optv |
148 | | -
|
149 | | -print("optv ok", optv.__version__) |
150 | | -print("openptv_python ok") |
151 | | -print("numba ok", numba.__version__) |
152 | | -PY |
| 84 | +pip install "[dev]" |
153 | 85 | ``` |
154 | 86 |
|
155 | | -### 3. Start using the Python API |
| 87 | +## Usage |
156 | 88 |
|
157 | | -```python |
158 | | ->>> import openptv_python |
159 | | - |
160 | | -``` |
| 89 | +### Python API |
161 | 90 |
|
162 | | -### 4. Run the test suite |
| 91 | +```python |
| 92 | +import openptv_python |
163 | 93 |
|
164 | | -```bash |
165 | | -uv run make |
| 94 | +print(openptv_python.__version__) |
166 | 95 | ``` |
167 | 96 |
|
168 | | -Stress and performance tests are part of the default suite now. If you need a |
169 | | -faster validation pass locally, you can skip them explicitly: |
| 97 | +### GUI |
170 | 98 |
|
171 | 99 | ```bash |
172 | | -OPENPTV_SKIP_STRESS_BENCHMARKS=1 uv run make |
| 100 | +uv run pyptv |
173 | 101 | ``` |
174 | 102 |
|
175 | | -### Workflow for developers/contributors |
| 103 | +The GUI is versioned from the same shared source as the library. |
176 | 104 |
|
177 | | -Recommended contributor workflow with `uv`: |
| 105 | +## Documentation |
178 | 106 |
|
179 | | -```bash |
180 | | -uv venv |
181 | | -source .venv/bin/activate |
182 | | -make env-update |
183 | | -``` |
| 107 | +Detailed guides live under [docs/](docs/), especially the PyPTV guides in [docs/pyptv](docs/pyptv/README.md). |
184 | 108 |
|
185 | | -This keeps the local environment synced to the locked developer dependency set. |
| 109 | +## Testing |
186 | 110 |
|
187 | | -If you prefer the conda workflow instead: |
| 111 | +Run the focused test suites with: |
188 | 112 |
|
189 | 113 | ```bash |
190 | | -conda create -n openptv-python -c conda-forge python=3.12 |
191 | | -conda activate openptv-python |
192 | | -make conda-env-update |
| 114 | +uv run --with pytest pytest -q tests/openptv_python tests/pyptv |
193 | 115 | ``` |
194 | 116 |
|
195 | | -Before pushing to GitHub, use the developer install above and then run the |
196 | | -following commands: |
197 | | - |
198 | | -1. Update the environment: `make env-update` by default, or `make conda-env-update` if you are using the conda workflow |
199 | | -1. If you are using pip instead of uv, install the editable developer environment: `pip install -e ".[dev]"` |
200 | | -1. Sync with the latest [template](https://github.com/ecmwf-projects/cookiecutter-conda-package) (optional): `make template-update` |
201 | | -1. Run quality assurance checks: `make qa` |
202 | | -1. Run tests: `make unit-tests` |
203 | | -1. Run the static type checker: `make type-check` |
204 | | -1. Build the documentation (see [Sphinx tutorial](https://www.sphinx-doc.org/en/master/tutorial/)): `make docs-build` |
| 117 | +The repository also contains test datasets in [tests/testing_folder](tests/testing_folder/). |
205 | 118 |
|
206 | | -### License |
| 119 | +## Repository Structure |
207 | 120 |
|
208 | | -``` |
209 | | -Copyright 2023, OpenPTV consortium. |
210 | | -
|
211 | | -Licensed under the Apache License, Version 2.0 (the "License"); |
212 | | -you may not use this file except in compliance with the License. |
213 | | -You may obtain a copy of the License at |
| 121 | +- `src/openptv_python/`: shared Python library code and canonical version module |
| 122 | +- `src/pyptv/`: GUI, batch tools, and compatibility helpers |
| 123 | +- `docs/`: Sphinx documentation |
| 124 | +- `tests/`: library, GUI, and fixture tests |
214 | 125 |
|
215 | | - http://www.apache.org/licenses/LICENSE-2.0 |
| 126 | +## License |
216 | 127 |
|
217 | | -Unless required by applicable law or agreed to in writing, software |
218 | | -distributed under the License is distributed on an "AS IS" BASIS, |
219 | | -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
220 | | -See the License for the specific language governing permissions and |
221 | | -limitations under the License. |
222 | | -``` |
| 128 | +Apache License, Version 2.0. |
0 commit comments