Processing for Live Video

28 05 2010

Finally I did some processing works which have similar effects with the linear image work for still images. The most different point is the new processing I did capturing video through webcam, not just still images. Which means I can use it in the show to make it live! At the same time, the webcam can capture people walking around which is a kind of the another dimension behind the office window in my pictures —- the interior.

Here are some screenshots from the three processing works.

Here are two images from works in two scales, one is 4 another is 12.

ScreenShot of window01(scale=4)

==========code===================
import processing.video.*;

int videoScale = 4;

int cols, rows;
Capture video;

void setup() {
size(800,600);

cols = width/videoScale;
rows = 1;
video = new Capture(this,cols,rows,30);
}

void draw() {
if (video.available()) {
video.read();
}
background(0);

video.loadPixels();

for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {

int x = i*videoScale;
int y = j*videoScale;
color c = video.pixels[i+j*video.width];
fill(c);
noStroke();
rect(x,y*2,videoScale+1,height);
}
}
}

screenshot of window02(scale=12)

The below two are created for simulating effect of the office window which I took. One has the same colours as the webcam captured, another one looks like in a dark background, which is good for express the things behind window in night.

screenshot of window01

screenshot of brightness01

============CODE===========================
import processing.video.*;

int videoScale = 10;
int cols, rows;
Capture video;

void setup() {
size(800,600);
cols = width/videoScale;
rows = (height/videoScale)/2;
smooth();
video = new Capture(this,cols,rows,15);
}

void draw() {
if (video.available()) {
video.read();
}
background(0);

video.loadPixels();

for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {

int x = i*videoScale;
int y = j*videoScale;

int loc = (video.width – i – 1) + j*video.width;

color c = video.pixels[loc];

float sz = (brightness(c)/255.0)*videoScale;
rectMode(CENTER);
fill(c);
noStroke();
rect(x + videoScale/2,(y + videoScale/2)*2,sz,sz*2);

}
}
}