Skip to content

Instantly share code, notes, and snippets.

@mikebridge
Created May 19, 2015 20:04
Show Gist options
  • Select an option

  • Save mikebridge/1b96a1984b64fb41f5db to your computer and use it in GitHub Desktop.

Select an option

Save mikebridge/1b96a1984b64fb41f5db to your computer and use it in GitHub Desktop.
take a photo on raspberry pi
#!/bin/bash
PIDMOTION=$(pgrep -x motion)
if [ -n "$PIDMOTION" ]
then
echo "stopping motion"
sudo /etc/init.d/motion stop
fi
TIMESTAMP=$(date -d "today" +"%Y-%m-%d-%H%M").jpg
FILENAME=/home/pi/motion/photo-$TIMESTAMP
WIDTH=1900
HEIGHT=1425
#QUALITY=50
QUALITY=8
EXPOSURE=auto
#EXPOSURE=night
#EXPOSURE=verylong
echo "taking photo..."
/usr/bin/raspistill --exposure $EXPOSURE --quality $QUALITY --width $WIDTH --height $HEIGHT -o $FILENAME
if [ -n "$PIDMOTION" ]
then
echo "restarting motion"
sudo /etc/init.d/motion start
fi
rsync --remove-source-files -avzhe "ssh -i /home/pi/.ssh/id_rsa" $FILENAME [email protected]:/root/webcam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment