diff options
| author | St33v <github@f3rr3t.com> | 2016-09-28 07:21:29 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-28 07:21:29 +1000 |
| commit | 98cc377d642fdf5dbba042ae793c8659d5ac875d (patch) | |
| tree | 11d1937a1563f0c08fa3bba2d014543bba2f6351 /getpix.sh | |
| parent | 52b0d042176580d9f017714bfdfb868de26e643e (diff) | |
Moved night/dark pic test from neatherd (out of memory errors)
Diffstat (limited to 'getpix.sh')
| -rwxr-xr-x | getpix.sh | 49 |
1 files changed, 32 insertions, 17 deletions
@@ -1,32 +1,35 @@ #!/usr/bin/bash # SJP 30 Dec 2015 # -# Copy photos from a cam-equipped raspi +# Copy and process photos from a cam-equipped raspi -# hard-code source hostname for the moment -campi="neatherd" -sourcedir="/home/st33v/pix/" # where the image is on the source computer (i.e. $campi) -thisdir="/home/st33v/cams/" # this directory (on this computer) +########### Constants ################## +campi="neatherd" # hard-code source hostname for the moment +sourcedir="/home/st33v/pix" # where the image is on the source computer (i.e. $campi) +thisdir="/home/st33v/cams" # this directory (on this computer) +threshold="2000" # minimum value of average pixel brightness. Tests if pic is too dark +########### end Consts ################ -# get the filename of the photo, but only the most recent -newestpicfunc () { newestpic=$(ls ${thisdir}${campi}/*.jpg -t | head -1); } +cd ${thisdir} +########### Functions ################## +# get the filename of the most recent photo stored on this computer. +newestpicfunc () { newestpic=$(ls ${campi}/*.jpg -t | head -1); } +########### end Funcs ################# # 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). -scp ${campi}:${sourcedir}*.jpg ${thisdir}${campi}/. 2>/dev/null -# Delete the phot from the source computer. -ssh $campi "rm ${sourcedir}*.jpg" 2>/dev/null +scp ${campi}:${sourcedir}/*.jpg ${campi}/. 2>/dev/null +# Delete the photo from the source computer. +ssh $campi "rm ${sourcedir}/*.jpg" 2>/dev/null # 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}" +#echo "After: newpic is ${newpic}" if [[ "$oldpic" == "$newpic" ]] ; then # echo no new photos so exit now @@ -35,9 +38,21 @@ fi # NeatHerd doesn't have enough RAM to perform image processing, so let's try it on STAN -convert ${newpic} -unsharp 1.5x1+0.7+0.02 ${thisdir}/temp.jpg -convert ${thisdir}/temp.jpg -resize 33% -quality 70 ${newpic} -rm ${thisdir}/temp.jpg +# 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|" +# too dark (nighttime) +if [[ "${mean}" -lt "${threshold}" ]] ; then + rm $newpic +# echo mean of $mean is too low. It is nighttime. + exit 13 +fi + +# Improve sharpness and resize photo, ready for upload to webserver +# Break into two steps to avoid out-of-memory errors (OS kills process) +convert ${newpic} -unsharp 1.5x1+0.7+0.02 temp.jpg +convert temp.jpg -resize 33% -quality 70 ${newpic} +rm temp.jpg . ~/cams/sendpix.sh |
