Metadata-Version: 2.5
Name: visiongraph
Version: 1.3.0
Summary: Visiongraph is a computer vision pipeline that provides ready-to-use modules for quick prototyping of image-based algorithms.
Project-URL: Homepage, https://github.com/cansik/visiongraph
Project-URL: Documentation, https://cansik.github.io/visiongraph/
Project-URL: Repository, https://github.com/cansik/visiongraph.git
Author-email: Florian Bruggisser <github@broox.ch>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: numpy>2
Requires-Dist: opencv-contrib-python~=4.12
Requires-Dist: requests
Requires-Dist: scipy
Requires-Dist: tqdm
Requires-Dist: vector~=1.9.0
Provides-Extra: all
Requires-Dist: depthai~=2.30; (platform_system != 'Darwin' or platform_machine == 'arm64') and extra == 'all'
Requires-Dist: faiss-cpu; extra == 'all'
Requires-Dist: filterpy; extra == 'all'
Requires-Dist: mediapipe~=1.2.3; extra == 'all'
Requires-Dist: numba~=0.61; extra == 'all'
Requires-Dist: onnxruntime<2,>=1.23.2; extra == 'all'
Requires-Dist: openvino<2027,>=2025.4.1; extra == 'all'
Requires-Dist: pyk4a-bundle~=1.5.0.1; (platform_system == 'Windows') and extra == 'all'
Requires-Dist: pyopengl; (platform_system == 'Darwin' or platform_system == 'Windows') and extra == 'all'
Requires-Dist: pyrealsense2-macosx~=2.56.5; (platform_system == 'Darwin') and extra == 'all'
Requires-Dist: pyrealsense2~=2.59.1; (platform_system != 'Darwin') and extra == 'all'
Requires-Dist: spoutgl~=0.1.1; (platform_system == 'Windows') and extra == 'all'
Requires-Dist: syphon-python~=0.2.0; (platform_system == 'Darwin') and extra == 'all'
Requires-Dist: vidgear[core]~=0.3.7; extra == 'all'
Provides-Extra: azure
Requires-Dist: pyk4a-bundle~=1.5.0.1; (platform_system == 'Windows') and extra == 'azure'
Provides-Extra: depthai
Requires-Dist: depthai~=2.30; (platform_system != 'Darwin' or platform_machine == 'arm64') and extra == 'depthai'
Provides-Extra: faiss
Requires-Dist: faiss-cpu; extra == 'faiss'
Provides-Extra: fbs
Requires-Dist: pyopengl; (platform_system == 'Darwin' or platform_system == 'Windows') and extra == 'fbs'
Requires-Dist: spoutgl~=0.1.1; (platform_system == 'Windows') and extra == 'fbs'
Requires-Dist: syphon-python~=0.2.0; (platform_system == 'Darwin') and extra == 'fbs'
Provides-Extra: media
Requires-Dist: vidgear[core]~=0.3.7; extra == 'media'
Provides-Extra: mediapipe
Requires-Dist: mediapipe~=1.2.3; extra == 'mediapipe'
Provides-Extra: mot
Requires-Dist: filterpy; extra == 'mot'
Provides-Extra: numba
Requires-Dist: numba~=0.61; extra == 'numba'
Provides-Extra: onnx
Requires-Dist: onnxruntime<2,>=1.23.2; extra == 'onnx'
Provides-Extra: onnx-directml
Requires-Dist: onnxruntime-directml~=1.24.4; (platform_system == 'Windows') and extra == 'onnx-directml'
Requires-Dist: onnxruntime<2,>=1.23.2; (platform_system == 'Darwin' or platform_system == 'Linux') and extra == 'onnx-directml'
Provides-Extra: onnx-gpu
Requires-Dist: onnxruntime-gpu~=1.32.0; (platform_system != 'Darwin') and extra == 'onnx-gpu'
Requires-Dist: onnxruntime<2,>=1.23.2; (platform_system == 'Darwin') and extra == 'onnx-gpu'
Provides-Extra: openvino
Requires-Dist: openvino<2027,>=2025.4.1; extra == 'openvino'
Provides-Extra: realsense
Requires-Dist: pyrealsense2-macosx~=2.56.5; (platform_system == 'Darwin') and extra == 'realsense'
Requires-Dist: pyrealsense2~=2.59.1; (platform_system != 'Darwin') and extra == 'realsense'
Description-Content-Type: text/markdown

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/cansik/visiongraph/refs/heads/main/assets/visiongraph-logo-dark-mode.png">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/cansik/visiongraph/refs/heads/main/assets/visiongraph-logo-bright-mode.png">
  <img src="https://raw.githubusercontent.com/cansik/visiongraph/refs/heads/main/assets/visiongraph-logo-bright-mode.png" alt="Visiongraph Logo Bright" width="75%">
</picture>

# Visiongraph

[![Ruff](https://github.com/cansik/visiongraph/actions/workflows/code.yml/badge.svg)](https://github.com/cansik/visiongraph/actions/workflows/code.yml)
[![PyPI](https://img.shields.io/pypi/v/visiongraph)](https://pypi.org/project/visiongraph/)
![Pepy Total Downloads](https://img.shields.io/pepy/dt/visiongraph)
[![Documentation](https://img.shields.io/badge/read-documentation-blue)](https://cansik.github.io/visiongraph/visiongraph.html#documentation)
[![DOI](https://zenodo.org/badge/423544682.svg)](https://doi.org/10.5281/zenodo.22307737)

Visiongraph is a computer-vision pipeline library designed to simplify the prototyping of image-based algorithms with ready-to-use modules and composable graph nodes. Built on top of OpenCV, it also integrates popular frameworks such as [Intel OpenVINO](https://github.com/openvinotoolkit/openvino), [Google MediaPipe](https://github.com/google-ai-edge/mediapipe), and [DepthAI](https://pypi.org/project/depthai/). The library is designed with a focus on real-time applications and edge deployment.

![Readme Example](https://github.com/cansik/visiongraph/raw/main/doc/visiongraph-readme-street.webp)

*Object detection, segmentation and pose estimation example.*

Here is a minimal example that opens a live webcam capture, runs SSD object detection, and displays the annotated result.

```python
import cv2
from visiongraph import vg

with vg.VideoCaptureInput() as cam, vg.SSDDetector.create(vg.SSDConfig.SSDLiteMobileNetV2_FP32) as ssd:
    while True:
        _, frame = cam.read()
        if frame is None:
            break

        results = ssd.process(frame)
        results.annotate(frame)

        cv2.imshow("Frame", frame)
        cv2.waitKey(1)
```

Get started with `visiongraph` by reading the **[documentation](https://cansik.github.io/visiongraph/visiongraph.html#documentation)**.

## Research Origins

Visiongraph originated as a research codebase for rapid prototyping in computer vision. It has since supported a range of academic, artistic, and applied projects. Selected examples include:

* [Are You Talking to Me? A Case Study in Emotional Human-Machine Interaction](https://ojs.aaai.org/index.php/AIIDE/article/view/27538)
* [reconFIGURE: Confronting Audiences with Digital Doppelgängers](https://dl.acm.org/doi/abs/10.1145/3664208)
* [Space Stream](https://github.com/cansik/space-stream)
* [Kamituga | Digital Gold](https://blog.zhdk.ch/digitalgold/)

## Installation

Visiongraph supports CPython 3.11 through 3.13. Python 3.14 and newer can be used where the selected dependencies
provide compatible builds.
The base installation uses NumPy 2 and OpenCV contrib (`cv2`).

To add Visiongraph with all available optional dependencies to a project managed by
[uv](https://docs.astral.sh/uv/), run:

```bash
uv add "visiongraph[all]"
```

Alternatively, install it into the active Python environment with [pip](https://pip.pypa.io/):

```bash
pip install "visiongraph[all]"
```

It is also possible, and usually preferable, to install only the extras you actually need:

```bash
# example: install RealSense and OpenVINO support only
uv add "visiongraph[realsense,openvino]"
```

The equivalent pip command is:

```bash
pip install "visiongraph[realsense,openvino]"
```

Please read more about the extra packages in the [documentation](https://cansik.github.io/visiongraph/visiongraph.html#extras).

## Model Assets

Most estimators download their model files on demand and store them in `~/.visiongraph/assets/` by default. Set `VISIONGRAPH_ASSET_DIR` to use a different location.
Visiongraph itself is released under the MIT License, but individual downloadable models can use different licenses,
including copyleft terms such as AGPL or GPL. Check [MODEL_ATTRIBUTIONS.md](https://github.com/cansik/visiongraph/blob/main/MODEL_ATTRIBUTIONS.md) for the license of
the specific model you plan to ship, redistribute, or use in a commercial product.

Images and project artwork stored in the repository's `assets` directory are documented in
[assets/ATTRIBUTIONS.md](https://github.com/cansik/visiongraph/blob/main/assets/ATTRIBUTIONS.md).

## Examples
Run an example with `uv run examples/<ExampleFile>.py`, for example `uv run examples/SimpleVisionGraph.py`.

To demonstrate the possibilities of visiongraph, the repository already contains a number of ready-to-run [examples](https://github.com/cansik/visiongraph/tree/main/examples). Here is a selection of the current examples:

- [SimpleVisionGraph](https://github.com/cansik/visiongraph/blob/main/examples/SimpleVisionGraph.py) - A minimal graph example for live object detection and tracking.
- [VisionGraphExample](https://github.com/cansik/visiongraph/blob/main/examples/VisionGraphExample.py) - A face detection and tracking example with custom callbacks.
- [InputExample](https://github.com/cansik/visiongraph/blob/main/examples/InputExample.py) - A basic input example that previews the stream and reports depth when available.
- [DepthCameraExample](https://github.com/cansik/visiongraph/blob/main/examples/DepthCameraExample.py) - Display the depth map next to the color image for a supported depth camera.
- [FaceDetectionExample](https://github.com/cansik/visiongraph/blob/main/examples/FaceDetectionExample.py) - A face detection pipeline example.
- [FindFaceExample](https://github.com/cansik/visiongraph/blob/main/examples/FindFaceExample.py) - A face recognition example to find a target face.
- [CascadeFaceDetectionExample](https://github.com/cansik/visiongraph/blob/main/examples/CascadeFaceDetectionExample.py) - A face detection pipeline that also predicts facial landmarks.
- [HandDetectionExample](https://github.com/cansik/visiongraph/blob/main/examples/HandDetectionExample.py) - A hand detection pipeline example.
- [PoseEstimationExample](https://github.com/cansik/visiongraph/blob/main/examples/PoseEstimationExample.py) - A pose estimation pipeline that annotates generic pose keypoints.
- [ProjectedPoseExample](https://github.com/cansik/visiongraph/blob/main/examples/ProjectedPoseExample.py) - Project pose estimation into 3D space with a RealSense camera.
- [ObjectDetectionExample](https://github.com/cansik/visiongraph/blob/main/examples/ObjectDetectionExample.py) - An object detection example.
- [InstanceSegmentationExample](https://github.com/cansik/visiongraph/blob/main/examples/InstanceSegmentationExample.py) - Instance segmentation based on the COCO dataset.
- [InpaintExample](https://github.com/cansik/visiongraph/blob/main/examples/InpaintExample.py) - A GAN-based inpainting example.
- [MidasDepthExample](https://github.com/cansik/visiongraph/blob/main/examples/MidasDepthExample.py) - Real-time monocular depth prediction with the [midas-small](https://github.com/isl-org/MiDaS) network.
- [RGBDSmoother](https://github.com/cansik/visiongraph/blob/main/examples/RGBDSmoother.py) - Smooth RGB-D depth map videos with a one-euro filter per pixel.
- [FaceMeshVVADExample](https://github.com/cansik/visiongraph/blob/main/examples/FaceMeshVVADExample.py) - Detect voice activation by landmark sequence classification.

There are also additional projects that use visiongraph in practice:

- [Spout/Syphon RGB-D Example](https://github.com/cansik/spout-rgbd-example) - Share RGB-D images over Spout or Syphon.
- [NDI Input / Output](https://github.com/cansik/visiongraph-ndi) - Receive and share video frames over NDI.
- [WebRTC Input](https://github.com/cansik/visiongraph-webrtc) - WebRTC input example for visiongraph.

## Development

To develop Visiongraph itself, clone this repository and install the dependencies with
[uv](https://docs.astral.sh/uv/getting-started/installation/):

```bash
# from the repository root
make sync
```

uv uses Python 3.13 from the repository's `.python-version` by default.

### Build

Build the source distribution and wheel from the repository root. The build regenerates the required repository
artifacts first and writes the packages to `./dist`:

```bash
make build
```

Run `make generate-artifacts` to regenerate the public imports and model attributions outside a build. If attribution
generation reports missing dependencies, run `make sync` and try again.

To download local copies of all model license texts referenced by repository-backed assets into `./build/licenses`, run:

```bash
make download-model-licenses
```

### Docs

Generate the deployable documentation in `./docs` with:

```bash
make docs
```

The docs builder uses stubs for optional backends so API pages can be built with the base and docs dependencies.

To preview the documentation locally with pdoc's development server, run:

```bash
make docs-serve
```

### Code Quality and Tests

Format the repository and apply auto-fixable Ruff rules:

```bash
make autoformat
```

Run the non-mutating lint and formatting checks individually, or run the full validation suite:

```bash
make lint          # run Ruff lint checks
make fmt-check     # check formatting without changing files
make test-routine  # run unit tests and backend import checks
make test          # run the full test suite, including model inference
make check         # run lint, formatting, and tests
```

The **Visiongraph Test** workflow offers three suites:

- `routine` is the default and runs unit tests and optional backend import checks on Windows, macOS, and Linux with
  Python 3.11–3.13.
- `inference` runs the full suite on Ubuntu with Python 3.13.
- `full` runs the full suite across the OS and Python matrix.

The inference suites fetch model assets on demand and cache them by model mirror revision.

## Dependencies

Parts of these libraries are directly included and adapted to work with visiongraph. For more information, please see the [third party notices](https://github.com/cansik/visiongraph/blob/main/THIRD_PARTY_NOTICES.md).

Below is a list of visiongraph dependencies and their licenses, provided without guarantee of correctness:

```
depthai               MIT License
faiss-cpu             MIT License & BSD-3-Clause
filterpy              MIT License
mediapipe             Apache License 2.0
numba                 BSD License
numpy                 MIT License
onnxruntime           MIT License
onnxruntime-directml  MIT License
onnxruntime-gpu       MIT License
opencv-contrib-python Apache License 2.0
openvino              Apache License 2.0
pdoc                  MIT License
pyk4a                 MIT License
pyopengl              BSD License
pyrealsense2          Apache License 2.0
pyrealsense2-macosx   Apache License 2.0
pytest                MIT License
requests              Apache License 2.0
ruff                  MIT License
scipy                 MIT License
hatchling             MIT License
SpoutGL               BSD License
syphon-python         MIT License
tqdm                  MIT License
ty                    MIT License
vector                BSD License
vidgear               Apache License 2.0
wheel                 MIT License
```

For more information about the dependencies, see [pyproject.toml](https://github.com/cansik/visiongraph/blob/main/pyproject.toml).

Please **note** that the library code is MIT-licensed, but some downloadable models, such as Ultralytics YOLOv8 and YOLOv11, use their own licenses (for example AGPLv3). Model provenance and license information is listed in [MODEL_ATTRIBUTIONS.md](https://github.com/cansik/visiongraph/blob/main/MODEL_ATTRIBUTIONS.md).

## Credits

Developed at the [Immersive Arts Space](https://blog.zhdk.ch/immersivearts/),
[Zurich University of the Arts (ZHdK)](https://www.zhdk.ch/).  
Maintained by Florian Bruggisser.  

Released under the MIT License. See [LICENSE](https://github.com/cansik/visiongraph/blob/main/LICENSE) for details.
