Thursday, June 9, 2011

Processing: Web-cam capturing in Linux

Processing is an open source and cross-platform programming language and integrated development environment (IDE). It is especially used for teaching the basics of computer programming.
Website:
http://processing.org

To capture a web-cam with processing there is a standard video library.
However it requires pre-installation of Quicktime and WinVDIG.

It seemed quite difficult for me to run this way video capturing in Linux.
Finaly I found an additional library GSVideo.
Website:
http://gsvideo.sourceforge.net

It works very similar to the standard video library. Plus it does not require pre-installation of Quicktime & WinVDIG, and works in Linux platform as well.

Below simple example shows the differences of standard video library and GSVideo library.



// Capturing web-cam with standard video library.
// It requires pre-installation of QuickTime and WinVDIG.
// Hard to use in Linux platform.

import processing.video.*;
Capture camera;

void setup(){
size(320, 240);
camera = new Capture(this, 320, 240, 12);
}

void draw(){
image(camera, 0, 0);
}

void captureEvent(Capture camera){
camera.read();
}



// Capturing with GSVideo library works cross-platform.
// It only requires additional GSVideo library as below directory order;
// <processing>/sketchbook/libraries/GSVideo
// Visit gsvideo.sourceforge.net for reference information.

import codeanticode.gsvideo.*;
GSCapture camera;

void setup(){
size(320, 240);
camera = new GSCapture(this, 320, 240);
camera.play();
}

void draw(){
image(camera, 0, 0);
}

void captureEvent(GSCapture camera){
camera.read();
}



It worked very well for me.
Hope this post helps someone else in similar case :)


No comments: