![]() |
Adding a USB webcamNote: the first part of this page is severly outdated. I believe the ov511 etc are supported standard by kernel-module-ovcamchip. For Philips chip based webcams there is package pwc (together with its companion setpwc). The first part concerns the ov511 driver e.g. for the Avermedia Intercam webcam. If you have a Logitech Quickcam Messenger, see UseALogitechQuickcamMessenger. I have bought a lot of computer equipment in my days, but few things have I used as little as my webcam. It has basically lived its life in one of those drawers that also house SCSI to D-shell cables and other things once thought useful. Since my webcam, an AverMedia InterCam Elite, is probably one of the worst commercial webcams ever made, I had little idea that it would leave its drawer for anything but the garbage. Well, with the slug it got another brief smell of life. Fortunately these drivers support more than the crappy AverMedia InterCam Elite -- the list is extensive and include all (eh... "warning: broad sweeping statement") cameras using the OV511 and compatible (OV518 etc) controllers with various sensor types. For a good list of webcams and the controllers they use, see http://webcam-osx.sourceforge.net/cameras/index.php?orderBy=controller Also note that the module that needed to be changed is the generic module videodev.o and most controller specific modules can now be used with no change, like with most of the Creative Webcams. Have a look in the Linux support list to see whether your camera is listed and make some noise to have it compiled. Unslung 5.x: Getting the softwareSince 5.0 using a cam is really easy as all required kernel modules are available as ipkg packages. Just type:
**note**: This dependencies warning can be disregarded. Then load the drivers using
and see the 'Testing it' chapter below. Building it yourself
Alternative kernel compileEdit build/conf/local.conf and add the lines: then rm tmp/stamps/openslug-kernel-2.6.9-r11.do_configure and run the results should end up in the Getting it running for testing
Testing itNow your driver need a test application to see that the driver is working. I compiled w3cam, which provides a CGI script for putting webcam still images in your web pages. I made this work with the stock Linksys thttpd, though I managed to crash my slug by running multiple concurrent instances. Better for our purpose is the vidcat command line program for fetching a still image. I put both these programs as well as ppmtoascii (all compiled to use /dev/video0) in http://folk.uio.no/ingeba/w3camapps.tar.gz, but I suggest looking elsewhere for better webcam apps. I tried compiling several others using the old native toolchain, but most builds failed compilation with "CPP preprocessor failed sanity check" or "syslimits.h not found". This is fixed in a new version of the native toolchain coming out, so don't bother trying with the old one. Do cross compile or wait for new native toolchain.
Loading the driver modules on startupCreate a file named S89wcam in /opt/etc/init.d as this:
and make it executable (chmod +x S89wcam). OpenSlug methodThe OpenSlug is a bit different. Building vidcatI think the vidcat supplied in the tgz of this page might also work but I wanted to attempt to build it.
DESCRIPTION="Set of small programs to grab images and videos from video4linux devices" SECTION = "media-gfx" LICENSE = "GPLV2?" DEPENDS="jpeg" SRC_URI="http://mpx.freeshell.net/${P}.tar.gz" inherit autotools
Note: currently there is a working bb file in the openslug development head. vidcat command lineI had to muck about with the palette and size args to make it work. Otherwise you just get VIDIOCMCAPTURE: Invalid argument args: width=320 height=240 palette=4 Error: Can't get image For my camera, creative brand: tftpTo download files to the slug, from the slug prompt: You'll need to put the files in the tftproot dir if running tftpd with -s and make sure the tftpd user (nobody by default) can read the file. I had to configure tftpd to allow access to uploading into the tftproot directory. Run tftpd with -s /tftproot -c -p and make sure that the nobody user can write to the tftproot dir. Once you've got it working you can tighten up security by running as a special user etc. Troubleshooting
Making the installation permanentThis works until you reboot, for two reasons:
FutureIf this becomes stable, we can expect:
I thought I'd place my camera in the window of my Oslo apartement so I can browse to it from Amsterdam to see what the sun looks like from time to time. Bob_tm Webcams using the pwc driver, e.g. Logitech Quickcam Pro 4000There are two different approaches to get this done. The text just below is Unslung related. After that (large) section there is also a section on Openslug. Note also that a PWC webcam might not work properly if you connect it to the slug with a USB 2.0 hub. Best thing is to use a 1.1 hub or to connect directly to the slug. PWC: the Unslung methodAssumes you have crosstool-0.28-rc35 or later installed on a Linux machine. To build the pwc.o module follow these steps: Get pwc-9.0.2.tar.gz from http://www.smcc.demon.nl/webcam. Note: Development for this driver stopped a long time ago, with verion 9.0.2, but a new project took over, at http://www.saillard.org/linux/pwc/ . It includes all the features of 9.0.2, including those which were only available using the binary decompressors. The instructions below use the 9.0.2 version, but it would probably be worth testing the new driver. Unpack only the 2.4 part for instance in /tmp: cd /tmp tar xvzf pwc-9.0.2.tar.gz pwc-9.0.2/2.4 Go to that directory: cd /tmp/pwc-9.0.2/2.4 Add the following before the #includes in the file pwc-if.c: static void set_bit(int nr, volatile void *addr)
{
((unsigned char *) addr)[nr >> 3] |= (1U << (nr & 7));
}
static void clear_bit(int nr, volatile void *addr)
{
((unsigned char *) addr)[nr >> 3] &= ~(1U << (nr & 7));
}
This fixes getting unresolved symbols. I do not know why set_bit and clear_bit do not get properly resolved. Get a copy of videodev.c there as well: cp /usr/src/linux-2.4.22/drivers/media/video/videodev.c . Add this Makefile: EMULATION = armelfb_linux ARCH = armv5 CC = armv5b-softfloat-linux-gcc LD = armv5b-softfloat-linux-ld KERNEL_INCLUDE = /opt/crosstool/armv5b-softfloat-linux/gcc-3.3.4-glibc-2.2.5/armv5b-softfloat-linux/include MODVERSIONS = CFLAGS = -D__KERNEL__ -DNEED_SETBIT -I$(KERNEL_INCLUDE) -Wall -Wstrict-prototypes \ -Wno-trigraphs -O2 \ -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe \ -march=$(ARCH) -mbig-endian -DMODULE -DMODVERSIONS -nostdinc -iwithprefix include $(MODVERSIONS) LDFLAGS = -m $(EMULATION) -r all: pwc.o videodev.o clean: -rm *.o pwc-if.o: $(CC) $(CFLAGS) -DKBUILD_BASENAME=pwc_if -c -o pwc-if.o pwc-if.c pwc-misc.o: $(CC) $(CFLAGS) -DKBUILD_BASENAME=pwc_misc -c -o pwc-misc.o pwc-misc.c pwc-ctrl.o: $(CC) $(CFLAGS) -DKBUILD_BASENAME=pwc_ctrl -c -o pwc-ctrl.o pwc-ctrl.c pwc-uncompress.o: $(CC) $(CFLAGS) -DKBUILD_BASENAME=pwc_uncompress -DEXPORT_SYMTAB -c pwc-uncompress.c pwc.o: pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o $(LD) $(LDFLAGS) -o pwc.o pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o videodev.o: $(CC) $(CFLAGS) -DKBUILD_BASENAME=videodev -DEXPORT_SYMTAB -c videodev.c Set the correct environment: export PATH=/opt/crosstool/armv5b-softfloat-linux/gcc-3.3.4-glibc-2.2.5/bin And now issue the make command: /usr/bin/make -f Makefile This will result in the pwc.o and videodev.o modules for a big-endian ARM running a Linux 2.4.22 kernel (like the Unslung NSLU2). First, make sure you have a video device on the slug: mknod /dev/video0 c 81 0 mknod /dev.state/video0 c 81 0 chown admin.everyone /dev/video0 chown admin.everyone /dev.state/video0 chmod g+w /dev/video0 chmod g+w /dev.state/video0 Then copy the modules over to the slug and put them in /opt/lib/modules. Install them with: insmod /opt/lib/modules/videodev.o insmod /opt/lib/modules/pwc.o It is up to you to write the necessary rc diversion scripts to have this done upon every boot. You could just put the insmod commands in /share/hdd/conf/unslung/rc.local. Get some webcam utility that accesses the webcam via the videodev interface. I used vidcat from w3cam-0.7.2.tar.gz and compiled it on the slug using the crosstool-native packages. Mind that I had to resort to using the read() call instead of mmap() (see vidcat.c) to get my Logitech Quickcam Pro 4000 working but only at 160x120 resolution. I use the command "vidcat -s 160x120 -p y". You can also find the precompiled binaries for pwc.o, videodev.o, vidcat and setpwc in the "files" section of the Yahoo nslu2 news group (click on Yahoo group in sidepanel on the left). Have fun, Geert PWC: the Openslug methodNote: the text below used the pwc driver from the kernel. This one is quite old. Instead better use the driver from the pwc package. In order to get my cam up and running I did the following.
Rebuild the kernel. Make sure that in your defconfig file the line I also needed v4l2_common.ko. If I recall correctly this came with videodev. Anyway, when you have these three files you can just copy them to the slug, insmod them, do a depmod -a and off you go. However instead, I decided to go for the latest version (10.0.7a). As the version in Openslug is older, I just did a build as before, then overwrote my tmp/work/*kernel*/linux*/drivers/usb/media/pwc directory with the 10.0.7a version (from www.saillard.org). After that remove tmp/stamps/*kernel*compile and do a bb openslug-kernel That will give you the most recent .ko file Note that this last thing is not very decent. If you do a bb -cclean or so, your changes will be lost. However, I am not comfortable enough with bb and friends to do that in a nicer way. Make the entries in /dev as needed (see above) and compile vidcat. With that you should be able to grab pictures, e.g. with "vidcat -s 160x120 -p y". I also managed to compile the sound drivers. I'm not really sure what I changed to do that (sorry!). I definitely changed in defconfig: CONFIG_SND_USB_AUDIO=m But it is quite possible I also enabled some of the following: CONFIG_SND=m CONFIG_SND_TIMER=m CONFIG_SND_PCM=m CONFIG_SND_HWDEP=m CONFIG_SND_RAWMIDI=m # CONFIG_SND_SEQUENCER is not set CONFIG_SND_OSSEMUL=y CONFIG_SND_MIXER_OSS=m CONFIG_SND_PCM_OSS=m The most tricky thing here was to get them loaded in the right order. Here is the output of lsmod on my slug to help you getting started: snd_usb_audio 44800 0 snd_pcm 54472 1 snd_usb_audio snd_timer 14020 1 snd_pcm snd_page_alloc 4584 1 snd_pcm snd_usb_lib 9120 1 snd_usb_audio snd_rawmidi 13056 1 snd_usb_lib snd_hwdep 4324 1 snd_usb_audio snd 26680 5 snd_usb_audio,snd_pcm,snd_timer,snd_rawmidi,snd_hwdep soundcore 3844 1 snd Note that although everything loads, I still have been unable to get any sound from the cam (although I can get sound on it on my fedora system). PWC: The Debian NSLU2 methodhttp://www.cyrius.com/debian/nslu2/ 1. Get the Installer mkdir ramdisc /*create a directory for your ramdisc in the root directory mkfs /dev/ram0 /*maybe we should put this into an init script mount /dev/ram0 /ramdisc /*mount your ramdisc /etc/ffserver.conf:(only Real Media seems to work for me) Port 8090 <Feed feed.ffm> File /ramdisc/feed.ffm FileMaxSize 1M ACL allow 127.0.0.1 </Feed> /* Real Media /* cif 352x288 <Stream cam.rm> Feed feed.ffm Format rm AudioBitRate 32 VideoBitRate 500 VideoFrameRate 6 VideoSize cif </Stream> Start streaming with the following two commands: ffserver ffmpeg -vd /dev/video0 http://localhost:8090/feed.ffm Output from ffmpeg: FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2004 Fabrice Bellard configuration: --enable-gpl --enable-pp --enable-pthreads --enable-vorbis --enable-libogg --enable-a52 --enable-dts --enable-libgsm --enable-dc1394 --disable-debug --enable-shared --prefix=/usr libavutil version: 0d.49.0.0 libavcodec version: 0d.51.11.0 libavformat version: 0d.50.5.0 built on Oct 7 2006 07:39:35, gcc: 4.1.2 20060920 (prerelease) (Debian 4.1.1-14) [video4linux2 @ 0x4009a104][4]Capabilities: 5000001 Input #0, video4linux2, from '': Duration: N/A, bitrate: N/A Stream #0.0: Video: rawvideo, yuv420p, 352x288, 7299 kb/s, 6.00 fps(r) Input #1, audio_device, from '': Duration: N/A, bitrate: N/A Stream #1.0: Audio: pcm_s16le, 22050 Hz, mono, 352 kb/s Output #0, ffm, to 'http://localhost:8090/feed.ffm': Stream #0.0: Audio: ac3, 22050 Hz, mono, 32 kb/s Stream #0.1: Video: rv10, yuv420p, 352x288, q=3-31, 500 kb/s, 6.00 fps(c) Stream mapping: Stream #1.0 -> #0.0 Stream #0.0 -> #0.1 Press [q] to stop encoding [rv10 @ 0x4044234c]rc buffer underflow frame= 23 q=1.6 Lsize= 176kB time=3.8 bitrate= 376.1kbits/s video:103kB audio:18kB global headers:0kB muxing overhead 45.889019% Receive your Webcam Video/Audio Stream on client side with the following command: mplayer http://<your-nslu-ip-number>:8090/cam.rm /* You can also use Realplayer 8 to rcceive your webcam stream, but Realplayer 10 does not work ! Output from mplayer: MPlayer 1.0rc1-SUSE Linux 10.1 (i686)-Packman-4.1.0 (C) 2000-2006 MPlayer Team CPU: Intel(R) Pentium(R) M processor 1.73GHz (Family: 6, Model: 13, Stepping: 8) CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. Can't open joystick device /dev/input/js0: No such file or directory Can't init input joystick mplayer: could not connect to socket mplayer: Connection refused Failed to open LIRC support. You will not be able to use your remote control. Playing http://192.168.1.77:8090/cam.rm. Resolving 192.168.1.77 for AF_INET6... Couldn't resolve name for AF_INET6: 192.168.1.77 Connecting to server 192.168.1.77[192.168.1.77]: 8090... Cache size set to 320 KBytes Cache fill: 17.50% (57344 bytes) REAL file format detected. Stream description: The Audio Stream Stream mimetype: audio/x-pn-realaudio Stream description: The Video Stream Stream mimetype: video/x-pn-realvideo VIDEO: [RV10] 352x288 24bpp 6.000 fps 0.0 kbps ( 0.0 kbyte/s) ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffrv10] vfm: ffmpeg (FFmpeg RV10 decoder) ========================================================================== ========================================================================== Opening audio decoder: [liba52] AC3 decoding with liba52 Using SSE optimized IMDCT transform Using MMX optimized resampler AUDIO: 22050 Hz, 2 ch, s16le, 32.0 kbit/4.54% (ratio: 4000->88200) Selected audio codec: [a52] afm: liba52 (AC3-liba52) ========================================================================== AO: [oss] 22050Hz 2ch s16le (2 bytes per sample) Starting playback... VDec: vo config request - 352 x 288 (preferred colorspace: Planar YV12) VDec: using Planar YV12 as output csp (no 0) Movie-Aspect is undefined - no prescaling applied. VO: [xv] 352x288 => 352x288 Planar YV12 A: 11.2 V: 11.2 A-V: 0.003 ct: -0.331 68/ 68 2% 0% 0.2% 2 0 18% Have Fun, Peter =========================================================================== Quickcam 4000 Webcam on Debian Etch RC2?I had an old Logitech Quickcam 4000 lying around so I decided to see if it could be made to work on a Slug. It turns out it is one of the easiest webcams to support, using the Philips pwc driver, If you are not sure which USB webcam you have, try plugging it in and typing lsusb You can check that the driver is not already loaded with lsmod and if not, see if it can be loaded modprobe pwc lsmod I was pleasantly surprised to find that the module was available and loaded fine. To have it load automatically in future on reboot add the following to /etc/modules # for webcam pwc with your favourite editor. After this the video device should become available, and can be identified with this command, mine turned out to be /dev/video0, which is normal: ls /dev/video* You can check it is working OK with the simple framegrabber application Streamer: apt-get install streamer streamer -c /dev/video0 -b 16 -o webcamfile.jpeg You will need to copy webcamfile.jpeg to your client to view it, it should be a single frame image from your webcam, so remember to smile ;-) The next step was to find a proper webcam application. The first I came across was the imaginatively named ‘webcam’. I installed it and after a fair bit of digging in the man files and surfing finally got it to work. Quirkily it uses a config file called /root/.webcamrc . The default supplied is mostly rubbish for our purposes. Also I suggest you supply the full filename when editing it in your fave editor so you don’t end up editing a file in the wrong place which will be ignored. I have copied my file here which should be easy enough to follow along with the man page: apt-get install webcam
nano /root/.webcamrc
[grab]
device = /dev/video0
text = "NSLU2 webcam m-H:S (BST)"
# infofile =
fg_red = 255
fg_green = 255
fg_blue = 255
width = 640
height = 480
# delay = number of seconds between snapshots
delay = 30
wait = 1
input = usb
norm = webcam
rotate = 0
top = 0
left = 0
bottom = -1
right = -1
quality = 75
trigger = 0
once = 0
# archive =
[ftp]
host = 127.0.0.1
user = root
pass = xxxx
dir = /var/mywebroot/webcam
file = webcam.jpeg
tmp = uploading.jpeg
passive = 1
debug = 0
auto = 0
# local = 1 means just use the local directory specified above, do not use ftp or ssh
local = 1
ssh = 0
You can then start webcam webcam and test that it is working by pointing your browser at <your web root>/webcam/webcam.jpeg in the above example. I found it ran well, using negligible resources, and it was easy to knock up some html to pretty it up a bit and auto refresh. If you want it to run automatically you could set up a crontab: crontab -e @reboot /usr/bin/webcam A (much) more sophisticated webcam package which includes motion detection is the equally imaginatively called ‘motion’. This is so complex that it has its own wiki (always a bad sign!) but it wasn’t too hard to get running: apt-get install motion and a more conventionally named /etc/motion/motion.conf # Minimal motion example config file provided by the # Debian motion package - for basic webcam operation. # # You most certainly want to investigate # /usr/share/doc/motion/examples/motion-dist.conf.gz # for further configuration options. Also, refer to the # motion man page and /usr/share/doc/motion/motion_guide.html # for detailed information on configuration options. daemon on quiet on # You may very well need to change this (check with 'dmesg' # after plugging in your webcam). videodevice /dev/video0 # Image size in pixels (valid range is camera dependent). width 320 height 240 # framerate 2 quality 85 auto_brightness off # # Make automated snapshot every N seconds (default: 0 = disabled) snapshot_interval 60 # # General threshold level and noise threshold # level (for distinguishing between noise and motion). threshold 4500 noise_level 64 # # Initial brightness, contrast, hue (NTSC), and saturation. # 0 = disabled (valid range 0-255). brightness 0 contrast 0 saturation 0 hue 0 # # for low-powered cpus low_cpu 1 # # Target base directory for pictures and films (you may need # to change this (or change its permissions) depending on # which system user runs motion). target_dir /var/mywwwroot/motion/snapshots # # filenames recycle after 1 month jpeg_filename HS-%q # # snapshot_filename YdM%S-snapshot snapshot_filename last-snapshot # # Define a port number (e.g. 8000) to enable the mini-http server. # 0 = disabled. webcam_port 0 # # Set to 'off' to allow anybody (not just localhost) to view the # webcam via the mini-http server (http://hostname:port). webcam_localhost off # webcam_quality 50 webcam_maxrate 1 Start motion from your shell and because of the daemon on setting it will run as a daemon and begin both taking 60 second snapshots (overwriting the same jpeg file in this case), and creating one jpeg per frame while detecting motion. If you like you can stream near-real-time images via its built in web server to a chosen port but be prepared for 97% CPU usage while doing it! In fact performance generally seems to be on the margins for a Slug. I disabled the mini-server, set all the frame rates to their minimum, added the low-cpu statement, and reduced the video size to 320x240. Collectively these took CPU and Memory usage down from both being at about 20% to both being at about 10%, which I guess is just about OK for most users. Beware that by default the motion detection creates zillions of jpeg files, one per frame while something is moving in the webcam’s field of view. I changed it to loop around the day of the month, by changing the filename, which I estimate would create at worst a few gigabytes of data. If you are shorter of space you could loop around say a days or even an hours worth of files, although it could be frustrating to arrive home only to find the only image you had of a burglar was a shot of his arse disappearing thru the window... I didn’t try out any of the timelapse or mpeg creation options yet, maybe I will give these a go at a later date. In the meantime I have created a rough webcam page here http://www.zonko.ath.cx/webcam.html where you can see either webcam or motion in action (though only one at a time!). I can’t promise it will always be on, though. Having proved the concept I’m not sure really where I want to put it or how to best use it.... Vic Z ==================================================================================== NSLU2 Webcamshttp://www.matthewsmith.id.au/webcam.php http://wake.willmeroth.com/webcam.html - No live images as of Dec 8,2006 http://tech.groups.yahoo.com/group/nslu2-linux/message/16388
view ·
edit ·
print ·
history ·
Last edited by jeff.
Based on work by Naomi, Robert, fcarolo, Vic Z, Peter Bauer, Sebastian Kraatz, Jack Kozik, pebainodeat, eFfeM, Werner Teeling, CelticWonder, David Johnson, StefanWillmeroth, Ed, skraatz, tman, djfoobarmatt, Geert Janssen, scott, and bobtm. Originally by bobtm. Page last modified on July 29, 2007, at 02:43 AM
|