codeanticode.gsvideo
Class GSCapture

java.lang.Object
  extended by processing.core.PImage
      extended by codeanticode.gsvideo.GSCapture
All Implemented Interfaces:
java.lang.Cloneable, processing.core.PConstants

public class GSCapture
extends processing.core.PImage
implements processing.core.PConstants

Class for storing and manipulating video frames from an attached capture device such as a camera.


Field Summary
static java.lang.String capturePlugin
           
static java.lang.String devicePropertyName
           
static java.lang.String indexPropertyName
           
 
Fields inherited from class processing.core.PImage
format, height, parent, pixels, width
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BILINEAR, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLAMP, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, DYNAMIC, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, FIXED, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HAS_NORMAL, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINEAR, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, OPENGL2, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINT_SPRITES, POINTS, POLYGON, POSTERIZE, PROBLEM, PROG_GL2, PROG_GL3, PROG_GL4, PROJECT, PROJECTION, QUAD, QUAD_STRIP, QUADRATIC, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, STATIC, STREAM, SUBTRACT, SW, TAB, TARGA, TEXT, TEXTURE2D, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TRILINEAR, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight)
          Basic constructor: tries to auto-detect all the capture parameters, with the exception of the resolution.
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight, int frameRate)
          Constructor that takes resolution and framerate indicated as a single number.
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight, java.lang.String cameraName)
          This constructor allows to specify the camera name.
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight, java.lang.String cameraName, int frameRate)
          This constructor allows to specify the camera name and the desired framerate.
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight, java.lang.String sourceName, java.lang.String[] strPropNames, java.lang.String[] strPropValues, java.lang.String frameRate)
          This constructor accepts an arbitrary list of string properties for the source element.
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight, java.lang.String sourceName, java.lang.String[] strPropNames, java.lang.String[] strPropValues, java.lang.String[] intPropNames, int[] intPropValues, java.lang.String frameRate)
          This constructor accepts an arbitrary list of string properties for the source element, as well as a list of integer properties.
GSCapture(processing.core.PApplet parent, int requestWidth, int requestHeight, java.lang.String sourceName, java.lang.String cameraName, int frameRate)
          This constructor lets to indicate which source element to use (i.e.: v4l2src, osxvideosrc, ksvideosrc, etc).
 
Method Summary
 boolean available()
          Returns "true" when a new video frame is available to read.
 void delete()
          Releases the gstreamer resources associated to this capture object.
 void dispose()
          Same as delete.
 void disposeBuffer(java.lang.Object buf)
           
 java.lang.String[] framerates()
          Returns a list with the framerates supported by the capture device, expressed as a string like: 30/1, 15/2, etc.
 java.lang.String getSource()
          Returns the name of the source element used for capture.
 boolean isCapturing()
          Returns whether the device is capturing frames or not.
static java.lang.String[] list()
          Returns a list of available capture devices.
static java.lang.String[] list(java.lang.String sourceName)
          Get a list of all available captures as a String array.
 boolean newFrame()
          Returns true if a new frame has been read to the pixels array with the read() method.
 void oldFrame()
          Sets the new frame flag to false.
 void printElements()
          Prints all the gstreamer elements currently used in the current pipeline instance.
 void read()
          Reads the current video frame.
 boolean ready()
          Returns true if the stream is already producing frames.
 int[][] resolutions()
          Returns a list with the resolutions supported by the capture device.
 void setEventHandlerObject(java.lang.Object obj)
          Uses a generic object as handler of the movie.
 void setPixelDest(java.lang.Object dest)
          Sets the object to use as destination for the frames read from the stream.
 void setPixelDest(java.lang.Object dest, boolean copy)
          Sets the object to use as destination for the frames read from the stream.
 void setPixelDest(java.lang.Object dest, java.lang.String mask, boolean copy)
          Sets the object to use as destination for the frames read from the stream.
 void start()
          Starts the capture pipeline.
 void stop()
          Stops the capture pipeline.
 
Methods inherited from class processing.core.PImage
blend, blend, blendColor, clone, copy, copy, filter, filter, get, get, get, getCache, getImage, getModifiedX1, getModifiedX2, getModifiedY1, getModifiedY2, getParams, init, isModified, loadPixels, mask, mask, removeCache, removeParams, resize, save, set, set, setCache, setModified, setModified, setParams, updatePixels, updatePixels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

capturePlugin

public static java.lang.String capturePlugin

devicePropertyName

public static java.lang.String devicePropertyName

indexPropertyName

public static java.lang.String indexPropertyName
Constructor Detail

GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight)
Basic constructor: tries to auto-detect all the capture parameters, with the exception of the resolution.


GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 int frameRate)
Constructor that takes resolution and framerate indicated as a single number.


GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 java.lang.String cameraName)
This constructor allows to specify the camera name. In Linux, for example, this should be a string of the form /dev/video0, /dev/video1, etc.


GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 java.lang.String cameraName,
                 int frameRate)
This constructor allows to specify the camera name and the desired framerate.


GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 java.lang.String sourceName,
                 java.lang.String cameraName,
                 int frameRate)
This constructor lets to indicate which source element to use (i.e.: v4l2src, osxvideosrc, ksvideosrc, etc).


GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 java.lang.String sourceName,
                 java.lang.String[] strPropNames,
                 java.lang.String[] strPropValues,
                 java.lang.String frameRate)
This constructor accepts an arbitrary list of string properties for the source element. The camera name could be one of these properties. The framerate must be specified as a fraction string: 30/1, 15/2, etc.


GSCapture

public GSCapture(processing.core.PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 java.lang.String sourceName,
                 java.lang.String[] strPropNames,
                 java.lang.String[] strPropValues,
                 java.lang.String[] intPropNames,
                 int[] intPropValues,
                 java.lang.String frameRate)
This constructor accepts an arbitrary list of string properties for the source element, as well as a list of integer properties. This could be useful if a camera cannot by specified by name but by index. Framerate must be a fraction string: 30/1, 15/2, etc.

Method Detail

delete

public void delete()
Releases the gstreamer resources associated to this capture object. It shouldn't be used after this.

Overrides:
delete in class processing.core.PImage

dispose

public void dispose()
Same as delete.


printElements

public void printElements()
Prints all the gstreamer elements currently used in the current pipeline instance.


setPixelDest

public void setPixelDest(java.lang.Object dest)
Sets the object to use as destination for the frames read from the stream. The color conversion mask is automatically set to the one required to copy the frames to OpenGL.

Parameters:
Object - dest

setPixelDest

public void setPixelDest(java.lang.Object dest,
                         boolean copy)
Sets the object to use as destination for the frames read from the stream. The color conversion mask is automatically set to the one required to copy the frames to OpenGL. If copy is true, then the frames are copied into new buffer objects, this can help solve threading problems when playing back a large number of videos.

Parameters:
Object - dest
boolean - copy

setPixelDest

public void setPixelDest(java.lang.Object dest,
                         java.lang.String mask,
                         boolean copy)
Sets the object to use as destination for the frames read from the stream. If copy is true, then the frames are copied into new buffer objects, this can help solve threading problems when playing back a large number of videos.

Parameters:
Object - dest
String - mask
boolean - copy

setEventHandlerObject

public void setEventHandlerObject(java.lang.Object obj)
Uses a generic object as handler of the movie. This object should have a movieEvent method that receives a GSMovie argument. This method will be called upon a new frame read event.


ready

public boolean ready()
Returns true if the stream is already producing frames.

Returns:
boolean

newFrame

public boolean newFrame()
Returns true if a new frame has been read to the pixels array with the read() method.

Returns:
boolean

oldFrame

public void oldFrame()
Sets the new frame flag to false. This is useful to avoid reading pixels array when there is no new frame data.


available

public boolean available()
Returns "true" when a new video frame is available to read.

Returns:
boolean

isCapturing

public boolean isCapturing()
Returns whether the device is capturing frames or not.

Returns:
boolean

start

public void start()
Starts the capture pipeline.


stop

public void stop()
Stops the capture pipeline.


read

public void read()
Reads the current video frame. This method() and invokeEvent() are now synchronized, so that invokeEvent() can't be called whilst we're busy reading. Problematic frame error fixed by Charl P. Botha


resolutions

public int[][] resolutions()
Returns a list with the resolutions supported by the capture device. Each element of the list is in turn an array of two int, first being the width and second the height.

Returns:
int[][]

framerates

public java.lang.String[] framerates()
Returns a list with the framerates supported by the capture device, expressed as a string like: 30/1, 15/2, etc.

Returns:
String[]

list

public static java.lang.String[] list()
Returns a list of available capture devices.

Returns:
String[]

list

public static java.lang.String[] list(java.lang.String sourceName)
Get a list of all available captures as a String array. i.e. println(Capture.list()) will show you the goodies.

Parameters:
sourceName - String
Returns:
String[]

getSource

public java.lang.String getSource()
Returns the name of the source element used for capture.

Returns:
String

disposeBuffer

public void disposeBuffer(java.lang.Object buf)


processing library GSVideo by Andres Colubri. (c) 2008-2011