Image-guided surgery functions, in C++, using OpenCV, wrapped in Python.
Part of the SNAPPY software project, developed at the Wellcome EPSRC Centre for Interventional and Surgical Sciences, University College London (UCL).
- Stereo triangulation (Hartley/Zisserman SVD method and midpoint-of-shortest-distance)
- Calibration dot/fiducial detection
- Point masking utilities
pip install scikit-surgeryopencvcppRequires CMake 3.15+ and a C++17 compiler. All dependencies (OpenCV, pybind11) are fetched automatically via CMake FetchContent.
pip install build
python -m build --wheelThis produces a wheel in dist/ that you can install with:
pip install dist/scikit_surgeryopencvcpp-*.whlFor a faster development cycle (reuses your existing build artifacts):
pip wheel . -v --no-build-isolationcmake -B build -DBUILD_TESTING=ON -DBUILD_PYTHON_BINDINGS=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
ctest --test-dir build --build-config Release --output-on-failureRequires NumPy and pybind11 in your environment:
pip install numpy pybind11
cmake -B build -DBUILD_TESTING=ON -DBUILD_PYTHON_BINDINGS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
ctest --test-dir build --build-config Release --output-on-failureimport numpy as np
import sksurgeryopencvpython as sks
# Triangulate stereo point pairs
points_3d = sks.triangulate_points_using_hartley(
image_points, # Nx4 array (left_x, left_y, right_x, right_y)
left_intrinsics, # 3x3 camera matrix
right_intrinsics, # 3x3 camera matrix
rotation_matrix, # 3x3 left-to-right rotation
translation_vector # 3x1 left-to-right translation
)- Raise an issue on GitHub
- Fork the repository
- Create a feature branch:
<issue-number>-<short-description> - Submit a pull request
Copyright 2018 University College London. Released under the BSD-3 license.