Motion-WebCam

This perl-script saves, in fixed intervals, pictures from a WebCam if
there was motion detected in the picture.

The package mainly consists of:
-
A Perl-script which connects to a server running CamServ. This
does not necessarily have to be your own WebCam but might also be
someone else's. But may I ask you to inform the webmaster of the
respective WebCam in case you hook up to his server?
The script makes use of the netpbm package to convert pictures, detect the
motion, et al.
-
A tiny little shell script which erases older pics in order to keep
your harddisk clean. I believe you figure this yourself; it's here for
completeness.
-
A PHP-script in case you run your own web-server or have a good
relation to the guy hosting your homepage. The script builds a
web-page showing all the recorded frames on demand. (See below if you
can't run PHP)
Oh, and not to forget: If you want a more accurate solution (consuming
more CPU power and harddisk space), try
motion. This is
a really excellent package with which you'll for sure not miss one
single frame. It can also create MPEGs out of what it detected. But be
warned! It allocated 30% CPU of my PIII/1GHz if I tuned it to be
accurate ;-)

I didn't put a documentation into the tarball yet. But here's some
brief instructions on how to get it running:
Get the gzipped tarball.
Unpack it to a convenient location and:
-
Edit MotionWebCam.pl. There's a section commented as "Settings"
which you should inspect carefully.
The CamServ
Server provides a convenient way of grabbing a single frame
through host:port/singleframe (see the $URL variable for
details). The sensitivity
which triggers a motion-detection can easily be debugged by enabling
the respective print command in the source (see the source code
comments). If enabled, the script will print Delta to the
console every time a frame is grabbed. If Delta is smaller than
the pre-set $SENSITIVITY, it's considered detected motion and a
shot is taken.
The path to where the pictures (containing detected motion) are saved
can be anywhere as long as the access-rights are OK.
Futher, you can set the interval in which a picture is grabbed and
comapred against the previous one by tuning $FRAMEDELAY. A
setting of 3 (3 seconds) here provides a quite easy CPU load...
-
Run MotionWebCam.pl, e.g. in /etc/rc.d/rc.local or as a SYS V
script. This is best done by the command /foo.../MotionWebCam
&. Keep in mind that the script does NOT detach itself, so you
need the & at the end!
And, please! Consider well which user you want to run this script as...
-
Once running, MotionWebCam will start filling your chosen path with
pictures. To keep this directory within limits, there's a tiny little
script included in the package which deletes all file that are older
than a given time.
Edit CleanShots.sh. More than only simple, just adjust the
filepath variable to point to the path where your shots
are located. Be careful not to specify the wrong path or important
files might disappear forever ;). spawn defines, in the usual
find syntax, the time after which pictures are deleted (see
man find for details).
-
Run this CleanShots.sh from cron at reasonable
intervals. For RedHat, this can e.g. be done with the command ln -s
/foo../CleanShots.sh /etc/cron.hourly/CleanShots.sh
-
If you have your own web-server (including PHP support) running or
your webpage hoster is generous enough, there's a PHP script included
wich can, on demand, display the list of pictures taken. Edit
list.php and set the variable $path to the path where
your pictures are located. Put it on your server and off you go...
If you don't have the chance to run PHP scripts, there's still another
way: Write a small script which generates a HTML-file pointing to all
your pictures. You can then, e.g. triggered by cron, upload all the
pictures plus the generated page to your homepage. This works quite
flawlessly with a tool like ncftpput and maybe something like
dial-demandd, which can also be found on my page. (That's acually how
I did it for quite some months before my praised ISP introduced
flat-rate...).
-
If you have any problems in getting it running, collect all the logs
you can and drop me a mail. Promise, I'll try ;-)