processing.video
Class Capture

java.lang.Object
  extended by processing.core.PImage
      extended by processing.video.Capture
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable, PConstants

public class Capture
extends PImage
implements java.lang.Runnable

Watchin' shit on the telly.


Field Summary
 quicktime.std.sg.SequenceGrabber capture
           
 quicktime.std.sg.SGVideoChannel channel
          the guy who's doing all the work
static int COMPONENT
           
static int COMPOSITE
           
 boolean crop
          True if this image is currently being cropped
 int cropH
           
 int cropW
           
 int cropX
           
 int cropY
           
 int[] data
          Temporary storage for the raw image data read directly from the capture device
 int dataHeight
           
 int dataRowBytes
           
 int dataWidth
           
 int frameRate
           
static int NTSC
           
static int PAL
           
 quicktime.util.RawEncodedImage raw
           
static int SECAM
           
static int SVIDEO
           
static int TUNER
           
 
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, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, 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_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, 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, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
Capture(PApplet parent, int requestWidth, int requestHeight)
           
Capture(PApplet parent, int reqWidth, int reqHeight, int frameRate)
           
Capture(PApplet parent, int reqWidth, int reqHeight, java.lang.String name)
           
Capture(PApplet parent, int requestWidth, int requestHeight, java.lang.String name, int frameRate)
          If 'name' is null or the empty string, it won't set a specific device, which means that QuickTime will use that last device used by a QuickTime application.
 
Method Summary
 boolean available()
          True if a frame is ready to be read.
 void crop(int x, int y, int w, int h)
          Set the video to crop from its original.
 void dispose()
          Called by PApplet to shut down video so that QuickTime can be used later by another applet.
 void format(int which)
          Set the video format standard to use on the video digitizer: NTSC, PAL, or SECAM.
 void frameRate(int iframeRate)
          Set the frameRate for how quickly new frames are read from the capture device.
 void init(PApplet parent, int requestWidth, int requestHeight, java.lang.String name, int frameRate)
           
static java.lang.String[] list()
          Get a list of all available captures as a String array.
 void noCrop()
          Remove the cropping (if any) of the image.
 void read()
           
 void run()
           
 void settings()
          Show the settings dialog for this input device.
 void source(int which)
          Set the format to ask for from the video digitizer: TUNER, COMPOSITE, SVIDEO, or COMPONENT.
 void stop()
          Called by applets to stop capturing video.
 
Methods inherited from class processing.core.PImage
blend, blend, blendColor, clone, copy, copy, filter, filter, get, get, get, getCache, getImage, init, isModified, loadPixels, mask, mask, removeCache, resize, save, set, set, setCache, setModified, setModified, updatePixels, updatePixels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPOSITE

public static final int COMPOSITE
See Also:
Constant Field Values

SVIDEO

public static final int SVIDEO
See Also:
Constant Field Values

COMPONENT

public static final int COMPONENT
See Also:
Constant Field Values

TUNER

public static final int TUNER
See Also:
Constant Field Values

NTSC

public static final int NTSC
See Also:
Constant Field Values

PAL

public static final int PAL
See Also:
Constant Field Values

SECAM

public static final int SECAM
See Also:
Constant Field Values

data

public int[] data
Temporary storage for the raw image data read directly from the capture device


dataWidth

public int dataWidth

dataHeight

public int dataHeight

dataRowBytes

public int dataRowBytes

crop

public boolean crop
True if this image is currently being cropped


cropX

public int cropX

cropY

public int cropY

cropW

public int cropW

cropH

public int cropH

frameRate

public int frameRate

raw

public quicktime.util.RawEncodedImage raw

capture

public quicktime.std.sg.SequenceGrabber capture

channel

public quicktime.std.sg.SGVideoChannel channel
the guy who's doing all the work

Constructor Detail

Capture

public Capture(PApplet parent,
               int requestWidth,
               int requestHeight)

Capture

public Capture(PApplet parent,
               int reqWidth,
               int reqHeight,
               int frameRate)

Capture

public Capture(PApplet parent,
               int reqWidth,
               int reqHeight,
               java.lang.String name)

Capture

public Capture(PApplet parent,
               int requestWidth,
               int requestHeight,
               java.lang.String name,
               int frameRate)
If 'name' is null or the empty string, it won't set a specific device, which means that QuickTime will use that last device used by a QuickTime application.

Unfortunately, Apple's QuickTime API uses the name to select devices, and in some cases there might be cameras with the same name on a machine. If you ask for a camera of the same name in sequence, you might see if it just does the right thing and grabs each separate camera in succession. If that doesn't work, you might try calling settings() which will bring up the prompt where you can select a capture device.

If the following function:

public void captureEvent(Capture c)
is defined in the host PApplet, then it will be called every time a new frame is available from the capture device.

Method Detail

init

public void init(PApplet parent,
                 int requestWidth,
                 int requestHeight,
                 java.lang.String name,
                 int frameRate)

available

public boolean available()
True if a frame is ready to be read.
 // put this somewhere inside draw
 if (capture.available()) capture.read();
 
Alternatively, you can use captureEvent(Capture c) to notify you whenever available() is set to true. In which case, things might look like this:
 public void captureEvent(Capture c) {
   c.read();
   // do something exciting now that c has been updated
 }
 


crop

public void crop(int x,
                 int y,
                 int w,
                 int h)
Set the video to crop from its original.

It seems common that captures add lines to the top or bottom of an image, so this can be useful for removing them. Internally, the pixel buffer size returned from QuickTime is often a different size than requested, so crop will be set more often than not.


noCrop

public void noCrop()
Remove the cropping (if any) of the image.

By default, cropping is often enabled to trim out black pixels. But if you'd rather deal with them yourself (so as to avoid an extra lag while the data is moved around) you can shut it off.


read

public void read()

run

public void run()
Specified by:
run in interface java.lang.Runnable

frameRate

public void frameRate(int iframeRate)
Set the frameRate for how quickly new frames are read from the capture device.


stop

public void stop()
Called by applets to stop capturing video.


dispose

public void dispose()
Called by PApplet to shut down video so that QuickTime can be used later by another applet.


source

public void source(int which)
Set the format to ask for from the video digitizer: TUNER, COMPOSITE, SVIDEO, or COMPONENT.

The constants are just aliases to the constants returned from QuickTime's getInputFormat() function, so any valid constant from that will work just fine.


format

public void format(int which)
Set the video format standard to use on the video digitizer: NTSC, PAL, or SECAM.

The constants are just aliases to the constants used for QuickTime's setInputStandard() function, so any valid constant from that will work just fine.


settings

public void settings()
Show the settings dialog for this input device.


list

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