Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Bash scrip

Hardware/software/hints and tips/discussion/webcam links etc
dazza1223
Posts: 365
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: raspberry pi 3
Location: worthing
Contact:

Bash scrip

Postby dazza1223 » Tue Jul 10, 2018 11:26 pm

Hi has any one made bash scrip to take snapshot off a ip cam and over lay in with data?

User avatar
Toxic17
Posts: 676
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis VPro2 Plus
Operating System: Debian 9.5 Stretch
Location: Bangor, NI
Contact:

Re: Bash scrip

Postby Toxic17 » Tue Jul 10, 2018 11:56 pm

yep :)

I run mine every minute I think with crontab. something like this:

camdataT.txt Template processed realtime.

Code: Select all

Temp: <#temp>°C - Press: <#press> hPa - Hum: <#hum>% - Wind: <#wspeed> mph(<#currentwdir>) - Rain: <#rfall> mm - UV Index: <#UV> - SolarRad: <#SolarRad> W/m² - CloudBase: <#cloudbase>.


then minute script

Code: Select all

#!/bin/sh
#
#set variable yday to be like 20100208
#
#tday=$(date -d today +%Y%m%d%H%M%S);
#stamp=$(date '+DATE: %d/%m/%y%nTIME:%H:%M:%S');
tday=$(date +%Y%m%d%H%M%S);
#stamp=$(date +%Y%m%d);
#
# get weather image
wget --auth-no-challenge --http-user=xxxxxx --http-password=xxxxxxxx "http://xxx.xxx.xx.xxx/cgi/jpg/image.cgi" -O "/share/weather/sky1.jpg";
# next 2 lines add weather info
testdata="$(/bin/cat /share/weather/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;

# add layers and text to image
convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 1280 25" \
-fill red -draw "fill-opacity 0.6 rectangle 0 26 1280 27" \
-fill RoyalBlue4 -draw "fill-opacity 0.7 rectangle 0 695 1280 720" \
-fill red -draw "fill-opacity 0.6 rectangle 0 693 1280 694" \
-fill white -pointsize 18 -font /share/script/arialbold.ttf -draw "text 10,20 'Conlig Weather Station:  $testdata1 - ICODOWNN2 - www.conligwx.org'" \
-fill yellow -pointsize 18 -draw "text 10,715 '$testdata'" /share/weather/sky1.jpg  /share/weather/skywebcam.jpg

# convert image.jpg to 150kb for WUnderground
convert /share/weather/skywebcam.jpg -define jpeg:extent=150kb /share/weather/image.jpg

# ftp webcam to wunderground
lftp -e 'put /share/weather/image.jpg; bye' -u xxxxxxxx,passwordxxxx webcam.wunderground.com -d


Image
Regards Simon

https://www.conligwx.org
https://www.conligwx.org/pws/
https://twitter.com/conligwx
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

dazza1223
Posts: 365
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: raspberry pi 3
Location: worthing
Contact:

Re: Bash scrip

Postby dazza1223 » Wed Jul 11, 2018 9:14 am

o Simon thank you for that!!! i did have a Bash scrip but it keep crashing and makeing the imges go all funny? i will try and add yours..... but i will pont out this tho i do think it very nice that some ppl on here do share there hard work and give it to other and includeing you :D

Big Daddy
Posts: 63
Joined: Tue Sep 10, 2013 8:40 pm
Weather Station: Maplin N96FY
Operating System: Windows 8
Location: Freiston, Lincolnshire, UK

Re: Bash scrip

Postby Big Daddy » Sun Aug 26, 2018 2:24 pm

Thanks for this post Simon. Inspired with the idea I did the same for my webcams. All generated on a PI (which also runs my CumuusMX) and managed to integrate a background image using Imagemagick so it blends in with the rest of my website.

http://midlifedad.me.uk/weather/webcam_north.php

Andy

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Bash scrip

Postby water01 » Sun Aug 26, 2018 3:30 pm

Very nice, love the time lapse. Is all that running on the Pi?

Assume the template is home built?

User avatar
Toxic17
Posts: 676
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis VPro2 Plus
Operating System: Debian 9.5 Stretch
Location: Bangor, NI
Contact:

Re: Bash scrip

Postby Toxic17 » Sun Aug 26, 2018 7:36 pm

I do have a tinelapse script too if you guys want it

I am in Berlin for a few days but back home hopefully on Wednesday evening.
Regards Simon

https://www.conligwx.org
https://www.conligwx.org/pws/
https://twitter.com/conligwx
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

dazza1223
Posts: 365
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: raspberry pi 3
Location: worthing
Contact:

Re: Bash scrip

Postby dazza1223 » Sun Aug 26, 2018 10:50 pm

yes plz mate thanks

Big Daddy
Posts: 63
Joined: Tue Sep 10, 2013 8:40 pm
Weather Station: Maplin N96FY
Operating System: Windows 8
Location: Freiston, Lincolnshire, UK

Re: Bash scrip

Postby Big Daddy » Tue Aug 28, 2018 10:17 am

The Timelapse runs on an old Windows PC using some external software (IPTimelapse) as the PI wasnt able to handle creating 3 video images. It snaps frames using rtsp from my cameras every 10 seconds and then compiles the videos just after midnight each day. Its scheduled to captue between dawn and dusk using lat / long plus I add a bias before and after dusk to capture dark to light and vice versa.

The template started life as a WeatherByYou template "Weather Blues 2" (there is a section in the Sandaysoft forum) but as I learnt more I added more. I cant take all the credit for it, most of that goes to Jacques who developed the original template.

Andy

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Bash scrip

Postby water01 » Tue Aug 28, 2018 2:16 pm

OK thanks wondered if the PI was capable of doing the time lapse as well as everything else!!

dazza1223
Posts: 365
Joined: Sun Jan 25, 2015 8:41 pm
Weather Station: Davis Vantage Vue
Operating System: raspberry pi 3
Location: worthing
Contact:

Re: Bash scrip

Postby dazza1223 » Tue Aug 28, 2018 2:21 pm

i think it will be OK as i tried it with when i was running cumulus /SQL web server etc it a bit slow off making it but it dose the job and have u got the pi 3?

User avatar
Toxic17
Posts: 676
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis VPro2 Plus
Operating System: Debian 9.5 Stretch
Location: Bangor, NI
Contact:

Re: Bash scrip

Postby Toxic17 » Thu Aug 30, 2018 1:11 pm

ok had a look at the script which did work but have done some editing due to the fact uploading to WU for webcams should be no more than 2 minutes apart. 1 minute intervals will most likely be ignored.

so with that I suggest one crontab entry for uploading to WU, there by a separate script or command line entry.

every 2 minutes.

Code: Select all

# ftp webcam to wunderground
#
lftp -e 'put /share/htdocs/weather/image.jpg; bye' -u XXXXXXXX,xxxxxxxx webcam.wunderground.com


then 2 other scripts,

one to handle the image layers and create image and timed filenames:

Code: Select all

#!/bin/sh
#
# set variable yday to be like 20100208
#
# tday=$(date -d today +%Y%m%d%H%M%S);
# stamp=$(date '+DATE: %d/%m/%y%nTIME:%H:%M:%S');
tday=$(date +%Y%m%d%H%M%S);

# stamp=$(date +%Y%m%d);
#
# get weather image
wget --auth-no-challenge --http-user=xxxxx --http-password=xxxxxx "http://x.x.x.x/cgi/jpg/image.cgi" -O "/share/htdocs/weather/sky1.jpg";

# next 2 lines add weather info
#
testdata="$(/bin/cat /share/htdocs/weather/camdata.txt)";
testdata1=`date +"%A %d-%b-%Y %R %Z"`;

# convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 1280 25" \
#
convert -fill RoyalBlue4 -draw "fill-opacity 0.4 rectangle 0 0 1280 25" \
-fill red -draw "fill-opacity 0.6 rectangle 0 26 1280 27" \
-fill RoyalBlue4 -draw "fill-opacity 0.7 rectangle 0 695 1280 720" \
-fill red -draw "fill-opacity 0.6 rectangle 0 693 1280 694" \
-fill white -pointsize 18 -font /share/db_backup/script/arialbold.ttf -draw "text 10,20 'Conlig Weather Station:  $testdata1 - INEWTOWN20 - www.conligwx.org'" \
-fill yellow -pointsize 18 -draw "text 10,715 '$testdata'" /share/htdocs/weather/sky1.jpg  /share/htdocs/weather/skywebcam.jpg

# convert image.jpg to 150kb for WUnderground
#
convert /share/htdocs/weather/skywebcam.jpg -define jpeg:extent=150kb /share/htdocs/weather/image.jpg

# add timestamp to filename for image history and video timelapse.
cp /share/htdocs/weather/sky.jpg /share/htdocs/weather/image-history/video@"$tday".jpg;


the other to create a timelapse video from the image history (run once a day) atapprox 00:01

Code: Select all

#!/bin/sh
#maketimelapse movie
#
#set variable yday to be like 20100208
#
#yday=$(date +%Y%m%d %s -d $(( $(date +%s) - 86400 )));

yday=$(date -d "1 day ago" +%Y%m%d);
#
# make directory for yesterdays images
#
mkdir /share/htdocs/weather/image-history/"$yday";
# mkdir /volume1/Web/fishcam/image-history/"$yday";
#
# move yesterdays images to new directory sample image name is video@20100208000313.jpg
#
mv /share/htdocs/weather/image-history/video@"$yday"??????.jpg /share/htdocs/weather/image-history/"$yday"/;
# remove 0 byte files test script. find . -type f -size 0 | xargs ls -ld
cd /share/htdocs/weather/image-history/"$yday";
#find . -type f -size 0 | xargs rm;
# mv /volume1/Web/fishcam/image-history/video@"$yday"??????.jpg /volume1/Web/fishcam/image-history/"$yday"/;
# remove 0 byte files test script.
# cd /volume1/Web/fishcam/image-history/video@"$yday"??????.jpg /volume1/Web/fishcam/image-history/"$yday";
# /usr/bin/find . -type f -size 0 | xargs rm;
#
# create sequential files for ffmpeg to process apparently they have to be sequential for ffmpeg
#
x=1;
for i in $(ls -r -t /share/htdocs/weather/image-history/"$yday"/*jpg);
do counter=$(printf %04d $x);
ln -s "$i" /share/Public/tmp/img"$counter".jpg;
x=$(($x+1));
done;
#
#process with ffmpeg
#
# /volume1/.@plugins/AppCentral/upnp-server-v2/bin/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/weather/timelapse/"$yday".avi;
# /usr/local/bin/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/weather/timelapse/"$yday".avi;
ffmpeg -r 15 -f image2 -i /share/Public/tmp/img%04d.jpg -qmin 16 -qmax 26 /share/htdocs/weather/image-history/timelapse/"$yday".avi;
#
#tidy
#
rm /share/Public/tmp/img????.jpg;
#
# repeat final stages for fishcam..
#
# x=1;
# for i in $(ls -r -t /volume1/Web/fishcam/image-history/"$yday"/*jpg);
# do counter=$(printf %04d $x);
# ln "$i" /volume1/tmp/img"$counter".jpg;
# x=$(($x+1));
# done;
#
#process with ffmpeg
#
# /usr/local/bin/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/fishcam/timelapse/"$yday".avi;
# /volume1/Download/FFMPEG/ffmpeg -r 15 -f image2 -i /volume1/tmp/img%04d.jpg -qmax 9 /volume1/Web/fishcam/timelapse/"$yday".avi;
#
#tidy
#
# rm /volume1/tmp/img????.jpg;
#
#zip up yesterdays images to keep file count down
#

# /usr/builtin/bin/zip -rm0 /volume1/Web/fishcam/image-history/"$yday" /volume1/Web/fishcam/image-history/"$yday"
zip -rm9 /share/htdocs/weather/image-history/"$yday" /share/htdocs/weather/image-history/"$yday"


Please note I have not run the timelapse one for sometime and may differ from you own setups but it should give you an idea of how to create a timelapse video from your images you create from the previous day. I dont take credit for this, most of which was give to me by a friend (ho66es), and I had tweaked it to my setup and values I wanted for my layers.


Also inclusive is my CamdataT.txt template processed by CumulusMX to camdata.txt

Code: Select all

Temp: <#temp>°C - Press: <#press> hPa - Hum: <#hum>% - Wind: <#wspeed> mph(<#currentwdir>) - Rain: <#rfall> mm - UV Index: <#UV> - SolarRad: <#SolarRad> W/m² - CloudBase: <#cloudbase>.


hope this helps someone.
Regards Simon

https://www.conligwx.org
https://www.conligwx.org/pws/
https://twitter.com/conligwx
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image


Return to “Webcams”

Who is online

Users browsing this forum: No registered users and 2 guests