Using a webcam
The first thing you need to learn is displaying the video from your webcam, on the screen. Processing makes this very easy for you. You'll be up and running in no time, by writing a few lines of code.
How to do it...
The code for this example is really short. You need to start by importing the video
library that is included with Processing. Go to Sketch | Import Library | video, to do this. You also need to declare an object of the Capture
type. This object will be used to access the webcam on your computer.
import processing.video.*; Capture webcam;
Inside the setup()
function, you need to initialize the Capture
object with the settings you need and start capturing. In the draw()
function, we'll draw the current image from the webcam to the screen.
void setup() { size( 640, 480 ); smooth(); println( Capture.list() ); webcam = new Capture( this, width, height, 30 ); webcam.start(); } void draw() { background( 255 ); image( webcam, 0, 0 ); }
The last function...