Skip to content

Commit 412e332

Browse files
committed
updated optv installation by default
1 parent 47cd323 commit 412e332

7 files changed

Lines changed: 27 additions & 56 deletions

File tree

README.md

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ Python version of the OpenPTV library - this is *a work in progress*
77
`openptv-python` keeps the Python API as the main interface and combines three
88
execution modes behind that API:
99

10-
- Pure Python: the reference implementation and the easiest path for reading,
11-
debugging, and extending the code.
12-
- Python + Numba: several hot kernels are JIT-compiled automatically on first
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
1313
use, so the Python implementation still benefits from acceleration.
14-
- Native `optv` bindings: selected operations reuse the native OpenPTV
15-
implementation when the `optv` package is available.
16-
- PyPTV GUI: packaged in the same repository and installed as an optional
17-
application package.
14+
- **Native `optv` bindings** (default): selected operations reuse the native OpenPTV
15+
implementation. Installed by default on supported platforms (Linux, macOS, Windows).
1816

1917
At the moment, automatic native delegation is implemented for image
2018
preprocessing and full-frame target recognition. The rest of the library keeps
2119
the same Python API and remains usable even when those native paths are not in
2220
use.
2321

22+
If `optv` is not available on your platform, the package automatically falls back
23+
to pure Python/Numba implementations without any configuration needed.
24+
2425
## How this is started
2526

2627
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.
@@ -43,15 +44,7 @@ source .venv/bin/activate
4344
uv sync
4445
```
4546

46-
This gives you the standard runtime stack: NumPy, SciPy, Numba, and YAML
47-
support.
48-
49-
If you also want native `optv` delegation when bindings are available for your
50-
platform and Python version, install the optional extra:
51-
52-
```bash
53-
uv sync --extra native
54-
```
47+
This gives you the standard runtime stack: NumPy, SciPy, Numba, YAML, and the native `optv` bindings for accelerated image preprocessing and target recognition.
5548

5649
If you also want the GUI application, install the GUI extra:
5750

@@ -67,12 +60,6 @@ conda activate openptv-python
6760
pip install .
6861
```
6962

70-
Optional native bindings:
71-
72-
```bash
73-
pip install ".[native]"
74-
```
75-
7663
Optional GUI application:
7764

7865
```bash
@@ -99,14 +86,10 @@ pip install -e ".[dev]"
9986

10087
### What gets installed
10188

102-
- The default install contains the runtime dependencies only.
103-
- The optional `native` extra adds `optv` bindings for automatic native
104-
delegation on supported platforms.
89+
- The default install includes `optv` bindings for automatic native delegation on supported platforms (Linux, macOS, Windows).
10590
- The optional `gui` extra adds the PyPTV GUI and its runtime dependencies.
106-
- The optional `dev` extra adds test, docs, typing, pre-commit, and GUI
107-
tooling for contributors.
108-
- The public API stays the same regardless of which backend extras are
109-
installed.
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.
11093

11194
## Backend Behavior
11295

@@ -161,13 +144,9 @@ Use one of the installation methods above.
161144
uv run python - <<'PY'
162145
import openptv_python
163146
import numba
164-
try:
165-
import optv
166-
except ImportError:
167-
print("optv not installed; native delegation disabled")
168-
else:
169-
print("optv ok", optv.__version__)
147+
import optv
170148
149+
print("optv ok", optv.__version__)
171150
print("openptv_python ok")
172151
print("numba ok", numba.__version__)
173152
PY

pyproject.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ classifiers = [
1717
dependencies = [
1818
"numba>=0.64.0",
1919
"numpy>=2.4.2",
20+
"optv>=0.3.2",
2021
"pyyaml>=6.0.3",
2122
"scipy>=1.17.1"
2223
]
@@ -38,7 +39,6 @@ docs = [
3839
"sphinx-autoapi>=3.7.0"
3940
]
4041
gui = [
41-
"optv>=0.3.2",
4242
"traits>=6.4.0",
4343
"traitsui>=7.4.0",
4444
"enable>=6.1.0",
@@ -55,17 +55,13 @@ gui = [
5555
"pyparsing>=3.0.0",
5656
"marimo>=0.19.10"
5757
]
58-
native = [
59-
"optv>=0.3.2"
60-
]
6158
test = [
6259
"pytest>=9.0.2",
6360
"pytest-cov>=7.0.0"
6461
]
6562
dev = [
6663
"mypy>=1.19.1",
6764
"myst-parser>=5.0.0",
68-
"optv>=0.3.2",
6965
"pre-commit>=4.5.1",
7066
"pydata-sphinx-theme>=0.16.1",
7167
"pytest>=9.0.2",

src/pyptv/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from . import cli
1+
from .pyptv_gui import main
22

3-
cli()
3+
main()

src/pyptv/detection_gui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class DetectionGUI(HasTraits):
285285
# Buttons to apply range changes
286286
button_update_ranges = Button(label="Update Slider Ranges")
287287

288-
def __init__(self, working_directory=Path("tests/test_cavity")):
288+
def __init__(self, working_directory=Path("tests/testing_folder/test_cavity")):
289289
super(DetectionGUI, self).__init__()
290290

291291
self.working_directory = Path(working_directory)
@@ -810,7 +810,7 @@ def _button_update_ranges_fired(self):
810810
if __name__ == "__main__":
811811
if len(sys.argv) == 1:
812812
# Default to test_cavity directory
813-
working_dir = Path().absolute() / "tests" / "test_cavity"
813+
working_dir = Path().absolute() / "tests" / "testing_folder" / "test_cavity"
814814
else:
815815
# Use provided working directory path
816816
working_dir = Path(sys.argv[1])

src/pyptv/pyptv_gui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,7 @@ def main():
15301530
# Fallback to a bundled test directory if no argument is given.
15311531
# Prefer the repository copy when available, otherwise use the GUI test data.
15321532
candidate_paths = [
1533+
software_path / "tests" / "testing_folder" / "test_cavity",
15331534
software_path / "tests" / "test_cavity",
15341535
software_path / "src" / "pyptv" / "tests" / "test_cavity",
15351536
]

tests/testing_folder/test_cavity/parameters_Run1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ ptv:
130130
pix_y: 0.012
131131
tiff_flag: true
132132
splitter: false
133+
negative: false
133134
sequence:
134135
base_name:
135136
- img/cam1.%d

uv.lock

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)