Coder Social home page Coder Social logo

syphonpy's Introduction

syphonpy

Build Status
Python bindings for the Syphon Framework (OSX)

Installation

A prebuilt version is hosted on PyPI and available to install with pip:

pip install syphonpy

Build

  1. Have python3.7, XCode and cmake installed

  2. Clone to your local machine

  3. Open terminal and cd .. to the clone

  4. Update submodules

git submodule update --init --recursive
  1. Build
python3.7 setup.py build
  1. Install
python3.7 setup.py install

Test

  • install bimpypip3.7 install bimpy
  • install OpenGL pip3.7 install pyopengl
  • install numpy pip3.7 install numpy
  • run python3.7 tester.py

Original Syphon Framework readme

Syphon is an open source Mac OS X technology that allows applications to share video and still images with one another in realtime.

See http://syphon.v002.info for more information.

This project hosts the Syphon.framework for developers who want to integrate Syphon in their own software. If you are looking for the Syphon plugins for Quartz Composer, Max/Jitter, FFGL, etc, the project for the Syphon Implementations currently at http://github.com/Syphon


Acknowledgements

https://github.com/bangnoise
https://github.com/maybites
https://github.com/egradman
https://github.com/cansik https://github.com/kiyu-git

syphonpy's People

Contributors

bangnoise avatar cansik avatar kiyu-git avatar maybites avatar njazz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

syphonpy's Issues

Can't Build

Whenever I try and build setup.py I get the an error due to CMakeLists.txt not existing.
See log below:

python3.7 setup.py build
running build
running build_ext
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:11 (add_subdirectory):
The source directory

/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy/submodules/pybind11

does not contain a CMakeLists.txt file.

-- Framework Foundation found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework
-- Framework OpenGL found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework
-- Framework AppKit found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/AppKit.framework
CMake Error at CMakeLists.txt:47 (pybind11_add_module):
Unknown CMake command "pybind11_add_module".

-- Configuring incomplete, errors occurred!
See also "/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy/build/temp.macosx-10.14-x86_64-3.7/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
File "setup.py", line 68, in
zip_safe=False,
File "/usr/local/lib/python3.7/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 32, in run
self.build_extension(ext)
File "setup.py", line 56, in build_extension
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy/build/lib.macosx-10.14-x86_64-3.7', '-DPYTHON_EXECUTABLE=/Users/joel/.virtualenvs/cv/bin/python3.7', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
(cv) TECH-07-AIM-JL:syphonpy joel$ python3.7 setup.py install
running install
running bdist_egg
running egg_info
creating syphonpy.egg-info
writing syphonpy.egg-info/PKG-INFO
writing dependency_links to syphonpy.egg-info/dependency_links.txt
writing top-level names to syphonpy.egg-info/top_level.txt
writing manifest file 'syphonpy.egg-info/SOURCES.txt'
reading manifest file 'syphonpy.egg-info/SOURCES.txt'
writing manifest file 'syphonpy.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.14-x86_64/egg
running install_lib
running build_ext
CMake Error at CMakeLists.txt:11 (add_subdirectory):
The source directory

/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy/submodules/pybind11

does not contain a CMakeLists.txt file.

-- Framework Foundation found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework
-- Framework OpenGL found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework
-- Framework AppKit found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/AppKit.framework
CMake Error at CMakeLists.txt:47 (pybind11_add_module):
Unknown CMake command "pybind11_add_module".

-- Configuring incomplete, errors occurred!
See also "/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy/build/temp.macosx-10.14-x86_64-3.7/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
File "setup.py", line 68, in
zip_safe=False,
File "/usr/local/lib/python3.7/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.7/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/local/lib/python3.7/site-packages/setuptools/command/install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 172, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/usr/local/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 158, in call_command
self.run_command(cmdname)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/install_lib.py", line 107, in build
self.run_command('build_ext')
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 32, in run
self.build_extension(ext)
File "setup.py", line 56, in build_extension
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/joel/Desktop/SIG/Python/blink-detection/syphonpy/build/lib.macosx-10.14-x86_64-3.7', '-DPYTHON_EXECUTABLE=/Users/joel/.virtualenvs/cv/bin/python3.7', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.

Syphon for Blender issue

Hi

I have recently extended my spout addon for blender (https://github.com/maybites/blender.script.spout) to work with syphon for OSX, too. But I have encountered an issue I am unable to tackle:

In order to make syphon work inside blender I am using your python wrapper, and while it works, the effect makes it actually unusable:

https://www.dropbox.com/s/le2f4hsapy73vc3/blender-syphon.mov?dl=0

As you can see, the camera captured texture is sent to the syphon client, but only a stripe on the left of the texture is updated in realtime, while the rest is only updated once the interaction in blender ends.

Any hints why this could be the case and where the issue (the way blender manages the framebuffers? the way syphon copies the textures?) would be welcome.

cheers

martin

Integration with moderngl

Hello,
I'm trying to integrate syphonpy with moderGL,
the goal is to build a modular video synthetizer.

I think I miss something, cause my understanding of syphonpy and modernGL is very partial.
First of all, I test both of these libraries, they are running well.
After that I mixed exemples form A and B, here lies the mix :

import numpy as np
import syphonpy
import pprint
from PIL import Image
import moderngl
from ported._example import Example
import time as delay

class AlphaBlending(Example):
    gl_version = (3, 3)
    title = "Alpha Blending"

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.id = 0;
        self.server = syphonpy.SyphonServer("headlessTest2")
        self.size = (1280, 720)
        self.fbo = self.ctx.framebuffer(
            color_attachments=[self.ctx.texture(self.size, 4)]
        )
        self.fbo.use()
        self.prog = self.ctx.program(
            vertex_shader='''
                #version 330

                in vec2 vert;

                in vec4 vert_color;
                out vec4 frag_color;

                uniform vec2 scale;
                uniform float rotation;

                void main() {
                    frag_color = vert_color;
                    float r = rotation * (0.5 + gl_InstanceID * 0.05);
                    mat2 rot = mat2(cos(r), sin(r), -sin(r), cos(r));
                    gl_Position = vec4((rot * vert) * scale, 0.0, 1.0);
                }
            ''',
            fragment_shader='''
                #version 330
                in vec4 frag_color;
                out vec4 color;
                void main() {
                    color = vec4(frag_color);
                }
            ''',
        )

        self.scale = self.prog['scale']
        self.rotation = self.prog['rotation']

        self.scale.value = (0.5, self.aspect_ratio * 0.5)

        vertices = np.array([
            1.0, 0.0,
            1.0, 0.0, 0.0, 0.5,

            -0.5, 0.86,
            0.0, 1.0, 0.0, 0.5,

            -0.5, -0.86,
            0.0, 0.0, 1.0, 0.5,
        ], dtype='f4')

        self.vbo = self.ctx.buffer(vertices)
        self.vao = self.ctx.simple_vertex_array(self.prog, self.vbo, 'vert', 'vert_color')

    def render(self, time: float, frame_time: float):
        self.ctx.clear(1.0, 1.0, 1.0)
        self.ctx.enable(moderngl.BLEND)
        self.fbo.use()
        self.fbo.clear(255, 255, 255, 255)
        self.rotation.value = time
        self.vao.render(instances=10)

        viewPort = syphonpy.MakeRect(0,0,self.fbo.width,self.fbo.height)
        size = syphonpy.MakeSize(self.fbo.width,self.fbo.height)

        self.server.publish_frame_texture(self.fbo.glo, viewPort, size, False)


if __name__ == '__main__':
    AlphaBlending.run()

I run

python3 basic_alpha_blending.py

it works... the video output is piped to syphon which is what I need, the window build by moderGL is full white.
but I want to run it headless. so

I run

python3 basic_alpha_blending.py --window headless

it does not work. the syphon server looks to be created, but nothing is displayed into syphon recorder
(which I use to visualize the rendering)
later as debug, I saved the rendering FBO to a png file to isolate the bug origin,
this worked without any troubble,
So I imagine the trouble comes from syphonpy
but I'm kind of blocked...

does anyone here ve a bit of advices ?
Thanks for reading me.

Apple Silicon (M1 / arm64) Universal2 Binaries

I have prebuilt universal binaries with target version 11 (Big Sur) and arm64 / i386 binaries. The workflow currently only works on MacOS with build support for 11. Before I create a PR, I first have to make sure that building still works on older systems. But this is just an information for anyone else using it on newer Macs.

The new universal2 binaries are already uploaded to PyPI as well.

Trouble installing bimpy

Any ideas about how to fix this error? I haven't been able to figure out how to properly install gl3w on ios. Any help would be very appreciated.

pip3.8 install bimpy

ERROR: Command errored out with exit status 1:
command: /usr/local/opt/[email protected]/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-o7vee3j_/bimpy/setup.py'"'"'; file='"'"'/private/tmp/pip-install-o7vee3j_/bimpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-57rc07up
cwd: /private/tmp/pip-install-o7vee3j_/bimpy/
Complete output (12 lines):
Traceback (most recent call last):
File "/private/tmp/pip-install-o7vee3j_/bimpy/setup.py", line 47, in
from libs.gl3w import gl3w_gen
ImportError: cannot import name 'gl3w_gen' from 'libs.gl3w' (unknown location)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-install-o7vee3j_/bimpy/setup.py", line 50, in <module>
    import gl3w_gen
ModuleNotFoundError: No module named 'gl3w_gen'

[feature-request] Adding a wrapper function for stopping the syphon server.

Hi

great job! thanks for publishing this project. I was able to compile it and use it to stream syphon from blender (I will publish the addon once this feature is implemented)

I also forked your project so I can add more info to the readme file (it took me some time to figure out how to build it, though its actually quite straight forward) - I can send you a pull-request if you are inclined.

anyway..

I would like to have an additional function that allows me to stop the syphon server. ObjectC is an awful language and I just got in contact with the syphon developer and there seems to be a stop message.

cheers

martin

send output of openCV2 to syphon

Hey! I'm trying to get the output of a cv.imshow() to send over syphon using the test script but I'm not sure how to plug it in... any help would be appreciated or some documentation on how to send that image over syphon. Thanks!

build error (OS framework issue?)

Really excited to test this module out! Having trouble building on 10.14.3, up-to-date XCode, cmake 3.14.5 (homebrew)

running build
running build_ext
-- pybind11 v2.3.dev0
-- Framework Foundation found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework
-- Framework OpenGL found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework
-- Framework AppKit found at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/AppKit.framework
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/egradman/dev/syphonpy/build/temp.macosx-10.13-x86_64-3.7
[ 90%] Built target syphon_lib
make[2]: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Foundation', needed by `../lib.macosx-10.13-x86_64-3.7/syphonpy.cpython-37m-darwin.so'.  Stop.
make[1]: *** [CMakeFiles/syphonpy.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 68, in <module>
    zip_safe=False,
  File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 140, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 32, in run
    self.build_extension(ext)
  File "setup.py", line 57, in build_extension
    subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 341, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.

The /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/ directory is present, and contains Foundation.tbd but not Foundation

My XCode-fu is not strong. Sorry if this is obvious.

syphonpy not seeing servers?

Hi,
I'm very much a novice Python programmer, so this is probably user error. I've installed syphonpy and it seems to be working (the server.py script included in the examples folder functions as expected). However, when I run the client.py example, there is no list of servers returned even when I am running several (the Simple Server from the syphon folks, and a server in Isadora, for instance).

The issue seems to be that syphonpy.ServerDirectory.servers() is empty. Am I missing a function or line of code to populate that list of servers?

I'm running Python 3.9 on mac os 12.5.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.