From ElphelWiki
Jump to: navigation, search

Single image

You can use imgsrv to download a single image from the circbuf. MJPEG live stream is also available from imgsrv.

You can use wget to download the image to your computer or implement a small HTTP client in your software.

Live video

Using AVLD

AVLD stand for AVLD - Another Video Loopback Device. It's a very CPU and RAM consuming way to present an Elphel network camera as V4l device.

While it is the only solution with proprietary v4l compatible software products (such as skype), it's a total waste of resources for a free software app what can be adapted to receive an RTP stream.

Moreover, you can proceed to download the source code from:


 $ tar -jxvf avld_0.1.4.tar.bz2
 $ cd avld_0.1.4
 $ make && sudo make install

Right now you can mount your dummy device typing:

 $sudo modprobe avld width=<camera width resolution> height=<camera height resolution> fps=<camera fps>

Finally, you need to use mencoder in order to redirect the rtsp source to the dummy device:

 $ sudo mencoder rtsp:// -nosound -ovc raw -vf format=bgr24 -of rawvideo -o /dev/video0

With this, you just need a simple code in order to preview the scene:

 #include "highgui.h"
 #include "cv.h"
 #include "cvaux.h"
 #include <ml.h>
 int main(int argc,char *argv[])
   cvNamedWindow( "Current Frame");
   IplImage* pCurrentFrame = NULL;
   CvSize frame_size;
   CvCapture* capture = cvCaptureFromCAM ( 0 ); //the dummy device make the job :)
   char c;
   while ( 1 )
       //Request frame from Camera
       pCurrentFrame = cvQueryFrame ( capture );
       //video input file finished		
       if( !pCurrentFrame ) break;
       cvShowImage( "Current Frame", pCurrentFrame );
       c = cvWaitKey(10);
       if ( c == 27 ) break;
   cvReleaseImage ( &pCurrentFrame );
   cvDestroyAllWindows ();
   return 0;

--Esteban Correa 21:54, 29 July 2010 (CDT)

Using v4lsink GStreamer plugin and v4l2loopback

This is basically an AVLD fork that now evolved into v4l2loopback and a special gstreamer sink to the loopback device.

You can find the projects homepages at: (This version does not compile due to vala dependencies, somebody cloned and patched the project, it is available from github:

To install it do:

hg clone v4l2loopback  
cd v4l2loopback
make install

load the module:

modprobe v4l2loopback

To compile v4lsink you will need Vala compiler >= 0.8.1, the easy way is to install the package from Vala PPA:

sudo add-apt-repository ppa:vala-team/ppa
sudo apt-get update
sudo apt-get install valac vala-utils

It will install valac 0.9.1 instead of default 0.8.0 under Ubuntu 10.04.

Install v4lsink:

git clone
cd gst-v4l2loopback
make install

This will install the new gstreamer module in ~/.gstreamer-0.10/plugins/ folder. Now you can try "gst-inspect v4l2loopback"

Default resolution is fixed to 640x480, if you want to change the resolution, you can change it in the two places of the v4l2loopback.c file and recompile/reinstall v4lsink.

To test it with an RTSP stream from an Elphel camera you need to feed the stream into the loopback device:

gst-launch -e -m rtspsrc location=rtsp:// latency=50 ! rtpjpegdepay ! jpegdec ! ffmpegcolorspace ! v4l2loopback

Now you can open the stream as v4l2 device with any compatible program:

mplayer tv:// -tv device=/dev/video1

To test with OpenCV simply change the v4l2 device number:

// CvCapture* capture = 0;
   CvCapture* capture = 1;

Using OpenCV with FFMPEG

Using OpenCV with GStreamer

Design your OpenCV code as GStreamer plugin



Tennis balls recognizing

OpenCV Tennis balls recognizing tutorial

Go game record (kifu) generator