Webcam-Howto.

Aus Weimarnetz Wiki
Zur Navigation springen Zur Suche springen

Benoetigte Pakete

usb und video-Module installieren

ipkg install kmod-usb-ohci oder kmod-usb-uhci  (abhängig vom Gerät)
ipkg install kmod-usb2                         (nur bei Gerät mit USB 2.0 nötig)
ipkg install libpthread
ipkg install kmod-videodev

danach Neustart. USB-module werden selbsttätig geladen.

Driver

es gibt mittlerweile 4 Webcam-Driver von openwrt

spca5xx/spca5xx_LE

  • Installation:
Welches Driver-modul ihr braucht kommt auf Eure Kamera an --> Uebersicht
# spca5xx-Modul
ipkg install http://ping02.stura.uni-weimar.de/dave/kmod-spca5xx_2.4.30+20060501-brcm-1_mipsel.ipk


# spca5xx/LE-Modul
cd /tmp
wget http://ping02.stura.uni-weimar.de/dave/spca5xx_lite.o.gz
mv spca5xx_lite.o.gz /lib/modules/2.4.30
cd /lib/modules/2.4.30/
gunzip spca5xx_lite.o.gz

danach Neustart.
Die Module werden leider nicht beim Neustart selbstständig geladen. Webcammodule laden mit

insmod videodev
insmod spca5xx oder insmod spca5xx_lite

mit dem Befehl:

lsmod

kannst du überprüfen welche module geladen sind. Jetzt noch überprüfen ob die Webcam erkannt wurde indem wir

dmesg

eigeben. Da sollte dann sowas stehen wie:

Aldi Webcam DC-3110
root@dave_yakumo:~# dmesg 
Creating 5 MTD partitions on "Physically mapped flash":
0x00000000-0x00040000 : "cfe"
0x00040000-0x003f0000 : "linux"
0x000b5fec-0x00180000 : "rootfs"
mtd: partition "rootfs" doesn't start on an erase block boundary -- force read-only
0x003f0000-0x00400000 : "nvram"
0x00180000-0x003f0000 : "OpenWrt"
diag boardtype: 0000041a
Probing device eth0: No Robo switch in managed mode found
Probing device eth1: No Robo switch in managed mode found
Probing device eth2: No such device
Probing device eth3: No such device
BFL_ENETADM not set in boardflags. Use force=1 to ignore.
eth2: Broadcom BCM4320 802.11 Wireless Controller 3.90.37.0
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
usb-ohci.c: USB OHCI at membase 0xb8004000, IRQ 2
usb-ohci.c: usb-00:04.0, PCI device 14e4:4715
usb.c: new USB bus registered, assigned bus number 1
hub.c: USB hub found
hub.c: 2 ports detected
SCSI subsystem driver Revision: 1.00
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
uhci.c: USB Universal Host Controller Interface driver v1.1
Linux video capture interface: v1.00
usb.c: registered new driver spca5xx
drivers/usb/spca5xx.c: spca5xx driver 00.57.07 registered
hub.c: new USB device 00:04.0-1, assigned address 2
drivers/usb/spca5xx.c: USB SPCA5XX camera found. Qtec Webcam 100 Pac207-BCA 
drivers/usb/spca5xx.c: [spca5xx_probe:8380] Camera type GBRG 
drivers/usb/pac207.h: [pac207_config:148] Find Sensor PAC207
drivers/usb/spca5xx.c: [spca5xx_getcapability:2207] maxw 352 maxh 288 minw 160 minh 120

interessant ist für uns eigentlich nur "Gerät erkannt"

usb.c: registered new driver spca5xx
drivers/usb/spca5xx.c: spca5xx driver 00.57.07 registered
hub.c: new USB device 00:04.0-1, assigned address 2
drivers/usb/spca5xx.c: USB SPCA5XX camera found. Qtec Webcam 100 Pac207-BCA 
drivers/usb/spca5xx.c: [spca5xx_probe:8380] Camera type GBRG 
drivers/usb/pac207.h: [pac207_config:148] Find Sensor PAC207
drivers/usb/spca5xx.c: [spca5xx_getcapability:2207] maxw 352 maxh 288 minw 160 minh 120

also Driver gefunden, Webcam erkannt. Und das mit der Aldi-Cam super!


pwc/pwcx

ipkg install http://141.54.160.25/dave/philips-webcam_0.2_mipsel.ipk

es wird automatisch ein startscript /etc/init.d/S90webcam angelegt.

cd /etc/init.d/
vi S90webcam
#!/bin/sh

# unload drivers in case the were loaded
killall camsrv; rmmod pwcx; rmmod pwc; rmmod videodev

# load webcam driver modules (it can be assumed that the USB drivers are compiled into the kernel or were installed & autoloaded)
insmod videodev || exit 1
insmod pwc || exit 2
insmod pwcx || exit 3

sleep 1

# check if video device was allocated
if [ ! -e /dev/v4l/video0 ]; then exit 4; fi

camsrv -D /dev/v4l/video0 -r VGA -c 0 -F 5 &

setpwc

  • Tool zum einstellen der Kamera
  • Hilfe:
setpwc -h

setpwc v1.2, (C) 2003-2006 by folkert@vanheusden.com
-d device  device to use (default: /dev/video0)
-p      dump current settings
-f x    set framerate (0...63)
-S w,h,x  set width/height/framerate
-b      store settings in nonvolatile RAM
-r      restore settings from nonvolatile RAM
-x      restore factory settings
-c x    set compression preference (0-3)
-g x    set automatic gain control (0...65535)
-s x    set shutter speed (1...65535)
-w auto/manual/indoor/outdoor/fl
        set automatic white balance mode
-a x    red-balance (only if -w manual) (0...65535)
-e x    blue-balance (idem) (0...65535)
-i x    speed of automatic white balance (1...65535)
-j x    delay for automatic white balance (1...65535)
-k x    set led on-time (0...25500ms
-l x    set led off-time
-m x    set electronic sharpness (0...65535)
-n x    set backlight compensation (0=0ff, other=on)
-o x    set antiflicker mode (0=0ff, other=on)
-q x    set noise reduction mode (0=none...3=high)
-t x    reset pan(bit 0) and/or tilt(bit 1)
-u      query pan/tilt status
-y x    set pan position
-z x    set tilt position
-h      this help

ov511 / ov51x

ipkg install http://141.54.160.25/dave/ov511_0.1_mipsel.ipk

oder 

ipkg install http://141.54.160.25/dave/kmod-ov51x_2.4.30+1.65-1.12-mark-brcm-1_mipsel.ipk

Quickcam Messenger

ipkg install http://141.54.160.25/dave/qc-usb-messenger-1.6_0.1_mipsel.ipk

Programme

SpcaCat

Installation:

cd /tmp
wget http://ping02.stura.uni-weimar.de/dave/spcacat.gz
mv spcacat.gz /usr/bin
cd /usr/bin
gunzip spcacat.gz
chmod +x spcacat

Alle möglichen Einstellungen stehen in der Hilfe

spcacat -h
spcacat [-h -d -g -f -s -p -N -P -o]
     -h show this usage message.
     -d device ask the driver to use specified video
        output device (/dev/video1)
     -o outputfile  causes the program to output avi with
        image data received from the video device to the specified file.
     -g grab with READ method instead of default MMAP
     -f video format  nothing YUV420P  fourcc I420
        jpg JPEG         fourcc MJPG
        yuv YUV420P   fourcc I420
    r16 RGB565 16bits fourcc RGB2
    r24 RGB 24bits  fourcc RGB3
    r32 RGB 32bits  fourcc RGB4
    -v RAW data  fourcc RAWD
     -s widthxheight ask the driver for input size
     -p X take a picture every X seconds
     -p X && -o getPicture every X seconds and record in SpcaPict.jpg
     -N take N pictures and stop
     -P parport device (spcacat, spcaserv)

jetzt Link noch legen, weil das Programm das device /dev/v4l/video0 nicht verarbeiten kann. und dann spcacat starten.

ln -s /dev/v4l/video0 /dev/video0 
spcacat -d /dev/video0 -g -f jpg -p 10000 -o > /dev/null &

in unserm Falle speichert spcacat aller 10 sek. ein Bild namens SpcaPict.jpg ab.

Eleganter ist es auch diesmal ein script zu erstellen um nicht jedesmal die Module von Hand zu laden. Dazu legt man in dem Startverzeichnis(/etc/init.d) eine Datei z.B. S90webcam an

cd /etc/init.d/
vi S90webcam

#!/bin/sh

# Variablen Definition
REAL="/www/bild.jpg"
TEMP="/SpcaPict.jpg"

insmod videodev
insmod spca5xx
sleep 15

# Link legen fuer Vidiodevice
ln -s /dev/v4l/video0 /dev/video0

while true
do
spcacat -d /dev/video0 -g -f jpg -s 320x240 -p 1000 -o > /dev/null &
sleep 2
killall spcacat
killall -9 spcacat
sleep 1
mv $TEMP $REAL
sleep 15
done &

berechtigungen noch setzen mit

chmod 0777 S90webcam

Motion

Installation:

ipkg install http://ping02.stura.uni-weimar.de/dave/libjpeg_6b-1_mipsel.ipk
ipkg install http://ping02.stura.uni-weimar.de/dave/motion_3.2.6-1_mipsel.ipk

Nun noch die Config-Datei für motion anlegen.

vi /etc/motion.conf

#motion.conf

daemon on
quiet on

# You may very well need to change this (check with 'dmesg'
# after plugging in your webcam)
videodevice /dev/v4l/video0

# Image size in pixels (valid range is camera dependent)
width 320
height 240

quality 60
framerate 1
auto_brightness on

# Initial brightness, contrast, hue (NTSC), and saturation
# 0 = disabled (valid range 0-255)
brightness 0
contrast 0
saturation 0
hue 0

# Target base directory for pictures and films
# You should probably change this (create dir beforehand)
target_dir /tmp
jpeg_filename bild

# Define a port number (e.g. 8000) to enable the mini-http server
# 0 = disabled
webcam_port 8000

# 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 40
webcam_maxrate 2

# User defined text overlayed on each in the lower left corner
text_left  "Dave TV"

Und jetzt motion starten mit

motion

Jetzt kann man sich den Stream unter http://IP-Adresse_vom_Router:8000 ansehen

Eleganter ist es auch diesmal ein script zu erstellen um nicht jedesmal die Module von Hand zu laden. Dazu legt man in dem Startverzeichnis(/etc/init.d) eine Datei z.B. S90webcam an

cd /etc/init.d/
vi S90webcam

#!/bin/sh

# Module laden 
insmod videodev
insmod spca5xx
sleep 15
          
# Link legen fuer Vidiodevice
ln -s /tmp/bild.jpg /www/bild.jpg
          
# motion starten
while true       
do               
motion           
sleep 900        
killall motion   
killall -9 motion
sleep 2
done &

berechtigungen noch setzen mit

chmod 0777 S90webcam

Camsrv

LiveStream ähnlich motion

camsrv -r CIF -d 100 -v --device=/dev/v4l/video0

Hilfe: camsrv -h

camsrv v0.3.4
(c)2002 Matthew Painter

Usage: camsrv [options]

Example: camsrv -r VGA -d 100 -v --device /dev/video1
Example: camsrv -w 320 -h 240 -s --file cam.ppm
Example: camsrv --delay 10-2 --script upload.pl --file cam.jpg

General options:
-v --verbose              display verbose information (for debugging)
-V --version              display version and exit
-W --width NUM            width of captured image
-H --height NUM           height of captured image
-r --resmode MODE         use standard resolution (see below)
-f --file FILENAME        save PPM/JPG image of first frame captured and exit
-q --jpegquality NUM      JPEG image quality percentage (value between 0 and 100,
                          defaults to 75)
-p --script FILENAME      run FILENAME after each image is captured
-P --port PORT            port to run the camsrv server on
-d --delay NUM-NUM | NUM  delay (in seconds) between frames are captured
-e --capturedelay NUM     portion of delay where camera is enabled (for image stabilisation)
-l --loop                 loop still image capture. Enabled if streaming is
                          also enabled
-L --log FILENAME         log verbose output messages to FILENAME
-D --device PATH          path to video device to use (defaults to /dev/video0)
-S --stream               streams to java client. This is enabled by default
                          if --file is not used
-h --help                 display help

Philips specific options:
-F --framerate NUM    framerate of camera (integer between 4 to 30)
-c --compression NUM  camera compression (0..3)
-s --shutter NUM      shutter speed (0..65535) default: automatic
-g --agc NUM          automatic gain control override (0..65535)

Default resolution modes:

Mode            Resolution
sQCIF           128x96
QSIF            160x120
QCIF            176x144
SIF             320x240
CIF             352x288
VGA             640x480

Mvc

einfaches motion capture Programm

mvc version 0.8.9 - motion detection video capture program

Usage: mvc <options>

 -B picture brightness value.
 -C picture contrast value.
 -D run in daemon mode.
 -O Base directory for output images. default is current dir.
 -o Don't create sub-directories for output.
 -t Print timestamp on image.
 -d <device> video device (default:/dev/video0).
 -e <program> excute a external program while motion detected.
 -f {jpeg|png} set output file format. default is jpeg.
 -q <quality>               jpeg quality setting.
 -h print this help.
 -i <channel> which input channel to use, default is 1, or 0 if only 1 input.
 -m use mono color (grayscale) for capture.
 -n {pal|ntsc|secam|auto}    video norm to use, default: PAL
 -s XxY size of the output image, example: -s 640x480
 -a HxV block division number in Horizantal and Vertical. Ex: -a 16x8
 -b <diff_block_limit>      threshold of hot block number.
 -c <diff_color_limit>      threshold of block color difference.
 -w delay time for each capture(seconds), example: -w 0.5
 -l logfile used in daemon mode. default is null.
 -v increase verbose level for more details, can multiple applied.

Anzeigen auf dem Router

Anlegen eines Links:

cd /www
vi 20-cgi-bin-webcam

Text einfügen:

<TR><TD>^M
            <DIV CLASS="plugin"><A CLASS="plugin" HREF="cgi-bin-webcam.html">Webcam</A></DIV></TD>^M
          </TR>^M

Dann noch die Site anlegen

cd /www
vi cgi-bin-webcam.html

und Text einfügen:

als Bild

#!/bin/sh

export DATE="18.11.2006";SCRIPT=${0#/rom}
export TITLE="Webcam"
. ${SCRIPT%/*}/cgi-bin-pre.sh

cat<<EOF
<html><head>
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="refresh" content="10">
                <center>
                <H1>Webcam</H1>
                <br>
                <img src="bild.jpg" name="Webcambild">
                <br>
                Images refreshed every 10 seconds.
                </center>
</body></html>
EOF

. ${SCRIPT%/*}/cgi-bin-post.sh

Mit Java Applet

#!/bin/sh

export DATE="18.11.2006";SCRIPT=${0#/rom}
export TITLE="Webcam"
. ${SCRIPT%/*}/cgi-bin-pre.sh

cat<<EOF
<center>
<H1>Webcam</H1>
    <applet code=com.charliemouse.cambozola.Viewer
    archive=cambozola.jar width="320" height="240" style="border-width:1; border-color:gray; border-style:solid;">
    <param name="url" value="http://'''IP-Adresse''':8000">
    <param name="failureimage" value="offline.jpg">
    <param name="accessories" value="ZoomIn,ZoomOut,Pan,Info">
    </applet>
</center>
EOF

. ${SCRIPT%/*}/cgi-bin-post.sh


Geräte die getestet wurden

Fabrikat ID (lsusb/dmesg) driver Programm Qualität/Auflösung
Creative Vista Plus spca5xx motion, spcacat max:352x288 optimal:320x240
Philips ToUcam FUN II PCVC 830 pwc motion, camsrv, mvc max:640x480 optimal:320x240
Philips ToUcam Pro II PCVC 840 pwc motion, camsrv, mvc max:640x480 optimal:320x240
Qtec Webcam 100 (AldiCam) spca5xx motion, spcacat max:352x288 optimal:176x144
spca5xx motion, spcacat max:352x288 optimal:176x144