SKETCH RESUELTO
//
import processing.video.*;
color black = color(255);
color white = color(0);
int numPixels;
Capture cam;
void setup() {
size(320, 240);
strokeWeight(5);
cam = new Capture(this, width, height, 24);
numPixels = cam.width * cam.height;
noCursor();
smooth();
cam.frameRate(12);
}
void draw() {
if (cam.available()) {
cam.read();
int threshold= 70;
float pixelBrightness;
loadPixels();
for (int i = 0;i < numPixels; i++) {
pixelBrightness = brightness(cam.pixels[i]);
if (pixelBrightness > threshold) {
pixels[i] = white;
}
else {
pixels[i] = black;
}
}
updatePixels();
int testValue = get(mouseX, mouseY);
float testBrightness = brightness(testValue);
if (testBrightness > threshold) {
fill(black);
}
else {
fill(white);
};
PImage Img = loadImage(
"t.png");
PImage Img2 = loadImage("r.png");
cam.mask(Img);
image(cam, 0, 0);
image(Img2, 0, 0);
}
}