Last active
August 29, 2015 14:01
-
-
Save Pesticles/7c8dc9ba2b9287003474 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# takes 3 pictures, 20 seconds apart. | |
function check { | |
# Certain conditions cause raspistill to lock up, primarily if it has trouble writing the image to storage. | |
# Since we store locally now (we didn't use to) it's not such a problem | |
# but if you're saving direct to NFS or CIFS these checks are important. | |
PID=$(ps ax | grep raspistill | grep -v grep | awk '{print $1}') | |
if [[ ! -z "$PID" ]]; then | |
# Already running, try to kill it | |
echo "Running, pid: $PID" | |
kill $PID | |
sleep 1 | |
fi | |
PID=$(ps ax | grep raspistill | grep -v grep | awk '{print $1}') | |
if [[ ! -z "$PID" ]]; then | |
# Still running, exit with error | |
echo "Kill failed: $PID; Exiting" | |
exit 1 | |
fi | |
} | |
function shot { | |
# Check raspistill isn't already running | |
check | |
# Take a picture and save it using a timestamp as the file name | |
# YearMonthDayHourMinuteSecond.jpg, eg 20140515113500.jpg | |
raspistill -w 1920 -h 1080 -o /home/pi/temp/`date +'%Y%m%d%H%M%S'`.jpg & | |
} | |
shot | |
sleep 20 | |
shot | |
sleep 20 | |
shot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment