Wednesday, 29 June 2011

Video Transparency hack part II




/**
* hacked background subtraction and transparency effect in live video - needs refining!!
* E.DARE 2011
*/

import processing.video.*;
PImage star;
Capture cam;

void setup() {
size(320, 240);

cam = new Capture(this, 320, 240);
star =loadImage("back.jpg");

}


void draw() {
image(star, 0, 0, cam.width, cam.height);
if (cam.available() == true) {
cam.read();
cam.loadPixels();
color cc =color(255, 0); //

for (int x = 0; x < cam.width; x++) {
for (int y = 0; y < cam.height; y++ ) {
int loc = x + y*cam.width;
if (brightness(cam.pixels[loc])>=120) { //set your threshold here
cam.pixels[loc] = cc;//
}
}
}


}
cam.format = ARGB;
cam.updatePixels();
image(cam, 0, 0);
}

No comments:

Post a Comment