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

captureEvent()

Examples
import processing.video.*; 
Capture cam; 
 
void setup() { 
  size(200, 200); 
  cam = new Capture(this);
  cam.start(); 
} 
 
void draw() { 
  image(cam, 0, 0); 
} 

void captureEvent(Capture c) {
  c.read();
}
Description This event function is run when a new camera frame is available. Use the read() method to capture this frame. If there is more than one capture device in the program, captureEvent() is called each time any of the devices has a new frame available. Use an if within the function to determine which device is triggering the event.

This function is for people who want to process the image data separately from drawing (and as quickly as possible.) You cannot draw to the screen inside the captureEvent() function. If you want to draw immediately based on the new image, then use the Capture.available() method.
Syntax
void captureEvent(Capture which) {
  statements
}
Parameters
statements any valid statements
which the camera with the event
RelatedCapture
Updated on January 1, 2021 03:38:11am EST