OpenPTV - framework for particle tracking velocimetry
The OpenPTV project consists of two main components:
- liboptv - The core C library implementing the particle tracking algorithms
- py_bind - Python bindings for the C library
- Python 3.10 or newer
- CMake 3.15 or newer
- C compiler (gcc, clang, or MSVC)
- pip
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install build dependencies:
python -m pip install --upgrade pip
python -m pip install build numpy cython
- Build and install:
cd py_bind
python setup.py prepare
pip install -e .
- Verify installation:
cd py_bind/test
python -m pytest
You can also install the pre-built wheels from PyPI:
pip install optv
The Python tests are located in the py_bind/test
directory and should be run from within that directory:
cd py_bind/test
python -m pytest # Run all tests
python -m pytest test_version.py # Run a specific test file
python -m pytest -v # Run with verbose output
The C library tests use the Check framework and can be run in several ways:
- Run all tests with debug output:
cd liboptv
mkdir -p build && cd build
cmake ../
CK_FORK=no CK_VERBOSITY=verbose ctest -V
- Run a specific test (e.g., check_track) with debug output:
CK_FORK=no CK_VERBOSITY=verbose ctest -V -R check_track
- Run a single test case with maximum debug information:
CTEST_OUTPUT_ON_FAILURE=1 CK_FORK=no CK_VERBOSITY=verbose CK_RUN_CASE="test_single_particle_track" ctest --output-on-failure -VV -R check_track
Environment variables explained:
CK_FORK=no
: Prevents Check from forking processes, ensuring all output is visibleCK_VERBOSITY=verbose
: Enables verbose output from Check frameworkCK_RUN_CASE
: Specifies a single test case to runCTEST_OUTPUT_ON_FAILURE=1
: Shows output for failed tests
You can build wheels for distribution using cibuildwheel:
# Install cibuildwheel
pip install cibuildwheel
# Build wheels for the current platform
python -m cibuildwheel --output-dir wheelhouse py_bind/
# Build wheels for a specific Python version
python -m cibuildwheel --output-dir wheelhouse py_bind/ --only cp310-*
The project includes a GitHub Actions workflow that automatically builds wheels for multiple platforms when tags are pushed.
If you encounter build issues, clean the build artifacts and try again:
cd py_bind
rm -rf build/
rm -rf *.egg-info/
rm -rf dist/
rm -rf optv/optv
find . -name "*.so" -o -name "*.c" | xargs rm -f
from optv.tracking_framebuf import Target
from optv.tracker import Tracker
from optv.calibration import Calibration
cd liboptv
mkdir build && cd build
cmake ../
sudo make install
make verify
Please consider donation to support our website and domain expenses and our developers during their job transitions.