Files
sunny9898/task7/wk5_example4/wk5_example4.pde
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

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) {
}
}