This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.
Name |
Capture |
Examples |
import processing.video.*;
Capture cam;
void setup() {
size(640, 480);
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
// The camera can be initialized directly using an
// element from the array returned by list():
cam = new Capture(this, cameras[0]);
cam.start();
}
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(0, 0, cam);
}
|
Description |
Datatype for storing and manipulating video frames from an attached capture device such as a camera. Use Capture.list() to show the names of any attached devices. Using the version of the constructor without name will attempt to use the last device used by a QuickTime program.
|
Methods |
available() |
Returns "true" when a new video frame is available to read |
start() |
Starts capturing frames from the selected device |
stop() |
Stops capturing frames from an attached device |
read() |
Reads the current video frame |
list() |
Gets a list of all available capture devices such as a camera |
|
Constructor | Capture(parent)
Capture(parent, requestConfig)
Capture(parent, requestWidth, requestHeight)
Capture(parent, requestWidth, requestHeight, frameRate)
Capture(parent, requestWidth, requestHeight, cameraName)
Capture(parent, requestWidth, requestHeight, cameraName, frameRate)
|
Parameters |
parent |
PApplet: typically use "this" |
requestWidth |
int: width of the frame |
requestHeight |
int: height of the frame |
frameRate |
int: number of frames to read per second |
cameraName |
String: name of the camera |
|
Updated on January 21, 2019 10:05:15am EST