Home › Forums › Syphon › Syphon Implementations – User › Syphon Available Errors in Processing
Tagged: error, processing
- This topic has 9 replies, 2 voices, and was last updated 5 years, 5 months ago by Casey_Scalf.
-
AuthorPosts
-
June 10, 2015 at 10:02 pm #59002Casey_ScalfParticipant
I have been experiencing trouble using the syphon.Available() in Processing.
I am trying to use it to check if there is an available syphon feed, if so, read it. If not, use another image.
This runs, but it produces errors where the statements switch back and forth rapidly almost as if it is alternating between true and false even though there is no disruption in the feed. I added the code below. I am wondering if I am doing something wrong or if this is a limitation in Processing.
The feed coming into the sketch is from another Processing App that reads it from the camera. Using the Simple Syphon Client shows the disruption as well.
I have a youtube video pending upload that shows this in action.
import controlP5.*; import codeanticode.syphon.*; SyphonClient syphonIn; SyphonServer syphonOut; ControlP5 cp5; PGraphics canvas; PImage rawImg, defaultImg; Boolean syphonState = false; // GUI Variables boolean render = true; int threshold = 82; //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// void setup() { size(640, 640, P3D); frameRate(30); // Create a place to draw everything canvas = createGraphics(320, 320, P3D); // Create Syphon Client for specific source // syphonIn = new SyphonClient(this, "Sandbox_Soft_Server", "Sandbox Soft Server"); // Create Syphon Client for any source syphonIn = new SyphonClient(this); // Create Syphon Server syphonOut = new SyphonServer(this, "Sandbox Soft Server"); // Used as an image in case there is no available Syphon Feed defaultImg = loadImage("Room Default 640x640.png"); GUI(); } //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// void draw() { if (syphonIn.available() == true) { syphonState = true; } else { syphonState = false; } if (syphonState == true) { rawImg = syphonIn.getImage(rawImg); } if (syphonState == false) { rawImg = defaultImg; } // Draw everything in this PGraphics to be sent out via Syphon canvas.beginDraw(); canvas.background(0); canvas.image(rawImg, 0, 0); canvas.filter(THRESHOLD, map(threshold, 0, 255, 0, 1)); canvas.endDraw(); background(0); // Draws to Processing window to see if (render == true) { image(canvas, 0, 0, width, height); } // Uses frames from the main PGraphics and sends out via Syphon syphonOut.sendImage(canvas); // Shows FPS at the bottom text("FPS: " + int(frameRate), 40, height - 40); }
June 10, 2015 at 10:31 pm #59003Casey_ScalfParticipantHere is the video https://youtu.be/eSdTi10iJow
June 11, 2015 at 5:21 am #59005bangnoiseKeymasterHi
The available() function is confusingly named – it indicates the availability of a new frame since you last retrieved one, not the availability of the server.
I’ve opened an issue to request a function to do what you want – until then I’m not sure quite what to suggest – you might have to parse the result of listServers().
Processing’s SyphonClient could use some work…
June 11, 2015 at 2:15 pm #59006Casey_ScalfParticipant@Bangnoise, thanks for the rundown. That explains a lot!
I was under the impression that it was available in totality and not just every fresh frame. That explains why it would flippantly go back and forth if the framerate of the sketch and feed were not “in phase”.
With the listServers() are you suggesting I check the list to be more than 0 to determine of a feed is available? I think that may work. I have used that approach on other webcam based sketches in the past.
While we’re talking about the Processing implementation of Syphon, is there a reference for all of these functions? I have looked through the examples but I would love to see what else I may be missing!
June 12, 2015 at 9:03 am #59009bangnoiseKeymasterWith the listServers() are you suggesting I check the list to be more than 0 to determine of a feed is available?
yep
There’s documentation in libraries/Syphon/reference in your Processing folder.
October 8, 2015 at 6:11 pm #59069Casey_ScalfParticipantHas any of this been addressed since the 3.o rollout of Processing?
October 9, 2015 at 10:38 am #59070bangnoiseKeymasterIf you follow the link to the issue I posted above, you will see the answer… (yes).
October 10, 2015 at 1:02 pm #59071Casey_ScalfParticipantI am not the best at interpreting this stuff. Is this what you meant? I did not get it to work…
October 10, 2015 at 1:02 pm #59072Casey_ScalfParticipantOctober 10, 2015 at 1:08 pm #59073Casey_ScalfParticipantIn Processing 3.0 I tried this. It looks like some things have changed.
I tried the “active” part again but it would not compute. All I was able to do is set the frameRate to (30) and it wouldn’t bug out.
-
AuthorPosts
- You must be logged in to reply to this topic.