visiongraph-ndi


Namevisiongraph-ndi JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/cansik/visiongraph-ndi
SummaryNDI support for the visiongraph library.
upload_time2024-10-31 21:58:39
maintainerNone
docs_urlNone
authorFlorian Bruggisser
requires_pythonNone
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Visiongraph NDI [![PyPI](https://img.shields.io/pypi/v/visiongraph-ndi)](https://pypi.org/project/visiongraph-ndi/)

Visiongraph NDI is an extension of the [visiongraph](https://github.com/cansik/visiongraph) library, adding support for real-time video streaming over the network via NewTek's NDIĀ® protocol. This library provides both sending and receiving capabilities, making it easy to integrate NDI into computer vision workflows.

## Installation

Install visiongraph NDI with pip:

```bash
pip install visiongraph-ndi
```

### Requirements

Ensure you have the latest version of visiongraph installed.

## Usage Examples

### Sending Video Streams

The `NDIVideoOutput` class allows you to broadcast images in real-time. This example shows how to generate a simple time-based pattern and send it as a video stream.

```python
from visiongraph_ndi.NDIVideoOutput import NDIVideoOutput

# Set up NDI output with a stream name
with NDIVideoOutput("Demo") as ndi:
    image_bgr = ... # load or get an image in BGR format
    ndi.send(image_bgr)  # Send the generated image
```

The `NDIVideoOutput` class initializes an NDI output stream with the given name. Use `ndi.send(frame)` to transmit frames, which can be in `BGR` or `BGRA` format.

### Receiving Video Streams

The `NDIVideoInput` class supports finding available NDI sources and streaming from them in real-time. Below are examples of how to find NDI sources and receive streams.

#### Finding Sources

Use `NDIVideoInput.find_sources()` to list all available NDI sources on the network. It is possible to set the timeout to find sources (default: `1.0` seconds).

```python
from visiongraph_ndi.NDIVideoInput import NDIVideoInput

# Discover NDI sources for 5 seconds
for source in NDIVideoInput.find_sources(timeout=5.0):
    print(source.name)
```

#### Receiving Video Streams

The following example demonstrates how to receive a video stream from a the first NDI source available and display it using OpenCV.

```python
import cv2
from visiongraph_ndi.NDIVideoInput import NDIVideoInput

# Connect to an NDI source
with NDIVideoInput(stream_name="Demo") as ndi:
    while ndi.is_connected:
        ts, frame = ndi.read()  # Receive timestamped frame

        if frame is None:
            continue  # Skip if no frame is received

        # Display the frame
        cv2.imshow(f"NDI {ndi.source.stream_name}", frame)
        cv2.waitKey(1)
```

The `NDIVideoInput` class automatically connects to the first available NDI source or allows for specific source selection if desired (using the `stream_name` and/or `host_name` parameter in the constructor). By calling `ndi.read()`, you retrieve frames as `numpy` arrays, ready for processing or display.

### About

Visiongraph NDI is powered by the NDI Python wrapper [cyndilib](https://github.com/nocarryr/cyndilib) (`MIT license`). Special thanks to nocarryr for making this integration possible.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cansik/visiongraph-ndi",
    "name": "visiongraph-ndi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Florian Bruggisser",
    "author_email": "github@broox.ch",
    "download_url": null,
    "platform": null,
    "description": "# Visiongraph NDI [![PyPI](https://img.shields.io/pypi/v/visiongraph-ndi)](https://pypi.org/project/visiongraph-ndi/)\n\nVisiongraph NDI is an extension of the [visiongraph](https://github.com/cansik/visiongraph) library, adding support for real-time video streaming over the network via NewTek's NDI\u00ae protocol. This library provides both sending and receiving capabilities, making it easy to integrate NDI into computer vision workflows.\n\n## Installation\n\nInstall visiongraph NDI with pip:\n\n```bash\npip install visiongraph-ndi\n```\n\n### Requirements\n\nEnsure you have the latest version of visiongraph installed.\n\n## Usage Examples\n\n### Sending Video Streams\n\nThe `NDIVideoOutput` class allows you to broadcast images in real-time. This example shows how to generate a simple time-based pattern and send it as a video stream.\n\n```python\nfrom visiongraph_ndi.NDIVideoOutput import NDIVideoOutput\n\n# Set up NDI output with a stream name\nwith NDIVideoOutput(\"Demo\") as ndi:\n    image_bgr = ... # load or get an image in BGR format\n    ndi.send(image_bgr)  # Send the generated image\n```\n\nThe `NDIVideoOutput` class initializes an NDI output stream with the given name. Use `ndi.send(frame)` to transmit frames, which can be in `BGR` or `BGRA` format.\n\n### Receiving Video Streams\n\nThe `NDIVideoInput` class supports finding available NDI sources and streaming from them in real-time. Below are examples of how to find NDI sources and receive streams.\n\n#### Finding Sources\n\nUse `NDIVideoInput.find_sources()` to list all available NDI sources on the network. It is possible to set the timeout to find sources (default: `1.0` seconds).\n\n```python\nfrom visiongraph_ndi.NDIVideoInput import NDIVideoInput\n\n# Discover NDI sources for 5 seconds\nfor source in NDIVideoInput.find_sources(timeout=5.0):\n    print(source.name)\n```\n\n#### Receiving Video Streams\n\nThe following example demonstrates how to receive a video stream from a the first NDI source available and display it using OpenCV.\n\n```python\nimport cv2\nfrom visiongraph_ndi.NDIVideoInput import NDIVideoInput\n\n# Connect to an NDI source\nwith NDIVideoInput(stream_name=\"Demo\") as ndi:\n    while ndi.is_connected:\n        ts, frame = ndi.read()  # Receive timestamped frame\n\n        if frame is None:\n            continue  # Skip if no frame is received\n\n        # Display the frame\n        cv2.imshow(f\"NDI {ndi.source.stream_name}\", frame)\n        cv2.waitKey(1)\n```\n\nThe `NDIVideoInput` class automatically connects to the first available NDI source or allows for specific source selection if desired (using the `stream_name` and/or `host_name` parameter in the constructor). By calling `ndi.read()`, you retrieve frames as `numpy` arrays, ready for processing or display.\n\n### About\n\nVisiongraph NDI is powered by the NDI Python wrapper [cyndilib](https://github.com/nocarryr/cyndilib) (`MIT license`). Special thanks to nocarryr for making this integration possible.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "NDI support for the visiongraph library.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/cansik/visiongraph-ndi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bab9a9b7d0e583e93ec89194b19cce6eb876fb44a42ce25c97e81fab3c76950c",
                "md5": "2a71dea8ee90e2c58f92a45c2e5cd2e0",
                "sha256": "69eaad085dac9f8556c3644bb4299a24c4f16874c72973451668a66640bc9d81"
            },
            "downloads": -1,
            "filename": "visiongraph_ndi-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2a71dea8ee90e2c58f92a45c2e5cd2e0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7463,
            "upload_time": "2024-10-31T21:58:39",
            "upload_time_iso_8601": "2024-10-31T21:58:39.399113Z",
            "url": "https://files.pythonhosted.org/packages/ba/b9/a9b7d0e583e93ec89194b19cce6eb876fb44a42ce25c97e81fab3c76950c/visiongraph_ndi-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-31 21:58:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cansik",
    "github_project": "visiongraph-ndi",
    "github_not_found": true,
    "lcname": "visiongraph-ndi"
}
        
Elapsed time: 2.38388s