The Cube - Assimilating Technology

The Cube

UVC Camera stream

For Humans only


UVC Camera stream Print E-mail
Monday, 26 November 2007 22:09

For my birthday (or was it xmas - I forget as the two are on-top of each other),I got an Orbit Sphere Webcam.

Nice gadget, with full pan/tilt capabilities, and it looks like a massive eyeball

(I am still considering painting it to actually look like an eyeball !)

The issue was drivers. I needed to get this to work in Linux (a must in my home)

UVC Linux drivers to the rescue.

These allowed the camera to be used in Linux using th new v4l2 api system.

Note: Linux 2.6.26 and newer includes the Linux UVC driver natively.
You will not need to download the driver sources manually unless you want to test a newer version
or help with development.

My camera seems to have the firmware bug (typical) where the kernel alsa audio drivers are loaded
after the video drivers, which causes the camera to fail.

Described at this page: http://openfacts.berlios.de/index-en.phtml?title=Linux_UVC
(see known_problems)

The trick is to get the audio/alsa drivers to load first.

The workaround is not very nice, but for now it will do.
If anyone has a better way of getting this to work, please pop me an email.

I moved the driver out the way:

mv /lib/modules/2.6.24-21-generic/kernel/drivers/media/video/uvc/uvcvideo.ko /root

Once you have built the drivers (or if you are using the 2.6 kernel drivers), plug in your camera.

Here I then load my uvcvideo driver manually.

insmod /root/uvcvideo.ko 

Check dmesg output for any errors

dmesg

[432722.971391] ALSA /build/buildd/linux-ubuntu-modules-2.6.24-2.6.24/debian/build/build-generic
/sound/alsa-driver/usb/usbaudio.c:1289: 28:3:3: cannot set freq 16000 to ep 0x86
[432723.051826] usbcore: registered new interface driver snd-usb-audio
[432756.868962] usbcore: deregistering interface driver uvcvideo
[432758.263237] uvcvideo: Found UVC 1.00 device <unnamed> (046d:08c2)
[432758.612461] input: UVC Camera (046d:08c2)
[432758.622272] usbcore: registered new interface driver uvcvideo
[432758.622282] USB Video Class driver (v0.1.0)

So, now I wanted to make the camera work as a security system, to monitor a window we leave open for Kitty (yes you guessed it, our cat)

As I could not get a PC in the kitchen, close to the window, I opted to use a small pc104 ARM based
machine I had previously build in  a plan to make a car-mp3 player. (That project died off, as I just did not have the time to complete it)

I first tried to use 'motion', a Linux based system that uses a camera's to detect and record motion, but it did not suit my requirements. My camera monitors a window, and if we make coffee, we get captured by the camera. This would just not do.

So a bit of searching for the next thing, and i found ZoneMinder.  What a brilliant piece of free software.
It does what motion does, and it can define zones.

To start off, ran into the issue that ZoneMinder currently only supports v4l1 (work is being done by a zoneminder user called 'slbpatrol' on getting v4l2 working, see his post on the zoneminder forums
UPDATE:
As of July 21 2008 support for V4L2 drivers has been incorporated into Zoneminder 1.24.0)

So I had to get the camera working with zoneminder.  The obvious way was to get a stream going and then hook that stream into zoneminder as a remote camera. This will suit my needs very well, as the little pc104 board was a bit slow to do the camera and the zoneminder software all in one.

So, a bit of googling, and I stumbled upon UVC Stream ( by Tom Stoeveken ),   a nice piece of software that can stream the camera using uvc drivers, and best of all, it was designed to work on embedded system, so very very low cpu usage.

Note - I am still using version 1 of Tom's software called uvc_streamer, as it works well for me, and for this project I don't need the more advanced options that his new version
(called mjpg_streamer) gives. If it ain't broke, don't fix it :)

It compiled and installed without any issues.

Create a folder for the uvc_sources, and go into the folder

mkdir /usr/local/src/uvc_streamer 
cd /usr/local/src/uvc_streamer

Get the sources. You need subversion installed for this step.

svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer .

cd into the correct build folder

cd uvc-streamer 

build it

make 

There is no 'make install'. You are interested in the one file called 'uvc_stream', so just copy it manually
to your wanted location. /usr/local/bin works for me.

cp ./uvc_stream /usr/local/bin 

Start the streamer

/usr/local/bin/uvc_stream -f 1 -r 320x240 -b

You can change the resolution to your needs.

Check if the stream works. Use Firefox and point it to the ip address and port of the machine that runs
the streamer (default for UVC_streamer is 8080). If you use Firefox on the same machine where the
streamer runs, you can use localhost.

http://localhost:8080

I wanted to be able to control the camera motor (It would be a waste not to)  So I contacted Tom, and asked about adding it, and a week later I sent some patches to him, which he graciously included in uvc_stream.

Check if you can control the camera on port 8081

http://localhost:8081?control 

 

Things were looking good.

A bit of experimentation, and I managed to get zoneminder to accept the stream. I posted the information
on their wiki.

So now I had my uvc camera, installed  on a small embedded system, and streaming it to zoneminder that
was running on my Linux server.

In the image below you can see the window, and my 'zone' defined that only covers the window.

Active Image

Below is a picture of the little control panel.

Active Image

This is currently where this little project has come to rest, as I am a bit busy with some websites.

Update: I reccently create a perl motor control script forsomeone, but this is not for use with uvc_streamer
mentioned in the text above, but for the new version called mjpg_streamer.
You can download the script, and place it in the control folder of your zoneminder install. If you don't know
where that is, find a file called PanasonicIP.pm on your system, and place the file in the same folder.

The script gives basic Pan/Tilt and reset functionality. The intention is to update it soon with more control
commands. (focus, etc)

This script is now available in ZoneMinder 1.24.1 package.

 

 

 

Last Updated on Friday, 26 February 2010 07:21
 
Share on facebook