From 5da92d6a724cfc6da0647f67510b8faec30a87de Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 10 Oct 2011 17:32:53 +0000 Subject: [PATCH] Added newFrame() method to Capture and Movie --- .../video/src/processing/video/Capture.java | 21 ++++++++++++++++--- .../video/src/processing/video/Movie.java | 16 ++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/java/libraries/video/src/processing/video/Capture.java b/java/libraries/video/src/processing/video/Capture.java index ebebf982a..4748b8694 100644 --- a/java/libraries/video/src/processing/video/Capture.java +++ b/java/libraries/video/src/processing/video/Capture.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Set; import java.lang.reflect.*; import org.gstreamer.*; @@ -94,7 +93,8 @@ public class Capture extends PImage implements PConstants { protected Object copyHandler; protected boolean available; - protected boolean pipelineReady; + protected boolean pipelineReady; + protected boolean newFrame; protected RGBDataAppSink rgbSink = null; protected int[] copyPixels = null; @@ -328,6 +328,19 @@ public class Capture extends PImage implements PConstants { return 0 < bufWidth && 0 < bufHeight && pipelineReady; } + /** + * Returns true if its called for the first time after a new + * frame has been read, and false afterwards until another frame + * is read. + * + * @return boolean + */ + public boolean newFrame() { + boolean res = newFrame; + newFrame = false; + return res; + } + /** * ( begin auto-generated from Capture_available.xml ) * @@ -449,6 +462,7 @@ public class Capture extends PImage implements PConstants { } available = false; + newFrame = true; } /** @@ -689,7 +703,8 @@ public class Capture extends PImage implements PConstants { Element.linkMany(gsource, conv, videofilter, rgbSink); } - pipelineReady = true; + pipelineReady = true; + newFrame = false; } protected void initResAndFps() { diff --git a/java/libraries/video/src/processing/video/Movie.java b/java/libraries/video/src/processing/video/Movie.java index c1e978bdd..d728d1935 100644 --- a/java/libraries/video/src/processing/video/Movie.java +++ b/java/libraries/video/src/processing/video/Movie.java @@ -67,6 +67,7 @@ public class Movie extends PImage implements PConstants { protected boolean available; protected boolean sinkReady; + protected boolean newFrame; protected RGBDataAppSink rgbSink = null; protected int[] copyPixels = null; @@ -438,6 +439,19 @@ public class Movie extends PImage implements PConstants { return 0 < bufWidth && 0 < bufHeight && sinkReady && !seeking; } + /** + * Returns true if its called for the first time after a new + * frame has been read, and false afterwards until another frame + * is read. + * + * @return boolean + */ + public boolean newFrame() { + boolean res = newFrame; + newFrame = false; + return res; + } + /** * ( begin auto-generated from Movie_available.xml ) * @@ -649,6 +663,7 @@ public class Movie extends PImage implements PConstants { } available = false; + newFrame = true; } /** @@ -829,6 +844,7 @@ public class Movie extends PImage implements PConstants { }); sinkReady = true; + newFrame = false; } protected synchronized void invokeEvent(int w, int h, IntBuffer buffer) {