From db4ceb5d70017ddfff82f0631fdcef3284b58b5e Mon Sep 17 00:00:00 2001 From: st33v Date: Thu, 29 Dec 2016 17:30:26 +1100 Subject: Now can upload from more than one webcam --- getpix.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/getpix.sh b/getpix.sh index cc8567a..6c52984 100755 --- a/getpix.sh +++ b/getpix.sh @@ -12,22 +12,20 @@ threshold="2000" # minimum value of average pixel brightness. Test ########### end Consts ################ # cam names in an array: -declare -a camz=("neatherd" "lucerne") - +declare -a camz=(neatherd lucerne) ########### Functions ################## # get the filename of the most recent photo stored on this computer. -newestpicfunc () { newestpic=$(ls ${campi}/*.jpg -t | head -1); } +newestpicfunc () { newestpic=$(ls "$campi"/*.jpg -t | head -1); } ########### end Funcs ################# cd ${thisdir} -for campi in "$camz[@]}" +for campi in "${camz[@]}" do - { # record the latest photo BEFORE we look for a new one newestpicfunc; oldpic=${newestpic} - # echo "Before: oldpic is ${oldpic}" + echo "Before: oldpic is ${oldpic}" # Copy any photos from the camera-equipped source ($campi) # This script is on a rapid timer so there should only ever be one photo (if any). @@ -37,24 +35,25 @@ do # cp ${oldpic} ${thisdir}${campi}/zzz.jpg # testing # get the filename of the NEW photo, it there is one - newestpicfunc; newpic=${newestpic} - #echo "After: newpic is ${newpic}" + newestpicfunc; newpic="$newestpic" + echo "After: newpic is ${newpic}" if [[ "$oldpic" == "$newpic" ]] ; then - # echo no new photos so exit now - exit 0 + # echo no new photos so exit now + #exit 0 + continue fi # NeatHerd doesn't have enough RAM to perform image processing, so let's try it on STAN # Check to see if the pic is too dark (i.e. taken at night) mean=$(identify -format %[mean] ${newpic} | sed s/[.].*//) - # echo "mean is |$mean|" + # echo "mean is $mean" # too dark (nighttime) if [[ "${mean}" -lt "${threshold}" ]] ; then rm $newpic - # echo mean of $mean is too low. It is nighttime. - exit 13 + # echo mean of $mean is too low. It is nighttime. + continue fi # Improve sharpness and resize photo, ready for upload to webserver @@ -63,9 +62,10 @@ do convert temp.jpg -resize 33% -quality 70 ${newpic} rm temp.jpg - scp /home/st33v/cams/$campi/$newpic $wanWebServer:/home/st33v/farm/cam/$campi/. - } + # upload latest pic to web server + echo "/home/st33v/cams/$newpic" + echo "$wanWebServer:/home/st33v/farm/cam/$campi/" + scp /home/st33v/cams/$newpic $wanWebServer:/home/st33v/farm/cam/$campi/. done -#. ~/cams/sendpix.sh #exit(0) # force success exit code for fussy systemd -- cgit v1.3