[Novalug] keeping an eye on your dog (or whatever)
Doug Toppin
dougtoppin at gmail.com
Wed Dec 16 17:22:08 EST 2009
I have a webcam set up at home so that I can keep an eye on what my
dog is up to (when she is in her bed). I have a script that uses
wget to capture an image and keep them in a directory. I've been
looking into the dir thumbnails every now and then to see when she
shows up on camera and decided to try to automate it so that something
tells me when she appears (I do not want to stream the video for
checking btw so I am not using the motion difference tool that i ran
across a long time ago).
I ran across 'jpegdiff'
(http://www.webmasterworld.com/linux/3214786.htm) to do it which is
working reasonably well (it supports a fuzz factor to reduce false
hits due to light changes or whatever).
To notify me, when jpegdiff exits indicating that she might be in
view, my checker script uses 'xmessage' to put up a notification to me
(another tool called 'dzen/dzen2' can be used for that as well).
I thought that I would pass along what I'm using (jpegdiff, xmessage
or dzen2) to cobble this together in case anyone is not familiar with
them and might find them useful.
Anyone else doing "stuff" like this and have any other suggestions for
image comparison or pop-up notifications?
--------------------------------------
# lookforchili
# check the image directory for evidence that Chili is in view
DIR=$HOME/Desktop/Chili
cd $DIR
while :
do
# get the last (latest) two images in the directory
LIST=`ls $DIR/*.jpg |tail -2`
echo "checking $LIST"
# jpegdiff exit status indicates noticeable image differences
jpegdiff -vv -f 10 $LIST
if test $? -ne 0
then
echo "Chili is on camera"
# dzen2 is also available for notifications
#echo "Chili might be in view at `date`" | dzen2 -p 30
xmessage "Chili might be in view at `date`" &
fi
sleep 300
done
----------------------------------------------
When it runs, it looks like this:
./lookforchili
checking /home/dtoppin/Desktop/Chili/1261000982.jpg
/home/dtoppin/Desktop/Chili/1261001283.jpg
Fuzziness set to 10
Turbomode set to 1
921600 samples analyzed.
Brightness of the first image is 14%
Difference index is 125
Difference index >= 100, therefore files do NOT match.
Chili is on camera
----------------------------------------------
Doug
More information about the Novalug
mailing list