Time Delay Video with overlaying
import processing.video.*;
Capture cam;
Capture stream;
PImage[] buffer;
int w = 640;
int h = 480;
int nFrames = 60;
int iWrite = 0, iRead = 1;
void setup(){
size(640, 480);
cam = new Capture(this, w, h);
cam.start();
buffer = new PImage[nFrames];
stream = new Capture(this, w,h);
stream.start();
}
void draw() {
if(cam.available()) {
cam.read();
stream.read();
buffer[iWrite] = cam.get();
if(buffer[iRead] != null){
tint(255,110);
image(buffer[iRead], 0, 0);
}
iWrite++;
iRead++;
if(iRead >= nFrames-1){
iRead = 0;
}
if(iWrite >= nFrames-1){
iWrite = 0;
}
image(stream, 0,0);
}
}