#!/usr/bin/perl # Script for Creative Labs Webcam in cooperation with the CPIA-driver 0.4.0 # (coming soon in v4l) and the Framegrabber-program vidcat (from w3cam) # Further tools perl and the FTP-module for Perl # this script was developed by Andreas Romeyke, ordered by it-netservice. # It is a quick and dirty hack in perl and should be selfdocumented. use vars ('$grabtime','$refreshtime','$host','$login','$passwd','$path','$debug','$ftp','$quality','$smoothness','$grayscale','$size','$bytes'); #### Configuration $grabtime=300;#60 s #refresh of grabbing $refreshtime=300; # 10 s #refresh of html-buffers $host="webcam.localhost"; $login="camera"; $passwd="camera"; $path="www"; $debug=0; #default 4 $quality=55; #Jpeg-quality $smoothness=10; #Jpeg-Smoothness $grayscale="no"; #Grayscale? $size="320x240"; # Defaultsize: 320x240 use Net::FTP; use strict; #First we login $ftp=Net::FTP->new($host, Debug => $debug); #4 $ftp->login($login,$passwd); $ftp->cwd($path); $ftp->binary(); while () { #endless loop, breakable with CTRL-C &new_picture; &new_html; &transfer; sleep $grabtime; } $ftp->quit; sub new_picture { my($a,$b,$c,$d); `./vidcat -s $size -f ppm |ppmnorm -bpercent 3 -wpercent 3|cjpeg -quality $quality -progressive -optimize -smooth $smoothness >tmp/1.jpg`; ($a,$b,$c,$d,$bytes)=split (" ",`ls -l tmp/1.jpg`); #print "$bytes\n"; } sub new_html { my ($date); open (HTML, ">tmp/webcam.html")||die "Konnte \"tmp/webcam.html\" nicht öffnen"; $date=`date`; chop $date; print HTML << "_END";

WebCam IT-NetService, $date, aktualisiert aller $grabtime sec., © Andreas Romeyke _END close (HTML); open (HTML, ">tmp/comment.html")||die "Konnte \"tmp/comment.html\" nicht öffnen"; $date=`date`; chop $date; print HTML << "_END3";

WebCam IT-Netservice

Sie sehen einen Teil der Entwicklungsabteilung der IT-Netservice GmbH

Bild: JPEG mit Kontrastnormalisierung $quality% Quality & $smoothness% Smoothness der Größe $bytes Bytes

Webcam-Script © Andreas Romeyke

_END3 close (HTML); open (HTML, ">tmp/index.html")||die "Konnte \"index.html\" nicht öffnen"; print HTML << "_END2"; _END2 close (HTML); open (HTML, ">tmp/1.html")||die "Konnte \"tmp/1.html\" nicht öffnen"; print HTML << "_END4";
$date
_END4 close (HTML); } sub transfer { $ftp->put("tmp/index.html"); $ftp->put("tmp/webcam.html"); $ftp->put("tmp/comment.html"); $ftp->put("tmp/1.jpg"); $ftp->put("tmp/1.html"); }