OpenCV + GStreamer + Camera over IP

OpenCV + IPCam

It has been quite some time since I was looking for a simple solution for an installation using OpenCV. My main problem comes from the fact that the camera needs to be in perfect alignment with the projector axis (ideally placed right on the projector itself). And until now, I was using a hacked webcam that had to be less than 2 meters away (usb limitation) from the pc that does all the interpretation and rendering. That lead me to inextricable situations because the video projector is not always accessible or too far from the place where the computer must be (sometimes 20 meters away).

Should I mention that the solution had to be cheap or not too expensive and that the pc didn’t have any video capture card. Exit then the classic video cameras that transmit video signals over cable or even wirelessly.

Luckily, there is now what they call cameras over IP or IPCams and they’re not too expensive. The signal can then be transmitted over long distances without any special equipment (just some network cable). The problem with those cameras is the direct access to the video feed. It requires most of the time some proprietary software. Until I read this article from Nico Largo [fr]: GStreamer loves the IP Cameras from Axis

Convinced, I quickly went out to buy one (model 206) and was not disappointed. It’s not the cheapest IPCam ever but the image quality is impressive and the installation is done in less than 2 minutes. I also very much appreciate the camera stand that works like a clamp. Very useful to fix on whatever holds the projector.

And in my small Processing code using the OpenCV library, I only had to make some small changes to make it work (even better than before thanks to a better video quality and stability).

Extract from the code before:
import hypermedia.video.*;
void setup()
OpenCV opencv;
opencv = new OpenCV( this );
opencv.capture(w,h);

void draw()
opencv.read();

And after, with the GStreamer library:
import codeanticode.gsvideo.*;
import hypermedia.video.*;
GSPipeline pipe;
OpenCV opencv;
void setup()
pipe = new GSPipeline(this, "gnomevfssrc location=http://192.168.1.118/axis-cgi/mjpg/video.cgi?resolution=640x480 ! jpegdec ! ffmpegcolorspace");
opencv = new OpenCV( this );
opencv.allocate(w,h);

void draw()
if (pipe.available() == true)
pipe.read();
opencv.copy(pipe, 0, 0, 640, 480, 0, 0, w, h);