Python wrapper for the GPU texture sharing framework Syphon.
Project description
Syphon for Python
⚠️ This library is still in development.
Python wrapper for the Syphon GPU texture sharing framework. This library was created to support both the Metal backend and the deprecated OpenGL backend. It requires macOS 11 or above.
The implementation is based on PyObjC to wrap the Syphon framework](https://github.com/Syphon/Syphon-Framework) directly from Python. This approach eliminates native wrapper and allows Python developers to extend the library as needed.
State of Development
- Syphon Server Discovery
- Metal Server
- Metal Client
- OpenGL Server
- OpenGL Client
- Syphon Client On Frame Callback
Usage
To install syphon-python
it is recommended to use a prebuilt binary from PyPi:
pip install syphon-python
To run all the examples, please also install Numpy and OpenCV:
pip install numpy opencv-python
The following code snippet is a basic example showing how to share numpy
images as MTLTexture
with a SyphonMetalServer
. There are more examples in examples.
import time
import numpy as np
import syphon
from syphon.utils.numpy import copy_image_to_mtl_texture
from syphon.utils.raw import create_mtl_texture
# create server and texture
server = syphon.SyphonMetalServer("Demo")
texture = create_mtl_texture(server.device, 512, 512)
# create texture data
texture_data = np.zeros((512, 512, 4), dtype=np.uint8)
texture_data[:, :, 0] = 255 # fill red
texture_data[:, :, 3] = 255 # fill alpha
while True:
# copy texture data to texture and publish frame
copy_image_to_mtl_texture(texture_data, texture)
server.publish_frame_texture(texture)
time.sleep(1)
server.stop()
Development
To develop or manually install the library, use the following commands to set up the local repository.
Installation
# clone the repository and it's submodules
git clone --recurse-submodules https://github.com/cansik/syphon-python.git
# install dependencies
pip install -r dev-requirements.txt
pip install -r requirements.txt
# for some examples the following dependencies are needed
pip install numpy
pip install opencv-python
Build
Build the Syphon framework on your machine:
python setup.py build
Distribute
Create a wheel package (also runs build
automatically)
python setup.py bdist_wheel
Generate Documentation
# create documentation into "./docs
python setup.py doc
# launch pdoc webserver
python setup.py doc --launch
About
MIT License - Copyright (c) 2023 Florian Bruggisser
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file syphon_python-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
.
File metadata
- Download URL: syphon_python-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
- Upload date:
- Size: 459.8 kB
- Tags: CPython 3.12, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07e47ce5380de1832c30c21e460209db0c4d5771d27cb42912eff4ab431b12e1 |
|
MD5 | 6ad55c1a9d7fe33fa2a441f690a8291f |
|
BLAKE2b-256 | ee94ccc2749af546a080f3ce96e344c01591dd0758bd9edcf19de0c92b37b591 |
File details
Details for the file syphon_python-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
.
File metadata
- Download URL: syphon_python-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 459.8 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 863f884bb0665a7038596bcacedc81ebc0e627c9980f0a5c22b7defe67af25bb |
|
MD5 | 2748bde3b5ddc54a61ff4a078cb53437 |
|
BLAKE2b-256 | b0bc42b2adacacb9392a1c1a879ad7674f9c677489a180d9539d1bad9dc153ed |
File details
Details for the file syphon_python-0.1.1-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: syphon_python-0.1.1-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 459.8 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be4a25818cf228e895ff49255ebfbae3ce9578dcb0eae9c6f5b9083df721e8ff |
|
MD5 | 770d88be8d616e7982d9ea6af4d662d0 |
|
BLAKE2b-256 | 2cf2460c9cc7c4682353abccb1d3f8cf5ca0af2a59af97b5c57b72f87e1f296c |
File details
Details for the file syphon_python-0.1.1-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: syphon_python-0.1.1-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 459.8 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3be9ad989e30acc051c82d6204316016975ba3e78d0edb09abff7b3481ba76d |
|
MD5 | 94ee7f763cc38f20b3d598912c3a8b51 |
|
BLAKE2b-256 | 5a1dff37940336e807f451c817c30277c4140a6f669030e84769309725cf894e |
File details
Details for the file syphon_python-0.1.1-cp38-cp38-macosx_10_9_universal2.whl
.
File metadata
- Download URL: syphon_python-0.1.1-cp38-cp38-macosx_10_9_universal2.whl
- Upload date:
- Size: 459.9 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 221d71a17819660e81a12a43b85f9310ec35248eadac988d3a20eeffc9b0fdd1 |
|
MD5 | 8b425d84fe20459fb4d16bc4edfd56b0 |
|
BLAKE2b-256 | 43ff90bf6703a611721ae31c738345ef93b6c7eac2139cd0b6b0965afea073c4 |