40 lines
861 B
Plaintext
40 lines
861 B
Plaintext
import processing.video.*;
|
|
|
|
PImage tempImage;
|
|
|
|
Capture cam;
|
|
|
|
void setup() {
|
|
size(640, 480);
|
|
printArray(Capture.list());
|
|
cam = new Capture(this, width, height);
|
|
// In case if you catch this error: "BaseSrc: [avfvideosrc0] : Internal data stream error."
|
|
// use the following line
|
|
//cam = new Capture(this, width, height, "pipeline:autovideosrc");
|
|
|
|
tempImage = createImage(width, height, RGB);
|
|
|
|
cam.start();
|
|
}
|
|
|
|
void draw() {
|
|
if (cam.available()) {
|
|
cam.read();
|
|
}
|
|
|
|
image(cam, 0, 0);
|
|
blend(tempImage, 0, 0, width, height, 0, 0, width, height, LIGHTEST);
|
|
}
|
|
|
|
// this allows processing the image data separately from draw()
|
|
void captureEvent(Capture c) {
|
|
c.read();
|
|
}
|
|
|
|
void mousePressed() {
|
|
if (mouseButton == LEFT) {
|
|
tempImage.blend(cam.get(),0,0,width, height,0 ,0,width, height, LIGHTEST);
|
|
} else if (mouseButton == RIGHT) {
|
|
}
|
|
}
|