summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--editpix.sh45
-rwxr-xr-xgetpix.sh21
3 files changed, 59 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2c348c6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+lucerne/*
+
diff --git a/editpix.sh b/editpix.sh
new file mode 100644
index 0000000..cf3bb6d
--- /dev/null
+++ b/editpix.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/bash
+# 10Jan2017: V2 (pix are pushed to STAN for processing; replace TIMERS with PATH services)
+# SJP 30 Dec 2015 V1 (Copy and process photos from a cam-equipped raspi)
+
+########### Constants ##################
+wanWebServer="f3rr3t.com"
+#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 ################
+
+# cam names in an array:
+#declare -a camz=(neatherd lucerne)
+
+########### Functions ##################
+# get the filename of the most recent photo stored on this computer.
+########### end Funcs #################
+
+cd ${thisdir}
+
+ # record the latest photo BEFORE we look for a new one
+ newpic=$(ls "$campi"/*.jpg -t | head -1);
+
+ # 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.
+ continue
+ 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
+
+ # 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/.
+
+#exit(0) # force success exit code for fussy systemd
diff --git a/getpix.sh b/getpix.sh
index 6c52984..723b6b7 100755
--- a/getpix.sh
+++ b/getpix.sh
@@ -24,25 +24,25 @@ cd ${thisdir}
for campi in "${camz[@]}"
do
# record the latest photo BEFORE we look for a new one
- newestpicfunc; oldpic=${newestpic}
- echo "Before: oldpic is ${oldpic}"
+ # newestpicfunc; oldpic=${newestpic}
+ # 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 ${campi}/. 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
+ # 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}"
+ # newestpicfunc; newpic="$newestpic"
+ # echo "After: newpic is ${newpic}"
- if [[ "$oldpic" == "$newpic" ]] ; then
+ #if [[ "$oldpic" == "$newpic" ]] ; then
# echo no new photos so exit now
#exit 0
- continue
- fi
+ # continue
+ # fi
# NeatHerd doesn't have enough RAM to perform image processing, so let's try it on STAN
@@ -66,6 +66,9 @@ do
echo "/home/st33v/cams/$newpic"
echo "$wanWebServer:/home/st33v/farm/cam/$campi/"
scp /home/st33v/cams/$newpic $wanWebServer:/home/st33v/farm/cam/$campi/.
+ # bump parent directory to provoke path service
+ touch bump.txt
+ scp bump.txt $wanWebServer:/home/st33v/farm/cam/.
done
#exit(0) # force success exit code for fussy systemd