### Setup and Development Commands with uv Source: https://github.com/alexlib/openptv2/blob/main/CLAUDE.md Standard commands for setting up the environment, running tests, linting, type checking, and installing editable profiles. Always use uv, never bare python or pip. ```bash # Setup uv sync --extra dev # Run all tests (configured testpaths: tests) uv run pytest # Run a single test file uv run pytest tests/unit/test_vec_utils.py -v # Run a single test function uv run pytest tests/unit/test_vec_utils.py::test_dot -v # Run tests by marker uv run pytest -m unit uv run pytest -m "not slow" # Hot-path smoke test (tracking + correspondences) uv run pytest tests/unit/test_track.py tests/unit/test_track3d.py tests/unit/test_correspondences.py -v --tb=short # Lint uv run ruff check . # Type check uv run mypy src/openptv2/ # Editable install — three profiles: uv pip install -e . # default: headless library + openptv2-batch pipeline uv pip install -e ".[gui]" # + desktop GUI (traitsui/chaco/enable/PySide6) uv pip install -e ".[dev]" # everything: GUI, tests, lint, notebooks, docs # Cython build (required after any .py change in algorithms/) uv run python setup.py build_ext --inplace # Clean Cython rebuild (use after structural changes — new files, renames) rm -f src/openptv2/algorithms/*.c src/openptv2/algorithms/*.so rm -rf build/ uv run python setup.py build_ext --inplace # Check annotation scores (open generated HTML in browser) # annotate=True is already set in setup.py — every rebuild generates .html ``` -------------------------------- ### Install Prerequisites on Fedora/RHEL Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Installs system prerequisites for building OpenPTV2 from source on Fedora/RHEL Linux. ```bash sudo dnf install -y gcc gcc-c++ python3-devel cmake git ``` -------------------------------- ### Install Prerequisites on Ubuntu/Debian Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Installs system prerequisites for building OpenPTV2 from source on Ubuntu/Debian Linux. ```bash sudo apt-get update sudo apt-get install -y build-essential python3-dev cmake git ``` -------------------------------- ### Install OpenPTV2 with GUI Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/getting_started_tutorial.md Install OpenPTV2 with scientific dependencies using uv. This is a prerequisite for running the tutorial. ```bash uv pip install "openptv2[gui]" ``` -------------------------------- ### Install dev utilities and run local server Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/documentation_workflow.md Commands to install development documentation utilities with uv sync --extra dev and run the local MkDocs server with uv run mkdocs serve. The server runs at http://127.0.0.1:8000/ and auto-reloads on changes. ```bash # 1. Install development documentation utilities uv sync --extra dev # 2. Run the local development server uv run mkdocs serve ``` -------------------------------- ### Install with uv venv and pip (non-editable) Source: https://github.com/alexlib/openptv2/blob/main/docs/cloud-batch.md Creates a virtual environment (optionally free-threaded 3.14t) and performs a non-editable install so compiled kernel land in site-packages. Installs 18 packages and compiles extensions quickly, no GUI dependencies. ```bash uv venv --python 3.14t /opt/venv # or 3.11–3.13; 3.14t = free-threaded VIRTUAL_ENV=/opt/venv uv pip install . ``` -------------------------------- ### Verify installation with get_runtime_info() Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Run this command to verify the installation uses the precompiled Cython binary wheel. The expected JSON output shows the engine and compiled status; if "compiled" is true, the optimized binaries are active. ```bash uv run python -c "import openptv2; print(openptv2.get_runtime_info())" ``` ```json {"engine": "cython3-pure-python", "compiled": true, "package": "openptv2"} ``` -------------------------------- ### Launch guided interactive picker Source: https://github.com/alexlib/openptv2/blob/main/skills/openptv-calibrate/SKILL.md Launch the guided picker to manually click calibration points for each camera. ```bash uv run python $SK pick # or: pick --ids 2,3,71,73 ``` -------------------------------- ### Run proptv_tracking with per_tracker_overrides Source: https://github.com/alexlib/openptv2/blob/main/docs/tracker-tutorials.md Run the proptv_tracking tracker on a 30-frame window starting at frame 10001. Use per_tracker_overrides to obtain the tracker-specific overrides, then pass them to run_single_tracker. The src argument must be supplied; the example uses an ellipsis placeholder. ```python overrides = bu.per_tracker_overrides( ["proptv_tracking"], src=..., first=10001, n_frames=30 ) tracks, elapsed = bu.run_single_tracker( "proptv_tracking", track_overrides=overrides["proptv_tracking"], src=..., first=10001, ) ``` -------------------------------- ### Editable Development Installation (uv and pip) Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/packaging_and_releases.md Clone the repository and install it in editable mode for development. Option 1 uses 'uv sync --extra dev'; Option 2 uses 'pip' with the required build dependencies and the editable install with the 'dev' extra. ```bash git clone https://github.com/openptv/openptv2.git cd openptv2 # Option 1: Using 'uv' (recommended) uv sync --extra dev # Option 2: Using standard 'pip' pip install scikit-build-core cython numpy>=2.0.0 pip install -e ".[dev]" ``` -------------------------------- ### Install OpenPTV2 with GUI extra Source: https://github.com/alexlib/openptv2/blob/main/README.md Installs OpenPTV2 with the desktop GUI extra. This includes the default headless functionality plus the TraitsUI/Chaco/PySide6 desktop GUI. Launching the GUI requires this extra; a default install will fail with ModuleNotFoundError: No module named 'traitsui'. ```bash uv pip install openptv2[gui] # or pip install openptv2[gui] ``` -------------------------------- ### Install package in editable development mode (pip install -e .) Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/cython_and_pure_python.md Compiles and installs the package into the active virtual environment in editable development mode. ```bash uv pip install -e . ``` -------------------------------- ### Run priority_segment_3d tracker with benchmark_utils Source: https://github.com/alexlib/openptv2/blob/main/docs/tracker-tutorials.md Example code for running the priority_segment_3d tracker using benchmark_utils. It sets overrides via per_tracker_overrides and runs the tracker with run_single_tracker on test_data/proptv_500_30, starting at frame 10001 for 30 frames. ```python from pathlib import Path import benchmark_utils as bu overrides = bu.per_tracker_overrides( ["priority_segment_3d"], src=Path("test_data/proptv_500_30"), first=10001, n_frames=30, ) tracks, elapsed = bu.run_single_tracker( "priority_segment_3d", track_overrides=overrides["priority_segment_3d"], src=Path("test_data/proptv_500_30"), first=10001, ) ``` -------------------------------- ### Install OpenPTV2 headless/batch with uv or pip Source: https://github.com/alexlib/openptv2/blob/main/README.md Installs the headless/batch runtime of OpenPTV2 without the GUI. Use this for scripting and batch processing. The bare install includes the library and the openptv2-batch sequence and tracking pipeline, but no GUI. ```bash uv pip install openptv2 # or pip install openptv2 ``` -------------------------------- ### Backup Calibration Files Source: https://github.com/alexlib/openptv2/blob/main/notebooks/optimize_calibration.ipynb Commented-out example showing how to iterate through calibration orientation files and create backup copies. ```python # for f in calOriParams.img_ori[:4]: # print(f"Backing up {f}") # shutil.copyfile(f, f + ".bck") # g = f.replace("ori", "addpar") # shutil.copyfile(g, g + ".bck") ``` -------------------------------- ### Install with DEV_BUILD=1 for faster compilation Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/building.md Installs with lower optimization flags (bypassing slow -O3 vectorizations) for faster compile times during rapid prototyping. ```bash DEV_BUILD=1 uv pip install -e . ``` -------------------------------- ### Install OpenPTV2 from PyPI (pip and uv) Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/packaging_and_releases.md Install OpenPTV2 from PyPI. The first command installs the core tracking engine; the second adds Matplotlib GUI support via the 'gui' extra; the third shows the equivalent using the 'uv' package manager. ```bash # Install the core tracking engine pip install openptv2 # Install with Matplotlib GUI support pip install "openptv2[gui]" # Alternatively, using the fast 'uv' manager: uv pip install "openptv2[gui]" ``` -------------------------------- ### Verify OpenPTV2 installation with Python one-liners Source: https://github.com/alexlib/openptv2/blob/main/README.md Verifies the OpenPTV2 installation by importing the package and the Tracker class. Run these commands after installation to confirm the library is importable and the version is accessible. ```bash python -c "import openptv2; print(f'openptv2 version: {openptv2.__version__}')" python -c "from openptv2 import Tracker; print('Tracker imported successfully')" ``` -------------------------------- ### Example: Show Tracking Preview and Access Results Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/tracking_visualization.md Demonstrates how to show a tracking preview with 10 frames and access the average particles and linking ratio from the returned panel. The panel provides attributes avg_particles and avg_linking_ratio. ```python from gui.pyptv.tracking_viz_panel import show_tracking_preview # Show tracking preview with 10 frames panel = show_tracking_preview(main_gui, num_frames=10) # Access results print(f"Average particles: {panel.avg_particles}") print(f"Average linking ratio: {panel.avg_linking_ratio}") ``` -------------------------------- ### Install Prerequisites on macOS Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Installs macOS command line tools and optionally CMake via Homebrew for building OpenPTV2 from source. ```bash # Install command line tools xcode-select --install # Install cmake via Homebrew (optional) brew install cmake ``` -------------------------------- ### Quick Install with uv or pip Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Installs the precompiled binary wheels of OpenPTV2 with the [gui] extra, which adds Tkinter/ttkbootstrap, Matplotlib, and other scientific libraries for visualization. Omit the [gui] extra for batch tracking on a remote server. ```bash # Recommended: Install using uv for lightning fast setups uv pip install openptv2[gui] # Or using standard pip pip install "openptv2[gui]" ``` -------------------------------- ### Expected log output after parameter initialization Source: https://github.com/alexlib/openptv2/blob/main/docs/first_steps.md After selecting 'Start → Init / Reload' in the GUI, check the command-line log output for this message to confirm parameters loaded cleanly. ```text Read all the parameters and calibrations successfully ``` -------------------------------- ### Diff output example Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/parameters.md Example output of the diff command showing changed parameter values. ```text - sequence.last: 50 + sequence.last: 200 - ptv.mmp_n2: 1.33 + ptv.mmp_n2: 1.46 ``` -------------------------------- ### Launch OpenPTV2 GUI on test_cavity Source: https://github.com/alexlib/openptv2/blob/main/docs/first_steps.md Starts the OpenPTV2 graphical interface pointing directly to the cloned test_cavity folder. ```bash uv run openptv2-gui ./test_cavity ``` -------------------------------- ### Run batch with custom sequence and tracking plugins Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/batch_processing.md Example of using alternate sequence and tracking plugins (splitter_sequence and splitter_tracking) with the --sequence-plugin and --tracking-plugin flags. See the Plugins tutorial for details. ```bash uv run openptv2-batch test_data/test_splitter 1000001 1000002 \ --sequence-plugin splitter_sequence --tracking-plugin splitter_tracking ``` -------------------------------- ### Setup: define PP variable Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/parameters.md Sets up the working directory and defines the PP variable pointing to the params.py script used in subsequent commands. ```bash cd /path/to/openptv2 PP=skills/openptv-params/scripts/params.py ``` -------------------------------- ### Build from Source with pip and venv Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Creates a virtual environment, installs build-time requirements, and installs OpenPTV2 in editable mode using standard pip and venv. ```bash python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install build-time requirements pip install scikit-build-core cython "numpy>=2.0.0" # Install in development (editable) mode pip install -e ".[dev]" ``` -------------------------------- ### Build local wheels with cibuildwheel Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/building.md Installs cibuildwheel and build, then builds local wheels. The build produces source distributions and binary wheel .whl files in the dist/ folder. ```bash # Install cibuildwheel uv pip install cibuildwheel build # Build local target platforms wheels uv run python -m build ``` -------------------------------- ### Verify OpenPTV2 installation Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/building.md Verifies the installation by printing the version and runtime info. The expected output is engine: 'cython' and compiled: True. ```bash # Verify version uv run python -c "import openptv2; print(openptv2.__version__)" # Verify active compile status uv run python -c "import openptv2; print(openptv2.get_runtime_info())" ``` -------------------------------- ### Run import_calibration.py in both modes Source: https://github.com/alexlib/openptv2/blob/main/docs/plans/2026-08-30-calibration-hub-multi-source.md Two example invocations of the same script: one with --no-refine for a pure algebraic import without fitting, and one without it to perform seed plus bundle adjustment on all ~8550 points per camera. Both use placeholder paths. ```bash # pure algebraic import, zero fitting uv run python scripts/import_calibration.py --model-dir ... --no-refine --out cal_seed ``` ```bash # seed + bundle adjust on all ~8550 points per camera uv run python scripts/import_calibration.py --model-dir ... --points-dir ... --out cal_refined ``` -------------------------------- ### Snapshot-refine output example Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/calibration.md Example output from snapshot-refine showing per-camera point count, RMS before and after refinement, and flags. ```text cam1: 47 pts before=2.930px after=2.590px flags=[] ``` -------------------------------- ### 4be tracker usage example with per_tracker_overrides and run_single_tracker Source: https://github.com/alexlib/openptv2/blob/main/docs/tracker-tutorials.md Shows how to run the 4be tracker using bu.per_tracker_overrides and bu.run_single_tracker. The overrides are fetched for the '4be' tracker, then passed to run_single_tracker. The example uses src=..., first=10001, and n_frames=30. ```python overrides = bu.per_tracker_overrides(["4be"], src=..., first=10001, n_frames=30) tracks, elapsed = bu.run_single_tracker( "4be", track_overrides=overrides["4be"], src=..., first=10001 ) ``` -------------------------------- ### Call main() with output parameter Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/batch_processing.md Python API equivalent of the --output example, located at src/openptv2/batch/pyptv_batch.py:264. Passes the YAML file, frame range, mode, tracking plugin, and output name. ```python main(yaml, 1, 50, mode="tracking", tracking_plugin="two_phase", output="bench.zarr") ``` -------------------------------- ### Setup environment variables for dumbbell calibration Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/dumbbell_calibration.md Sets up the working directory and defines the DB variable pointing to the dumbbell calibration script. ```bash cd /path/to/openptv2 DB=skills/openptv-dumbbell/scripts/dumbbell.py ``` -------------------------------- ### Install and compile in editable mode Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/building.md Installs and compiles OpenPTV2 in editable mode. The first command uses uv with development extras; the second uses pip via uv. ```bash # Using uv (strongly recommended): uv sync --extra dev --all-extras # Alternatively, using pip: uv pip install -e . ``` -------------------------------- ### Install C compiler for openptv2 Source: https://github.com/alexlib/openptv2/blob/main/README.md Install the required C compiler for building openptv2 from source. The commands differ by operating system: Linux uses apt-get, macOS uses xcode-select, and Windows requires MSVC Build Tools. ```bash # Linux: sudo apt-get install build-essential # macOS: xcode-select --install # Windows: Install MSVC Build Tools ``` -------------------------------- ### Launch OpenPTV2 GUI in WSL2 Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Launch the OpenPTV2 GUI inside the WSL2 virtual environment after installing dependencies and setting up uv. ```bash uv run openptv2-gui ``` -------------------------------- ### Install openptv2 from PyPI Source: https://github.com/alexlib/openptv2/blob/main/README.md Install the openptv2 package from PyPI using either pip or uv. The uv command is recommended when using the uv package manager. ```bash pip install openptv2 ``` ```bash uv pip install openptv2 ``` -------------------------------- ### Launch calibration GUI standalone Source: https://github.com/alexlib/openptv2/blob/main/docs/tracer-self-calibration.md Alternative to launching the calibration dialog from the main pyptv2-gui. Use this command to start the calibration GUI directly with a parameters YAML file. ```bash python -m openptv2.gui.calibration_gui path/to/parameters_Run1.yaml ``` -------------------------------- ### Run interactive calibration visualization notebook Source: https://github.com/alexlib/openptv2/blob/main/docs/multi-folder-runs.md Run the interactive marimo notebook for calibration visualization. Requires the viz extra; uv run --extra viz installs it on demand. Provides an orbit-able 3D plot of camera poses and calibration body, with diagnostics table below. Also usable as a Claude Code skill. ```bash uv run --extra viz marimo -y run src/openptv2/gui/visualize_calibration_nb.py -- \ --models "current=" ``` -------------------------------- ### Install uv Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/building.md Installs the uv package manager, which is recommended for fast and reproducible virtualenv setup and package management. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Run visualize_calibration_setup.py marimo notebook Source: https://github.com/alexlib/openptv2/blob/main/skills/openptv-calibrate/SKILL.md Launches an interactive 3D setup visualization (world frame, ID-labeled calibration body, camera poses labeled by splitter quadrant) with mouse-drag rotation, plus 2D overlays. Runs directly from the checkout via marimo's -- CLI-args convention; no per-dataset copy needed. Falls back to mo.notebook_dir() if no --dataset is given. ```bash uv run marimo edit --sandbox --no-token \ skills/openptv-calibrate/scripts/visualize_calibration_setup.py \ -- --dataset "" ``` -------------------------------- ### Set up dev environment, run tests, and build docs Source: https://github.com/alexlib/openptv2/blob/main/README.md Set up the development environment with uv, run the test suite, and optionally build the documentation. The comment lines indicate where to make source changes. ```bash # Set up development environment uv sync --extra dev # Make changes to source code # Run tests pytest tests/ -v # Build documentation (optional) cd docs && make html ``` -------------------------------- ### Documentation folder structure Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/documentation_workflow.md Shows the layout of the docs/ directory at the repository root, including index, installation, first steps, tests, developer guides, tutorials, and GUI testing guide. ```text docs/ ├── index.md # Documentation home page ├── installation.md # Platform & VM setup instructions ├── first_steps.md # Quick start scripting and GUI guides ├── tests.md # Running and managing test suites ├── developer_guide/ # Developer guides │ ├── building.md # Build instructions │ ├── cython_and_pure_python.md # Pure Python vs Cython compiled mode guide │ ├── documentation_workflow.md # This guide │ └── packaging_and_releases.md # Wheel & releasing guide ├── tutorials/ # User tutorials │ ├── getting_started_tutorial.md # End-to-end tutorial │ ├── tracking_visualization.md │ └── tracking_debug_visualization.md └── HOW_TO_TEST_GUI.md # GUI testing guide ``` -------------------------------- ### Launch OpenPTV2 GUI Source: https://github.com/alexlib/openptv2/blob/main/README.md Launch the OpenPTV2 graphical interface using the pyptv_gui command. The first command starts the GUI with default settings; the second specifies a working directory. Ensure your virtual environment is activated or prefix with uv run. ```bash # Launch the GUI using the standard openptv2-gui or shorter pyptv_gui shortcut uv run pyptv_gui # Launch the GUI in the single-engine runtime uv run pyptv_gui --workdir=./test_data/test_cavity ``` -------------------------------- ### Setup: Set particle calibration script path Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/particle_calibration.md Sets the PC variable to the particle calibration script path for use in subsequent commands. ```bash cd /path/to/openptv2 PC=skills/openptv-particle-calib/scripts/particle_calib.py ``` -------------------------------- ### rig.yaml: multi-camera rig configuration Source: https://github.com/alexlib/openptv2/blob/main/docs/plans/2026-08-30-calibration-hub-multi-source.md Example rig.yaml configuration for a multi-camera setup. Each camera entry specifies position, focal length, and optional up, target, and roll. The volume_centre is the default target for all cameras. ```yaml # all distances in mm. One entry per camera, in camera order. volume_centre: [0.0, 0.0, 0.0] # default target for every camera cameras: - {position: [ 300, 200, -700], focal_mm: 50} - {position: [-300, 200, -700], focal_mm: 50} - {position: [-300, -200, -700], focal_mm: 50, up: [0, 0, 1]} - {position: [ 300, -200, -700], focal_mm: 50, target: [0, 0, 20], roll: 1.5708} ``` -------------------------------- ### Verify installation with runtime info Source: https://github.com/alexlib/openptv2/blob/main/docs/cloud-batch.md Checks that the compiled engine is accessible by importing the package and printing its runtime info. Expected output shows `compiled: true` and the engine name. ```bash /opt/venv/bin/python -c "import openptv2; print(openptv2.get_runtime_info())" # {"engine": "cython3-pure-python", "compiled": true, "package": "openptv2"} ``` -------------------------------- ### Initialize Project Configuration Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/getting_started_tutorial.md Load camera calibrations for 4 cameras from .ori and .addpar files. This is the first step in the tracking workflow. ```python from openptv2.calibration import Calibration from openptv2.parameters import TrackingParameters import os # Define workspace directory workdir = "test_data/test_cavity" # Load calibration for camera 1-4 cals = [] for cam in range(1, 5): cal = Calibration() cal.from_file( ori_file=os.path.join(workdir, f"cal/cam{cam}.ori"), addpar_file=os.path.join(workdir, f"cal/cam{cam}.addpar"), ) cals.append(cal) print(f"Loaded {len(cals)} camera calibrations successfully!") ``` -------------------------------- ### Set up experiment and load parameters Source: https://github.com/alexlib/openptv2/blob/main/tests/gui/test_rembg_contour_plugin.ipynb Initializes an Experiment, populates runs from a path, changes to the experiment directory, creates a 'res' folder if missing, reads the number of cameras, and loads processing parameters. Limits the last frame to 500 frames after the first for debugging. ```python exp_path = Path("/media/user/ExtremePro/omer/exp2") experiment = Experiment() experiment.populate_runs(exp_path) start = time.time() try: exp_path = Path(exp_path).resolve() print(f"Inside main of pyptv_batch, exp_path is {exp_path} \n") os.chdir(exp_path) print(f"double checking that its inside {Path.cwd()} \n") except Exception: raise ValueError(f"Wrong experimental directory {exp_path}") # RON - make a res dir if it not found res_path = exp_path / "res" if not res_path.is_dir(): print(" 'res' folder not found. creating one") res_path.mkdir(parents=True, exist_ok=True) # read the number of cameras with open("parameters/ptv.par", "r") as f: num_cams = int(f.readline()) cpar, spar, vpar, track_par, tpar, cals, epar = py_start_proc_c(experiment.pm) first_frame = spar.get_first() last_frame = spar.get_last() ## For debugging if last_frame - first_frame > 500: last_frame = first_frame + 500 print(f"first frame is {first_frame}") print(f"last frame is {last_frame}") # spar.set_first(first_frame) spar.set_last(last_frame) exp = { "cpar": cpar, "spar": spar, "vpar": vpar, "track_par": track_par, "tpar": tpar, "cals": cals, "epar": epar, "num_cams": num_cams, } # use dataclass to convert dictionary keys to attributes exp = AttrDict(exp) ``` -------------------------------- ### Remove virtual environment and local build artifacts Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Removes the virtual environment and any locally built Cython extensions (`.so` and `.c` files) and the `build` directory. Omit the second and third lines if you are not inside a cloned openptv2 checkout, as a plain `pip install`-only setup has no local `src/` or `build/` to clean up. ```powershell Remove-Item -Recurse -Force .venv Remove-Item -Force src\openptv2\algorithms\*.so, src\openptv2\algorithms\*.c -ErrorAction SilentlyContinue Remove-Item -Recurse -Force build -ErrorAction SilentlyContinue ``` -------------------------------- ### YAML configuration for tracking parameters Source: https://github.com/alexlib/openptv2/blob/main/docs/tracking_guide.md Example configuration for the track and plugins sections. Includes velocity search box limits (dvxmin/dvxmax, etc.), angle in gon, acceleration (dacc), and options like flagNewParticles, track_mode, postprocess, leaf_weight, min_trajectory_length, and selected_tracking. The preset 'full_multipass' is recommended for full multipass tracking. ```yaml track: preset: "full_multipass" dvxmin: -10.0 dvxmax: 10.0 dvymin: -10.0 dvymax: 10.0 dvzmin: -10.0 dvzmax: 10.0 angle: 120.0 # gon (400 gon = 360°) dacc: 5.0 # [mm/frame²] flagNewParticles: true track_mode: 0 # 0=Standard, 1=3D Segment postprocess: true leaf_weight: 1.0 # two_phase only: 2D leaf weight min_trajectory_length: 5 # seal filter: drop <5-frame traj plugins: selected_tracking: default # default, two_phase, myptv_3d_tracking, ... ``` -------------------------------- ### Initialize Calibration Environment Source: https://github.com/alexlib/openptv2/blob/main/tests/gui/calibration_with_particles.ipynb Sets up the working directory, initializes camera parameters, and identifies orientation flags. ```python # -*- coding: utf-8 -*- # copy of https://github.com/alexlib/pbi/blob/master/ptv/shake.py """ BOOM shake shake shake the room!!! Fine-tune calibration using the "shaking" method of comparing 3D positions obtained with existing calibration to their 2D projections. It's a kind of a feedback step over the normal calibration with known points. Created on Sun Jan 31 13:42:18 2016 @author: Yosef Meller """ import os from pathlib import Path import numpy as np from openptv2.gui.pyptv.parameters import OrientParams from openptv2.gui.pyptv.ptv import full_scipy_calibration, py_start_proc_c from optv.orientation import full_calibration from optv.tracking_framebuf import Frame, TargetArray present_folder = Path.cwd() working_folder = Path("/home/user/Documents/repos/test_cavity") par_path = working_folder / "parameters" working_folder.exists(), par_path.exists() # we work inside the working folder, all the other paths are relative to this num_cams = 4 os.chdir(working_folder) cpar, spar, vpar, track_par, tpar, calibs, epar = py_start_proc_c(num_cams) assert cpar.get_num_cams() == num_cams targ_files = [ spar.get_img_base_name(c).decode().split("%d")[0].encode() for c in range(num_cams) ] print(targ_files) # recognized names for the flags: NAMES = ["cc", "xh", "yh", "k1", "k2", "k3", "p1", "p2", "scale", "shear"] op = OrientParams() op.read() flags = [name for name in NAMES if getattr(op, name) == 1] print(flags) ``` ```text Output: [b'img_3/cam1.', b'img_3/cam2.', b'img_3/cam3.', b'img_3/cam4.'] [] ``` -------------------------------- ### Install NumPy for openptv2 Source: https://github.com/alexlib/openptv2/blob/main/README.md Install NumPy version 2.0.0 or later to resolve version mismatch errors during openptv2 installation. ```bash pip install numpy>=2.0.0 ``` -------------------------------- ### Manual verification: launch GUI with mock dataset Source: https://github.com/alexlib/openptv2/blob/main/docs/HOW_TO_TEST_GUI.md Launch the GUI with the mock dataset as the first step of the manual verification workflow. Use the same command as the quick launch. ```bash uv run openptv2-gui -w ./test_data/test_cavity ``` -------------------------------- ### Install dependencies inside WSL2 Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Install required system packages for OpenPTV2 GUI inside WSL2. Run these commands in the WSL2 terminal before setting up uv and installing openptv2. ```bash sudo apt-get update sudo apt-get install -y libgl1-mesa-glx libglib2.0-0 python3-tk ``` -------------------------------- ### Install OpenPTV2 from Git Source (pip) Source: https://github.com/alexlib/openptv2/blob/main/docs/developer_guide/packaging_and_releases.md Install the latest commit from the main branch directly from GitHub. The first command installs the core package; the second adds the 'gui' extra for Matplotlib support. ```bash # Standard installation pip install git+https://github.com/openptv/openptv2.git # With GUI dependencies pip install "openptv2[gui] @ git+https://github.com/openptv/openptv2.git" ``` -------------------------------- ### Run warmup with --write Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/warmup_tutorial.md Runs `openptv warmup` and persists the chosen tracker and tuned parameters back into `parameters.yaml`. ```bash uv run openptv warmup parameters.yaml --write ``` -------------------------------- ### Install rembg and onnxruntime Source: https://github.com/alexlib/openptv2/blob/main/tests/gui/test_rembg_contour_plugin.ipynb Pip install commands for rembg and onnxruntime, required for the masking functionality. ```python # %pip install rembg # %pip install onnxruntime ``` -------------------------------- ### Set up Tracking Parameters Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/getting_started_tutorial.md Load tracking physical bounds (e.g., search volume and velocity limits) from a YAML file. This step is required before tracking. ```python from openptv2.parameters import load_params_from_yaml # Load parameters params = load_params_from_yaml(os.path.join(workdir, "parameters_Run1.yaml")) print( "Velocity constraints: dvxmin =", params.track.dvxmin, "dvxmax =", params.track.dvxmax, ) ``` -------------------------------- ### Example status output Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/particle_calibration.md Example output from the status command showing per-camera RMS values. ```text cam n_pts before_rms after_rms cam1 87 2.341px 1.823px cam2 94 2.156px 1.640px cam3 91 2.498px 1.901px cam4 88 2.267px 1.712px ``` -------------------------------- ### Example output of dumbbell check Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/dumbbell_calibration.md Example output from the check command showing all fields are OK. ```text OK: dumbbell.dumbbell_scale = 46.0 (known dumbbell length (mm)) OK: dumbbell.dumbbell_penalty_weight = 1.0 (weight of length vs ray error) OK: dumbbell.dumbbell_eps = 0 (max length deviation to keep a frame (0 = keep all)) OK: dumbbell.dumbbell_step = 1 (frame stride through sequence) ``` -------------------------------- ### Launch GUI from terminal Source: https://github.com/alexlib/openptv2/blob/main/docs/HOW_TO_TEST_GUI.md Use either the command-line shortcut or direct module execution to launch the GUI with the mock dataset. Both commands specify the working directory with -w. ```bash # Using the command-line shortcut uv run openptv2-gui -w ./test_data/test_cavity ``` ```bash # Or directly running the module uv run python -m openptv2.gui.pyptv_gui -w ./test_data/test_cavity ``` -------------------------------- ### Launch GUI with experiment directory Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/parameters.md Launches the GUI with an experiment directory; the GUI will activate the first YAML it finds in alphabetical order. ```bash uv run openptv2-gui /data/exp1/ ``` -------------------------------- ### Output of experiment setup Source: https://github.com/alexlib/openptv2/blob/main/tests/gui/test_rembg_contour_plugin.ipynb The printed output from the experiment setup, showing the resolved path and frame range. ```text Output: Inside main of pyptv_batch, exp_path is /media/user/ExtremePro/omer/exp2 double checking that its inside /media/user/ExtremePro/omer/exp2 first frame is 1 last frame is 501 ``` -------------------------------- ### Install OpenPTV2 in development mode with pip Source: https://github.com/alexlib/openptv2/blob/main/README.md Sets up a virtual environment and installs OpenPTV2 in editable mode with the dev extra using pip. This is the alternative to uv for developers. The default editable install builds the Cython 3 pure-Python modules. ```bash # Create virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install build dependencies pip install setuptools cython numpy # Install in development mode pip install -e ".[dev]" ``` -------------------------------- ### Run openptv warmup with --frames and --max-cycles Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/warmup_tutorial.md Run the warmup command with a dry run (no --write) to preview tuned tracking parameters. The output shows the chosen tracker, forward/backward agreement, noise estimate, and the tuned track parameters that would be written to the YAML. Use --write to persist these values into the track block and plugins.selected_tracking. ```text $ uv run openptv warmup parameters.yaml --frames 8 --max-cycles 2 Warmup window: frames 10001-10008 (2 cycle(s)) Chosen tracker: priority_segment_3d (engine scores: {'priority_segment_3d': 6.51, 'full_multipass': 3.29}) Forward/backward agreement: 100.0% Empirical noise estimate: 2.920 mm Tuned track params: dvxmin: -13.284303841747132 dvxmax: 13.284303841747132 dvymin: -13.284303841747132 dvymax: 13.284303841747132 dvzmin: -13.284303841747132 dvzmax: 13.284303841747132 dangle: 120.0 dacc: 13.284303841747132 add: 1 Dry run (pass --write to persist into the YAML) ``` -------------------------------- ### Install Cython for openptv2 Source: https://github.com/alexlib/openptv2/blob/main/README.md Install Cython version 3.0.0 or later, which is required for building the Cython extensions in openptv2. ```bash pip install cython>=3.0.0 ``` -------------------------------- ### Run tutorial snapshot generator script Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/getting_started_tutorial.md Execute this command to run the reference tutorial snapshot generator script. It loads camera calibrations, reads TIFF images and 2D targets, loads 3D trajectories, projects them back to 2D, and saves high-resolution figures under docs/tutorials/images/. ```bash uv run python docs/tutorials/generate_tutorial_snapshots.py ``` -------------------------------- ### Install display-rendering dependencies on remote VM Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Install required packages on the remote VM for X11 forwarding and GUI rendering. ```bash sudo apt-get install -y x11-apps mesa-utils libgl1-mesa-glx python3-tk ``` -------------------------------- ### Example dry-run output Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/dumbbell_calibration.md Example output from a dry run. A good result shows RMS decreasing and a reasonable fraction of frames used. ```text Dumbbell calibration: /path/to/parameters.yaml Result: Frames used: 42 / 100 RMS before (px): 2.3410 RMS after (px): 1.1852 Improvement: +1.1558 px (dry-run: no files written) ``` -------------------------------- ### Synchronize and Build with uv Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Compiles the underlying C library, compiles the Cython bindings, and places the modules inside the virtual environment using uv. ```bash uv sync --extra dev ``` -------------------------------- ### Install OpenPTV2 build dependencies on Fedora/RHEL Source: https://github.com/alexlib/openptv2/blob/main/README.md Installs system build dependencies for OpenPTV2 on Fedora/RHEL Linux. Required to compile the Cython 3 extensions. ```bash sudo dnf install -y gcc gcc-c++ python3-devel ``` -------------------------------- ### Run local preflight quality gate with run_batch_experiment.py --sample-only Source: https://github.com/alexlib/openptv2/blob/main/docs/aorta_tutorial.md Runs a 10-frame preflight quality gate check locally in under 6 seconds before submitting long-running jobs to the cloud. The check requires at least 10 particles matched per frame (min_matches_per_frame: 10) and at least 10 active 3D links generated (min_tracks_created: 10). ```powershell $env:OPENPTV_STORAGE="zarr_only" uv run --project C:\Users\alex\projects\openptv2 python run_batch_experiment.py --sample-only ``` -------------------------------- ### Install OpenPTV2 build dependencies on Debian/Ubuntu Source: https://github.com/alexlib/openptv2/blob/main/README.md Installs system build dependencies for OpenPTV2 on Debian/Ubuntu Linux. Required to compile the Cython 3 extensions. ```bash sudo apt-get update sudo apt-get install -y build-essential python3-dev ``` -------------------------------- ### Inspect, detect targets, and initialize a fresh dataset Source: https://github.com/alexlib/openptv2/blob/main/skills/openptv-calibrate/SKILL.md Run these commands in order to prepare a dataset with no prior calibration. The inspect command names all three gaps, detect_targets.py runs the same detection as the GUI's Detection button, and init writes a naive default .ori/.addpar per camera. Always check run --dry-run's matched count because a converged-but-wrong pose is silent. ```bash uv run python $SK inspect --output /tmp/inspect.json # names all 3 gaps uv run python skills/openptv-calibrate/scripts/detect_targets.py # targets uv run python $SK init # initial guess # then step 2 (seed) below, then step 3 (run) ``` -------------------------------- ### Run calibration with calib.py (inspect, run, suggest-eps0) Source: https://github.com/alexlib/openptv2/blob/main/skills/openptv-calibrate/SKILL.md Run the calibration script from the openptv2 checkout with `uv run`. The `inspect` command writes a JSON report, `run` performs calibration, and adding `--suggest-eps0` sweeps the epipolar band to recommend the `criteria.eps0` that maximizes correct 4-camera quadruplets with zero spurious matches. ```bash SK=skills/openptv-calibrate/scripts/calib.py uv run python $SK inspect --output /tmp/inspect.json uv run python $SK run --output /tmp/calib.json uv run python $SK run --output /tmp/calib.json --suggest-eps0 ``` -------------------------------- ### Install and use xvfb for headless GUI scripts Source: https://github.com/alexlib/openptv2/blob/main/docs/installation.md Install xvfb on Debian/Ubuntu and run GUI-bound automated scripts or tests on headless servers using a virtual framebuffer. ```bash # Install xvfb on Debian/Ubuntu VM sudo apt-get install -y xvfb # Run with virtual framebuffer xvfb-run -a uv run python scripts/run_all_tests.py ``` -------------------------------- ### Install macOS build tools for OpenPTV2 Source: https://github.com/alexlib/openptv2/blob/main/README.md Installs the Xcode Command Line Tools on macOS, which provides the C compiler needed to build OpenPTV2's Cython extensions. ```bash xcode-select --install ``` -------------------------------- ### Set up environment and script path Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/calibration.md Sets the working directory to the openptv2 checkout and defines the SK variable pointing to the calib.py script. All commands must be run from this directory using uv run. ```bash cd /path/to/openptv2 SK=skills/openptv-calibrate/scripts/calib.py ``` -------------------------------- ### Illmenau calibration recipe: detect, fit cc, write .ori, gate, bundle, validate Source: https://github.com/alexlib/openptv2/blob/main/docs/illmenau-4cam-calibration.md Run the full Illmenau calibration recipe from the working folder. Steps 1-3 and 5 change the calibration; steps 4, 6, and 7 only measure it. Step 1 is cached, so re-running steps 2-5 with a different cc costs seconds; after step 5, re-run step 1 once because the labeller uses the .ori for its up-hint and a better calibration can rescue previously mislabelled frames. ```bash cd "$ILLMENAU_DIR" # --- 1. DETECT + LABEL every frame of all four cameras, cached to npz. # ~192 images, a few minutes -> cal/labelled_all_frames.npz. Hands the labeller # the two things one image cannot settle: the datum's grid index, and the image # direction of world +Y from the current .ori (section 9). On a brand-new rig # with no .ori yet, run once with ILLMENAU_NO_HINT=1, then re-run after step 3. uv run --project $OPTV python $OPTV/scripts/illmenau/detect_plate_frames.py # --- 2. FIT the one shared cc, from multi-plane cross-camera consistency. # The only quantity a single plane cannot see (section 4, Trap 2). uv run --project $OPTV --with opencv-python-headless \ python $OPTV/scripts/illmenau/fit_plate_cc.py # --- 3. WRITE the .ori: pure pinhole at that cc, poses from the reference # frame, zero distortion in .addpar (section 4, Trap 1). uv run --project $OPTV --with opencv-python-headless \ python $OPTV/scripts/illmenau/refit_plate_pinhole.py 8.5858 # --- 4. GATE. These two decide whether the calibration is usable. Never gate # on per-camera reprojection RMS -- it stayed at 0.5 px through every wrong # intermediate result of this work. uv run --project $OPTV python $OPTV/scripts/illmenau/check_plate_triangulation.py uv run --project $OPTV python $OPTV/scripts/illmenau/check_epipolar.py # --- 5. BUNDLE: re-solve all camera poses together with one plate pose per # frame, so the model is no longer exact on the reference plane and drifting # away from it (section 8b). cc stays fixed; the reference plate pose is the # gauge. Omit --write for a dry run that changes nothing. uv run --project $OPTV --with opencv-python-headless \ python $OPTV/scripts/illmenau/bundle_plate_poses.py 8.5858 --write # --- 6. RE-GATE (step 4 again), then validate over the whole dataset and look # at the pictures. plot_frame_triangulation.py fits nothing: it shows what the # .ori on disk actually reconstruct, one figure per plate position. uv run --project $OPTV python $OPTV/scripts/illmenau/check_plate_triangulation.py uv run --project $OPTV python $OPTV/scripts/illmenau/check_epipolar.py uv run --project $OPTV python $OPTV/scripts/illmenau/plot_frame_triangulation.py uv run --project $OPTV python $OPTV/scripts/illmenau/check_all_frames.py # --- 7. SET THE OBSERVATION VOLUME before opening the GUI (section 6). # Reports the largest safe Zmax for this rig; it is a display and search # parameter, not a calibration one, and the usual cause of "the epipolar lines # are wrong". uv run --project $OPTV python $OPTV/scripts/illmenau/check_epipolar_volume.py # --- optional: draw the rig against the global frame, as a sanity check that # the cameras came out where they physically are. uv run --project $OPTV python $OPTV/scripts/illmenau/draw_rig_global.py ``` -------------------------------- ### Build and run openptv2-cloud Docker image (Dockerfile.cloud) Source: https://github.com/alexlib/openptv2/blob/main/docs/cloud-batch.md Build the cloud Docker image and run zero-data smoke tests on the baked demos (test_cavity default pipeline, test_splitter with splitter plugins) plus a command for your own data mounted at /data. The image leaves the GIL enabled by default; add -e PYTHON_GIL=0 to force it off. ```bash docker build -f Dockerfile.cloud -t openptv2-cloud . # zero-data smoke test on the baked demo (default pipeline): docker run --rm openptv2-cloud sh -c \ "cp -r /demo/test_cavity /tmp/c && cd /tmp/c && \ openptv2-batch parameters_Run1.yaml 10001 10004" # zero-data smoke test of a non-default plugin (image-splitter dataset): docker run --rm openptv2-cloud sh -c \ "cp -r /demo/test_splitter /tmp/s && cd /tmp/s && \ openptv2-batch parameters_Run1.yaml 1000001 1000002 \ --sequence-plugin splitter_sequence --tracking-plugin splitter_tracking" # your own data (mounted at /data): docker run --rm -v "$PWD:/data" openptv2-cloud \ openptv2-batch /data//parameters_Run1.yaml ``` -------------------------------- ### Launch GUI with explicit YAML file Source: https://github.com/alexlib/openptv2/blob/main/docs/tutorials/parameters.md Launches the GUI with a specific YAML file so the GUI knows which run to activate on startup. This is the recommended invocation. ```bash uv run openptv2-gui /data/exp1/parameters_Run3.yaml ``` -------------------------------- ### Example track: and criteria: parameters from test_data/test_cavity parameters_Run1.yaml Source: https://github.com/alexlib/openptv2/blob/main/docs/tracker-tutorials.md A real-world example of the shared track: fields (dvxmax, dvymax, dvzmax, dacc, angle) and criteria: eps0 from a committed parameters_Run1.yaml. The dacc/dvxmax ratio is 0.4, matching the 'densely seeded' end of the guidance. angle is in gon (120 gon = 108°). ```yaml track: dvxmax: 0.6 # mm/frame dvymax: 0.6 dvzmax: 0.6 dacc: 0.24 # mm (ratio dacc/dvxmax = 0.4 -- exactly the "densely # seeded" end of the guidance above) angle: 120.0 # gon criteria: eps0: 0.05 # mm -- correspondence-stage epipolar tolerance, # see §6 ```