#!/bin/bash # this saves a snapshot of the camera every second or so depending on how long all the other crap takes # let's hope the vars make it otherwise imma need to parse a bollocksing file i=1 while [ -f "$WORKING_DIR/run" ] do FILENAME=$(printf "img-%05d" "$i") 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) COORDINATES="$LAT, $LON" 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 big boi should add both the timestamp and the coordinates #convert $WORKING_DIR/$FILENAME.jpg \( +clone -gravity NorthWest -pointsize 44 -fill yellow -annotate +30+30 "$TIME" $WORKING_DIR/$FILENAME-time.jpg\) \ #\( +clone -gravity NorthEast -pointsize 44 -fill yellow -annotate +30+30 "$COORDINATES" $WORKING_DIR/$FILENAME-final.jpg\) #-append $WORKING_DIR/$FILENAME.jpg # This should add the current time to the image and save it #convert $WORKING_DIR/$FILENAME.jpg -gravity SouthWest -pointsize 44 \ #-fill yellow -annotate +30+30 $TIME $WORKING_DIR/$FILENAME-temp.jpg # Delete original #rm $WORKING_DIR/$FILENAME.jpg # This should add the current latlon to the image and save it #convert $WORKING_DIR/$FILENAME-temp.jpg -gravity SouthEast -pointsize 44 \ #-fill yellow -annotate +30+30 $COORDINATES $WORKING_DIR/$FILENAME-final.jpg # Delete temp #rm $WORKING_DIR/$FILENAME-temp.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