[9b0df2]: / RaspberryPi / runthisstress.sh

Download this file

39 lines (31 with data), 743 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
CT=0
while [ True ]
do
FNAME="pipic$CT.jpg"
#Taking a snap and sending it to server
raspistill -o "$FNAME"
RESULT=$(curl -s -F "file=@$FNAME" http://url/predict | grep -w "var result" | awk '{print $4}' | sed 's/.$//')
echo "$FNAME uploaded..."
#Getting result
echo "RESULT = $RESULT"
RESULT=$(echo $RESULT | sed s'/....$//')
#Identifying Confidence from result
CMP=$(awk 'BEGIN{ print "'$RESULT'"<"'98'" }')
#Checking stress through confidence
if [ "$CMP" -eq 1 ]
then
echo "SUBJECT IS UNDER STRESS"
python buzz.py 1
sudo python LED.py 1
else
echo "SUBJECT IS NOT UNDER STRESS"
python buzz.py 0
sudo python LED.py 0
fi
printf "\n"
#Preparing for next cycle
CT=$((CT+1))
rm $FNAME
sleep 2
done