Video processing

I’ve been experimenting with processing for webcam manipulation. The code is as simple as setting up an array of pixels to store the screen data (which is built in to processing pixels[]) and an array to store the incoming video data. Then filtering the video data onto the screen data. Like this:

int numPixels;
Capture video;

void setup() {
size(400, 300);
video = new Capture(this, w, h, "USB Vimicro301 -WDM", 30);
numPixels = 400*300;


void draw() {

loadPixels(); //stores the current screen into pixels array; //store webcam image into video.pixels array

for(int i=0; i<numPixels; i++){
//***apply some filters/conditionals here***
pixels[i] = whatever you've done to video.pixels[i]


In the setup() function the first time you run this program on your computer it will print out a list of any available webcam inputs. Stop the program and change the video= line so the name of the webcam is one of yours. Vimicro was one of my webcams. Additionally in Windows you may need to install a program called WinVDig to get java to talk to quicktime, this is all documented on the processing site.

This is so easy relative to what I used to try and do for Java that this is one area in which i use Processing over Java currently.

Centrifugal & Centripetal

After trying out other filters I had this idea – two screens with webcams would be setup – on one the video capture rushes out from the centre to the outside. In the other it is sucked into the middle. This was partly inspired by this book cover:

The centrifugal one was pretty easy to code – using an inbuilt function copy() which just copies a section of the screen from one place to another – this could be enlarged & copied over itself, and is pretty fast. So all i needed to do was to slightly enlarge, and then copy a new set of pixels from the current video grabbed frame into the centre. This was done with an elipse shaped section in the middle of the image. To make this faster the elipse array was precalculated.

Centripetal was more difficult – the problem being that the copy() function loses accuracy when applied to small areas. The function must use integer maths to shrink the pixels so in the end a lot of linear artefacts appear, as the calculated floats are rounded down to ints. The middle section is too small to ever change as it’s only reducing down by about 98%. So i needed to find a different technique that was quick. There are various interpolation techniques which would have done the job – where each new pixel is made up of an interpolated average of the surrounding pixels, but this would be too slow – it’s the type of thing that Photoshop uses to resample images. Instead i found online a very clever idea which was to just arbitrarily remove vertical or horizontal lines from the image (and shove all the other lines across). As long as the lines are chosen randomly then the effect is a pretty smooth shrinkage. This became the piece Centripetal.

In one way I see the two pieces as novelties – their connection to my project is that in both cases, movement is recorded as a visual trail. It is possible to stretch noses, etc… When a show came up themed after an excerpt from a Victor Hugo quote ‘Egg,Nest,House,Country’, i couldn’t resist showing them as they fitted the quote so well 1) both pieces feature elipses (eggs) 2) both were about scaling . Centripetal also displayed a in built Union Jack effect given the right background, as seen below. The pieces were received with some glee at the show in Wilson’s Road corridor. People said it reminded them of the fun house mirrors you get at fairgrounds – which they do. But being with the pieces for longer today made me more convinced that they hold their own artistically too.

I haven’t tried pointing the two webcams at each other yet – reminscent of moshe and Katrin’s work last year. That shoud be interesting.

I plan to experiment more with Processing webcam works. I like their simplicity, and that they keep on working whether anyone is looking or not – shovelling pixels from one place to another in a pointlessly spiralling universe.


A third processing program (“Trailer”) was shown at the House Gallery as part of the Feedback show. Unfortunately the lighting conditions meant the documentation didn’t turn out well. I plan to redocument the program in college but I’ll have to re-write it as the computers that i tried it on there weren’t powerful enough to run the program at high enough resolution. The piece gave the effect of leaving a trail behind the viewer as they moved in front of the webcam. This is done by storing a worm of previous frames and removing the end of the worm, so not a feedback effect which was how the Jackson video above was done.
This piece once improved may be part of the end of year show as it neatly explains the type of process I’ve been using in my sculptures, and thus enriching both.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: