Connecting to the Camera
Note: This page is out of date. We are now retrieving images from the camera using RTSP and GStreamer, since the avld and mplayer combination proved unreliable and processing-intensive.
For the moment we are simply piping images from the Elphel camera to OpenCV for processing. OpenCV's highgui library is capable of capturing images from cameras via Linux's v4l (video for Linux) API. However, the v4l interface is intended for video capture hardware like webcams and cable framegrabber cards, not the Elphel, which interfaces via Ethernet. Therefore we have to convert the camera's RTSP video stream into something v4l can understand and feed that into OpenCV via a loopback video device.
These instructions are based on those on the Elphel Wiki.
Creating the loopback device
Download and build AVLD, the video loopback kernel module. Just grab the tarball and make && sudo make install. The current version is 0.1.4.
Insert the kernel module with the command:
sudo modprobe avld width=2592 height=1936 fps=0
The width and height must match the size of the image coming from the camera.
Feed the loopback device
Now we use mencoder, a part of the mplayer package, to feed the video stream. Unfortunately, because the images coming from the camera are so large they exceed the size that the default mplayer build expects in an RTSP stream, we must build mplayer ourselves to get this to work. See the on Elphel's wiki. You should sudo apt-get remove mplayer (if you already have it installed) before doing the build, which will take a while.
Okay, now that you have the right mplayer we can feed the video loopback device. If you're doing this on your laptop you're probably not going to run mencoder as root, so we need to make the video device writable.
sudo chmod o+rw /dev/video0
(If you had other video devices on your system before you inserted the AVLD module this may be /dev/video1, etc. You'll need to adjust the instructions accordingly.)
Now issue the following command to feed the video device:
mencoder rtsp://rtcam.dhcp.rose-hulman.edu -nosound -ovc raw -vf format=bgr24 -of rawvideo -o /dev/video0
You can preview it by running mplayer:
mplayer tv:// -tv driver=v4l:device=/dev/video0:outfmt=rgb24 -cache 8192 -vo x11
If the camera isn't available you can do testing with a file by substituting the file name for rtsp://rtcam.dhcp.rose-hulman.edu, but you'll need to have modprobed AVLD with the appropriate height and width or change the parameters with echo "width=WIDTH height=HEIGHT fps=0" > /dev/video0.

