Picture Server Storing Millions of jpg's!

Shawn boffin at xmtservices.net
Fri Jan 4 20:46:45 PST 2008


On Thu, 3 Jan 2008 08:27:58 -0500
Jerry McBride <mcbrides9 at comcast.net> wrote:


> Since this is bash, it is easily hacked to fit your needs... by
> having it weed/loop through the pictures in your holding directory
> and saving the ones of substantial difference to a different
> directory. I'll leave the necessary hacking to you.
> 
> Good luck and have fun. 
> 
> Caution: Indentation has been compressed out to try to eliminate word
> wrap.
> 
> #!/bin/bash
> #
> #Uses tools from media-video/w3cam, media-libs/jpeg and
> media-libs/netpbm #
> 
> #RESOLUTION=320x240
> DEVICE=/dev/video0
> #FRATE=1
> SENSITIVITY=35
> 
> echo "Setting up"
> mkdir /motion
> mkdir /motion/pics
> cd /motion
> # cleanup
> rm /motion/image.jpg
> # take a snapshop
> vidcat -q 100 -d $DEVICE -f jpeg -o /motion/image.jpg
> #cleanup
> rm /motion/image.ppm
> #decompress image
> djpeg -scale 1/4 -pnm /motion/image.jpg > /motion/image.ppm
> 
> #one big endless loop...
> while true
> do
> 
> echo "Taking a picture"
> #cleanup
> rm /motion/image2.jpg
> #take a snapshot
> vidcat -q 100 -d $DEVICE -f jpeg -o /motion/image2.jpg
> #cleanup
> rm /motion/image2.ppm
> #decompress image2
> djpeg -scale 1/4 -pnm /motion/image2.jpg > /motion/image2.ppm
> #get the current date and time
> date>/Ycolour
> #compare the signal-to-noise ratio of the two uncompressed images
> pnmpsnr /motion/image.ppm /motion/image2.ppm >> /Ycolour 2>&1
> 
> #snip out the data that what we want
> Y=`awk '/Y  color component/ {print int($5)}' /Ycolour`
> #show it
> echo $Y
> #if there's sufficient difference then brand and save image2
> if [ $Y -lt $SENSITIVITY ]
> then 
> cp /motion/image2.jpg /motion/pics/`date +%m%d%H%M%S.jpg`
> echo "Motion detected"
> fi
> #use uncompressed image2 for base of next comparison
> mv /motion/image2.ppm /motion/image.ppm
> #do it again
> done
> #we will never reach this exit...
> exit
> 
> --

Wow Guys Thanks!!

Between this and Kurt's script I think I am well on my way

Now I just need to get a few minutes to actually play!  Ugh!!!!  

BTW, 8in of snow in the front yard since 4PM here and its still coming
down, golf ball size flakes!

Shawn



More information about the Linux-users mailing list