back-end ustreamer, GPS, timelapse, and photo-refresh site working
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
trap "source {{ working_folder }}/create_timelapse.sh &" SIGINT SIGTERM
|
||||
|
||||
# initialize all the variables
|
||||
# basic things
|
||||
@ -18,13 +19,63 @@ echo Timelapse Initiated at $BEGIN >> $WORKING_DIR/info.txt
|
||||
echo Shuttlecraft Galileo located at $CITY, $STATE $ZIPCODE >> $WORKING_DIR/info.txt
|
||||
echo $DISPLAY_NAME >> $WORKING_DIR/info.txt
|
||||
|
||||
# Set the run file and fork the loop
|
||||
touch $WORKING_DIR/run
|
||||
source {{ working_folder }}/record_snapshots.sh &
|
||||
# timelapse creation helpers
|
||||
echo "To create timelapse, here's the ffpmeg script" >> $WORKING_DIR/info.txt
|
||||
echo "/bin/ffmpeg -r 30 -pattern_type glob -i "$WORKING_DIR/*.jpg" \\" >> $WORKING_DIR/info.txt
|
||||
echo "-vf "scale=1920x1080" -vcodec libx264 /$WORKING_DIR/00-timelapse.mp4" >> $WORKING_DIR/info.txt
|
||||
# there should be a script that can do them all
|
||||
echo "/bin/ffmpeg -r 30 -pattern_type glob -i "$WORKING_DIR/*.jpg" \\" >> {{ working_folder }}/generate_timelapses.sh
|
||||
echo "-vf "scale=1920x1080" -vcodec libx264 /$WORKING_DIR/00-timelapse.mp4" >> {{ working_folder }}/generate_timelapses.sh
|
||||
|
||||
# capture time
|
||||
i=1
|
||||
while [ $i ]
|
||||
do
|
||||
FILENAME=$(printf "img-%05d" "$i")
|
||||
# old API based latlon
|
||||
#LATLON=$(curl -s http://10.18.1.1:8184/where_is?api_key={{ tesla_api_key }} )
|
||||
#LON=$(echo $LATLON | jq .lon)
|
||||
#LAT=$(echo $LATLON | jq .lat)
|
||||
LAT=$(cat {{ gps_service_directory }}/gps_data | grep lat | cut -d ":" -f 2 | awk '{printf("%.5f\n", $1)}')
|
||||
LON=$(cat {{ gps_service_directory }}/gps_data | grep lon | cut -d ":" -f 2 | awk '{printf("%.5f\n", $1)}')
|
||||
SPEED_KPH=$(cat {{ gps_service_directory }}/gps_data | grep speed | cut -d ":" -f 2)
|
||||
if [ $SPEED_KPH -lt 1 ]; then
|
||||
SPEED_MPH=$(echo "scale=3; $SPEEK_KPH * 0.62" | bc)
|
||||
else
|
||||
SPEED_MPH=0
|
||||
fi
|
||||
COORDINATES="$LAT, $LON, $SPEED_MPH mph"
|
||||
curl http://127.0.0.1:7123/snapshot --output $WORKING_DIR/$FILENAME.jpg
|
||||
|
||||
# This variable is for the timestamp
|
||||
TIME=$(date +%c)
|
||||
|
||||
# Save the initial image in a temp file
|
||||
convert $WORKING_DIR/$FILENAME.jpg -gravity SouthWest -pointsize 44 \
|
||||
-fill yellow -annotate +30+30 "$TIME" $WORKING_DIR/$FILENAME-temp1.jpg
|
||||
|
||||
# Add the second annotation to the temp file
|
||||
convert $WORKING_DIR/$FILENAME-temp1.jpg -gravity SouthEast -pointsize 44 \
|
||||
-fill yellow -annotate +30+30 "$COORDINATES" $WORKING_DIR/$FILENAME-temp2.jpg
|
||||
|
||||
# Append the two images and save the final result
|
||||
convert $WORKING_DIR/$FILENAME-temp2.jpg -append $WORKING_DIR/$FILENAME.jpg
|
||||
|
||||
# Optionally, remove intermediate files if you don't need them
|
||||
rm $WORKING_DIR/$FILENAME-temp1.jpg $WORKING_DIR/$FILENAME-temp2.jpg
|
||||
|
||||
# This is for the tiny pic
|
||||
# I'll make one every 5 seconds
|
||||
# I have 1340x580. i think i will truncate the top
|
||||
# Calculate the height to trim based on the aspect ratios of the input and output images
|
||||
if (( $i % 5 == 0 )); then
|
||||
NOW=$(date +%Y%m%d%H%M%S)
|
||||
convert $WORKING_DIR/$FILENAME.jpg -gravity North -crop 1920x830+0+260 +repage -resize 1340x580 {{ working_folder }}/small_thumbs/$NOW.jpg
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
|
||||
((i++))
|
||||
|
||||
done
|
||||
|
||||
# set the trap and wait
|
||||
trap "source {{ working_folder }}/create_timelapse.sh &" SIGINT SIGTERM
|
||||
while true; do
|
||||
echo "Running..."
|
||||
sleep 1
|
||||
done
|
||||
Reference in New Issue
Block a user