Step 7Easy Motion Detector Program
1. Install your webcamera.
2. Install capture software called Xawtv. It creates file called .webcamrc
3. Open the file with your favorite editor.
4. Delay defines how often the still-picture is sent to server. I used 7 seconds.
Dir defines location folder where the picture goes. Something like: /usr/webcam/pictures/
File defines name of the picture. Something like caption,jpgor what you want to use.
5. Save and exit.
6. Now you can try the command webcam & . The program start updating the picture on every 7 second to
the defined dir folder. & option, put it to run on background.
And next..
Install ImageMagick software.
Under Fedora command is: yum install ImageMagick
Software contains function called compare and this is what we need.
Now you have to code a Shell script. Use your editor to do that.
#!bin/sh
PATH=/usr/webcam/pictures/
while(true)
do
cp $PATH/caption.jpg $PATH/tmp/caption2.jpg
sleep 10
compare -metric PSNR $PATH/caption.jpg $PATH/tmp/caption2,jpg null > result
result2=`head -c 4 result`
result2=${result2/./}
if test $result2 -lt 300
then
time=`date +%_T_%F`
cp $PATH/caption,jpg $PATH/save/$time.jpg
fi
done
Now you can run your script with command: sh gived_script_name
If the picture contains difference, it will be saved to defined folder. In my example it goes to /usr/webcam/pictures/ save/
About the ImageMagick and the compare function you will find more information from here http://www.imagemagick.org/script/compare.php
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|










































