Video Input
the Processing Video library includes a class called "Capture" to capture video from a Quicktime input device. In this example,
camera is a variable using the
Capture class.
- starting the capture: capture starts when the object is created (with 'new'). Give it the dimensions and framerate you want: new Capture(this,width,height,framerate).
- You can also give it a specific device to capture from (use the names that Capture.list() returns. for example, if you have a device named "Logitech Quickcam" you could say:
camera = new Capture (this,"Logitech Quickcam",320,240,12);
- Reading frames: the captureEvent() method gets called whenever there is a new frame available from the camera. You can use this to do processing on the image immediately when it comes in from the camera.
- Drawing frames: use the image() command in the draw() loop, just like for drawing JPGs or PNGs.
import processing.video.*;
Capture camera;
void setup()
{
size(320, 240);
// List all available capture devices to the console
println(Capture.list());
// open the default capture device at 320x240, 12 fps
camera = new Capture(this, 320, 240, 12);
// Opens the settings page for this capture device
//camera.settings();
}
void captureEvent(Capture camera)
{
camera.read();
}
void draw()
{
image(camera, 0,0);
}