Last active
November 2, 2016 19:44
-
-
Save sunmockyang/f6ba6be0f9d179c5cf52bac2458f7b37 to your computer and use it in GitHub Desktop.
Start the time-lapse at the sunrise of each day. Run timelapseSunrise.sh
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/sh | |
| WIDTH=1920 | |
| HEIGHT=1080 | |
| NUM_FRAMES=$1 | |
| FRAME_INTERVAL=$2 | |
| DIR=$3 | |
| DATE=$(date +"%Y-%m-%d_%H%M%S") | |
| if [ ! -n "$DIR" ]; then | |
| DIR="${HOME}/timelapse/timelapse60/$DATE" | |
| fi | |
| mkdir -p $DIR | |
| cd $DIR | |
| echo "STARTING TIMELAPSE IN: $DIR" | |
| # If it is the hour we want to record: | |
| # take $NUM_FRAMES pictures with | |
| # $INTERVAL_MINUTES of time in between each | |
| for i in `seq 1 $NUM_FRAMES`; do | |
| FILE_NAME=$DATE"_"$i | |
| echo "TAKING PICTURE: $FILE_NAME.jpg" | |
| raspistill -w $WIDTH -h $HEIGHT -vf -hf -awb sun -n -o $FILE_NAME.jpg | |
| sleep $FRAME_INTERVAL | |
| done |
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
| require "json" | |
| require 'net/http' | |
| require 'uri' | |
| def open(url) | |
| Net::HTTP.get(URI.parse(url)) | |
| end | |
| # Put in your own latitude and longitude | |
| puts JSON.parse(open('http://api.sunrise-sunset.org/json?lat=45.4215000&lng=-75.6972000&formatted=0&date=today'))["results"]["sunrise"] |
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/sh | |
| INTERVAL_MINUTES=1 | |
| NUM_FRAMES=60 | |
| DIR="${HOME}/timelapse/sunrise/"$(date +"%Y-%m-%d_%H%M%S") | |
| CHECK_INTERVAL=30 #seconds | |
| MINUTES_AFTER_SUNRISE=0 | |
| mkdir -p $DIR | |
| cd ${HOME}/scripts | |
| while true; do | |
| # Check every $CHECK_INTERVAL seconds if we're at the hour we want to record | |
| SUNRISE_TIME=`date --date="TZ=\"America/Toronto\" $(ruby get_sunrise_time.rb) + $MINUTES_AFTER_SUNRISE minutes"` | |
| HOUR_TO_RECORD=`date -d "$SUNRISE_TIME" +'%H'` | |
| MINUTE_TO_RECORD=`date --date="$SUNRISE_TIME" +"%M"` | |
| echo "Today's sunrise is at: $HOUR_TO_RECORD:$MINUTE_TO_RECORD" | |
| if [ $(date +"%H") -eq "$HOUR_TO_RECORD" ] && [ $(date +"%M") -eq "$MINUTE_TO_RECORD" ]; then | |
| ./customTimelapse.sh $NUM_FRAMES $(($INTERVAL_MINUTES * 60)) $DIR | |
| fi | |
| sleep $CHECK_INTERVAL | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment