import processing.video.*; class CamModule { private Capture cam; private PImage frame; private int w, h, offSet; CamModule(PApplet applet, int _w, int _h, int _o) { w = _w; h = _h; offSet = _o; String[] devices = Capture.list(); //println(devices); //comment in the above line if you don't know which port your webcam is plugged into cam = new Capture(applet, width, height, devices[1]); frame = createImage(w, h, RGB); } public PImage bitmap() { //read the full image from the webcam and copy out the pixels needed if (cam.available()) { cam.read(); frame.copy(cam, offSet, 0, w, h, 0, 0, w, h); } return frame; } }