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

My Custom Webcam

Hardware/software/hints and tips/discussion/webcam links etc
W2SWR
Posts: 17
Joined: Thu Mar 08, 2012 2:31 am
Weather Station: WH-1090
Operating System: vista
Location: Little River, SC.

My Custom Webcam

Postby W2SWR » Tue Apr 01, 2014 3:07 pm

Weather cam project
Image Image

I have created a weather cam that runs on a Raspberry PI mini PC and a Logitech HD C270 webcam that is overlay’ed with the current observations via Cumulus running on another (windows) pc.

These are more like notes than instructions.
YOU NEED TO KNOW; How to use wheezy linux (debian), How to set up Cumulus. to understand my instructions. Don’t ask me, google everything as I did.

This project requires the following:
Windows pc running Cumulus.
A web host with FTP capabilities to host your image and files.
A Raspberry Pi mini computer.
A webcam that successfully operates with the Raspberry PI (the C270 is plug-n-play)

Here is how I did it;
On the PI I installed:
fswebcam
imagemagick
libav-tools
ncftp

On the windows pc in C:\Cumulus\web\ I created a file called “overlay.sh”. This file needs to be processed by cumulus (see: cumulus help) and FTP to your web host in realtime mode.
Here it the script:

Code: Select all

#!/bin/sh
sleep 05
cd /home/pi/weathercam/
#places the icons on the image
composite -geometry +4+260 gauges.png rear.jpg \
rear3.jpg
#adds the trend arrows for temp and barrowmeter.
composite -geometry +129+282 <#temptrendtext>.png rear3.jpg \
rear2.jpg
composite -geometry +140+400 <#presstrendenglish>.png rear2.jpg \
rear4.jpg
#add the current readings
convert -size 75x20 rear4.jpg -pointsize 25 \
-draw "text 47,302 '<#temp>°F'" -fill white \
-draw "text 45,300 '<#temp>°F'" -fill black \
-draw "text 47,332 '<#hum>%'" -fill white \
-draw "text 45,330 '<#hum>%'" -fill black \
-draw "text 47,362 '<#wspeed> mph'" -fill white \
-draw "text 45,360 '<#wspeed> mph'" -fill black \
-draw "text 47,392 '<#wdir>'" -fill white \
-draw "text 45,390 '<#wdir>'" -fill black \
-draw "text 47,422 '<#press> in'" -fill white \
-draw "text 45,420 '<#press> in'" -fill black \
rear.jpg
sleep 3
./upload.sh

On the Raspberry PI, in the folder /home/pi I created a folder called weathercam. Then I created three files called mov.sh” , “runget.sh” and “upload.sh”. All files made as executable. Here is what I entered into the files:

Code: Select all

#runget.sh
#!/bin/sh
cd /home/pi/weathercam/
fswebcam -c /home/pi/weathercam/fswebcam.conf
wget http://host/path/to/your/overlay.sh
chmod +x overlay.sh
sleep 2
./overlay.sh

Code: Select all

#upload.sh
#!/bin/bash
rm overlay.sh*
ncftpput -t 30 -u username@yoursite.com -p password  yoursite.com / /home/pi/weathercam/rear.jpg
cp /home/pi/weathercam/rear.jpg /home/pi/weathercam/image.jpg
#If you have a weather underground PWS FTP account, then remove # from below.
#sleep 2
#ncftpput -y -t 60 -u yourCAM1 -p password webcam.wunderground.com / /home/pi/weathercam/image.jpg
sleep 2
rm rear2.jpg
rm rear3.jpg
rm rear4.jpg
rm image.jpg
mv rear.jpg /home/pi/weathercam/images-today/0$(date +%H%M).jpg
 



Code: Select all

#mov.sh
#!/bin/bash
 cd /home/pi/weathercam/images-yesteday
rm *.jpg
cd /home/pi/weathercam/images-today
cp -fr *.jpg /home/pi/weathercam/images-yesterday/
sleep 5
a=1
for i in *.jpg; do
new=$(printf "%04d.jpg" ${a}) #04 pad to length of 4
mv ${i} ${new}
let a=a+1
done
avconv -r 10 -i %04d.jpg rear.mp4
sleep 3
ncftpput -DD -t 30 -u username@yoursite.com -p password  yoursite.com / /home/pi/weathercam/images-today/rear.mp4
rm *.jpg



Another file called “fswebcam.conf” needs to be created to drive the camera. Remove the ## to use other options:

Code: Select all


device /dev/video0
resolution 640x480
##set brightness=52%
##set contrast=15%
##set saturation=19%
font /usr/share/fonts/truetype/freefont/FreeSansBold.ttf:18
##overlay /home/pi/weathercam/your custom logo.jpg
title "Hometown, USA."
subtitle "Looking Northwest"
timestamp "%m-%d-%Y %H:%M (%Z)"
##info "additional info"
jpeg 90
save /home/pi/weathercam/rear.jpg 
palette MJPEG




Save these images to your weathercam folder:
http://w2swr.com/downloads/index.php?fo ... FtLWZpbGVz
gauges.png Falling.png Rising.png Steady.png

Now create two subfolders in /home/pi/weathercam/
images-today
images-yesterday


Last thing you need to do is edit your PI’s crontab and add the following:

Code: Select all

# Builds and uploads an image every 5 mins on the fives.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/wundercam/runget.sh
#Builds and uploads a timelaps mp4 every night.
56 23 * * * /home/pi/wundercam/mov.sh
#dumps the trash each night
41 23 * * * rm /home/pi/.local/share/Trash/files/*
41 23 * * * rm /home/pi/.local/share/Trash/info/*


I hope you were successful.
Mike, W2SWR
Image
Image

Bridger
Posts: 32
Joined: Fri Jun 01, 2012 4:58 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP Pro
Location: New Forest. UK
Contact:

Re: My Custom Webcam

Postby Bridger » Sat Nov 08, 2014 5:07 pm

Mike, thanks for posting your scripts, they have encouraged me to have a go myself. I had no experience with the Raspberry Pi, or coding, so it has taken a little time and much Googling.
I have made a couple of changes to your scripts with apologies if they are not as elegant as they could be.
To try and preserve the Pi's SD card my camera operates only during daylight hours using <#isdaylight> webtag.

The file daylightget.sh is run from cron at 5 minute intervals.

Code: Select all

#daylightget.sh
#!/bin/sh
#gets daylight.sh
cd /home/pi/weathercam/
rm daylight.sh*
wget http://www.host/path/daylight.sh
chmod +x daylight.sh
sleep 2
./daylight.sh


Then this if it's daylight it runs runget.sh.

Code: Select all

#daylight.sh
#!/bin/sh
#checks Cumulus for daylight
daylight=<#isdaylight>
if [ $daylight -eq 1 ]
   then
   ./runget.sh
fi

I am also using the Humidity field in the image overlay to display the last hour's rain using <#rhour>, it displays relative humidity when there has been no rain in the last hour.

Code: Select all

#!/bin/sh
sleep 05
cd /home/pi/weathercam/
#is it raining?
a="0.0"
rain="<#rhour>"
raining="<#rhour>mm in last hour"
notraining="<#hum>%"
if [ "$rain" = "$a" ]
then
   itsraining=$notraining
else
   itsraining=$raining
fi
#places the icons on the image
composite -geometry +4+260 gauges.png rear.jpg \
rear3.jpg
#adds the trend arrows for temp and barometer.
composite -geometry +125+282 <#temptrendtext>.png rear3.jpg \
rear2.jpg
composite -geometry +155+400 <#presstrendenglish>.png rear2.jpg \
rear4.jpg
#place logo in bottom rh corner.
#composite -geometry +540+340 sign.png rear4.jpg \
#rear5.jpg
#add the current readings
convert -size 75x20 rear4.jpg -pointsize 20 \
-draw "text 47,302 '<#temp>°C'" -fill white \
-draw "text 45,300 '<#temp>°C'" -fill black \
-draw "text 47,332 '$itsraining'" -fill white \
-draw "text 45,330 '$itsraining'" -fill black \
-draw "text 47,362 '<#wspeed> mph'" -fill white \
-draw "text 45,360 '<#wspeed> mph'" -fill black \
-draw "text 47,392 '<#wdir>'" -fill white \
-draw "text 45,390 '<#wdir>'" -fill black \
-draw "text 47,422 '<#press> hPa'" -fill white \
-draw "text 45,420 '<#press> hPa'" -fill black \
rear.jpg
sleep 3
./upload.sh

The camera is installed in a stripped out security light (about £4 from Screwfix) and mounted on the garage wall. The Raspberry Pi is in the garage and accessed via WiFi.


Image Image
Thanks again. Peter

Sadgit
Posts: 99
Joined: Sun Jan 04, 2009 5:56 pm
Weather Station: Vantage Vue
Operating System: Windows 7
Location: Middlesbrough, England

Re: My Custom Webcam

Postby Sadgit » Sat Nov 08, 2014 6:24 pm

I love this place. I am looking to do this on my intel NUC running windows 7, but just wanted to say thanks, gives me some ideas about the overlay.

RussP
Posts: 3
Joined: Thu Jan 02, 2014 9:12 pm
Weather Station: OS WMR 88
Operating System: Win 8.1
Location: Lytham St. Annes

Re: My Custom Webcam

Postby RussP » Wed Apr 08, 2015 2:44 pm

Just like to thank W2SWR and Bridger for sharing the scripts for their set-ups.

I've got it up and running on a Pi2 with a Logitech c270

The changes I've made :
1. I'm also passing and displaying the temperature from my pond, so had to modify overlay.sh and gauges.png

2. I'm storing the /images-today, /images-yesterday, /movies folders on a USB pen drive instead of on the SD card. The scripts I've left on the SD card

3. After the .mp4 has been made I copy it to a folder called movies and give it a file name as that days date. That way I keep a file for each day.

Currently have a problem where fswebcam has an error after x period of time, and the only way to get it working again is to unplug/plug back in the camera or reboot the Pi. So for the time being I've just created a cron job to reboot the Pi every 30 mins.


To Do.
1. Decide on final position of the camera. I have a broken halogen light similar to the one Bridger shows, so may do similar. Currently points out my bedroom window.

2. merge the individual daily videos to create a single monthly video, and then a yearly video.

3. Get a second camera and have that pointing at my pond, and duplicate the scripts to do the same for this camera.

Image

User avatar
KetteringUK
Posts: 49
Joined: Sat Jul 25, 2009 2:25 pm
Weather Station: Maplin N96GY
Contact:

Re: My Custom Webcam

Postby KetteringUK » Sun Apr 26, 2015 5:03 pm

Thanks for sharing - Using Logitech 9000 with a few mods on the scripts

Image

Looking forward to trying Cumulus MX on the Pi2

philpugh
Posts: 108
Joined: Tue May 24, 2011 8:34 am
Weather Station: DAVIS VantageVue
Operating System: Debian (RPi) 3.18.11-v7
Location: Antrobus, Cheshire
Contact:

Re: My Custom Webcam

Postby philpugh » Thu Oct 01, 2015 9:23 am

What a great site. Just started playing with my RasPiCam and not satisfies with the crude overlays I have managed so far. Will be trying this out soon. Also love the idea of the unused security light housing. Have a couple lying around as I have replaced them with LED security lights.

philpugh
Posts: 108
Joined: Tue May 24, 2011 8:34 am
Weather Station: DAVIS VantageVue
Operating System: Debian (RPi) 3.18.11-v7
Location: Antrobus, Cheshire
Contact:

Re: My Custom Webcam

Postby philpugh » Thu Oct 01, 2015 5:13 pm

OK. Another method using a Raspberry PiCam. Based on the original post (thanks Mike/W2SWR).

My earlier attempts used Python and I decided to continue down this path. At present I am not too interested in keeping the images or making a time-lapse movie - but these can be added later so I based the processing on Mike's "overlay.sh" code - which seemed to do all the processing I needed.

I have a RPi 2 running CMX, Apache and MySQL and second RPi 2 with a PiCamera on it. I also run a NAS server onto which I store the SQL tables and use as a file storage for other stuff.

The outline is CameraPi takes an image every minute, does some simple image manipulation with ImageMagic as I want a thumbprint image for a link of my main weather web page. The processed overlay.sh is downloaded from the NAS box and called from the Python program which adds a simple opaque box area and writes CMX data onto the image.

There are three files.

1/ camdataT.txt is the template file processed as a realtime file by CMX to produce camdata.sh (my version of Mikes original overlay.sh)

2/ overlayphoto.py which is the Python script. This is run on CameraPi every minute as a cron task. It calls camdata.sh to do the majority of the image processing. It produces an output image weather.jpg at 70% quality as I have a very slow internet connection.

3/ bottom.png is a simple shaded box area so that the data can be read more easily - created on PC by Inkscape.

All three - with my site particulars removed, are in the attached rar file. If you are really desperate have a go!

Clicking on my signature banner should take you to my webserver - but I host it myself on the CMX Pi system and we have one of the slowest broadband connections imaginable - 0.5Mbps download/0.25Mbps upload on a good day!! In a couple of years we may be able to get 2Mbps we are told!! So be patient when browsing!
You do not have the required permissions to view the files attached to this post.

jules
Posts: 2
Joined: Sat Jun 30, 2012 7:25 pm
Weather Station: Vantage Pro2
Operating System: Mac OS Lion
Location: UK

Re: My Custom Webcam

Postby jules » Fri Oct 30, 2015 10:42 pm

i would like to do something similar, but before getting a logitech webcam with raspberry pi, i need to know if a powered usb hub is needed as well with the c270. i cant see any mention if this.
what other logitech webcams in the mid price range would also work?
thanks

RussP
Posts: 3
Joined: Thu Jan 02, 2014 9:12 pm
Weather Station: OS WMR 88
Operating System: Win 8.1
Location: Lytham St. Annes

Re: My Custom Webcam

Postby RussP » Wed Nov 04, 2015 2:09 pm

I run the c270 (well I did till a redecorated my bedroom, must look at how to set the pi2 up again without cables running across the floor)

I had it running via a powered hub, mainly due to also having a USB stick that I store the c270 images to. I cannot say how reliable it would be just plugged direct to the pi.

One problem I was having was that it would lose the camera from time to time. Sometimes it would be hours then other times after a few minutes of a reboot. Only way to get it back was a reboot. So I had a script to reboot the pi every hour.

logo9
Posts: 2
Joined: Thu Aug 04, 2016 2:56 pm
Weather Station: 1080
Operating System: Rpi3b
Location: NJ

Re: My Custom Webcam

Postby logo9 » Thu Aug 04, 2016 3:04 pm

I'm using a Rpi3b running weewx... I love the overlays but I don't want to run my home (windows) computer full time. Is there any way I can do overlays with just the pi?
Thanks for any info!!!
J



W2SWR wrote:Weather cam project
Image Image

I have created a weather cam that runs on a Raspberry PI mini PC and a Logitech HD C270 webcam that is overlay’ed with the current observations via Cumulus running on another (windows) pc.

These are more like notes than instructions.
YOU NEED TO KNOW; How to use wheezy linux (debian), How to set up Cumulus. to understand my instructions. Don’t ask me, google everything as I did.

This project requires the following:
Windows pc running Cumulus.
A web host with FTP capabilities to host your image and files.
A Raspberry Pi mini computer.
A webcam that successfully operates with the Raspberry PI (the C270 is plug-n-play)

Here is how I did it;
On the PI I installed:
fswebcam
imagemagick
libav-tools
ncftp

On the windows pc in C:\Cumulus\web\ I created a file called “overlay.sh”. This file needs to be processed by cumulus (see: cumulus help) and FTP to your web host in realtime mode.
Here it the script:

Code: Select all

#!/bin/sh
sleep 05
cd /home/pi/weathercam/
#places the icons on the image
composite -geometry +4+260 gauges.png rear.jpg \
rear3.jpg
#adds the trend arrows for temp and barrowmeter.
composite -geometry +129+282 <#temptrendtext>.png rear3.jpg \
rear2.jpg
composite -geometry +140+400 <#presstrendenglish>.png rear2.jpg \
rear4.jpg
#add the current readings
convert -size 75x20 rear4.jpg -pointsize 25 \
-draw "text 47,302 '<#temp>°F'" -fill white \
-draw "text 45,300 '<#temp>°F'" -fill black \
-draw "text 47,332 '<#hum>%'" -fill white \
-draw "text 45,330 '<#hum>%'" -fill black \
-draw "text 47,362 '<#wspeed> mph'" -fill white \
-draw "text 45,360 '<#wspeed> mph'" -fill black \
-draw "text 47,392 '<#wdir>'" -fill white \
-draw "text 45,390 '<#wdir>'" -fill black \
-draw "text 47,422 '<#press> in'" -fill white \
-draw "text 45,420 '<#press> in'" -fill black \
rear.jpg
sleep 3
./upload.sh

On the Raspberry PI, in the folder /home/pi I created a folder called weathercam. Then I created three files called mov.sh” , “runget.sh” and “upload.sh”. All files made as executable. Here is what I entered into the files:

Code: Select all

#runget.sh
#!/bin/sh
cd /home/pi/weathercam/
fswebcam -c /home/pi/weathercam/fswebcam.conf
wget http://host/path/to/your/overlay.sh
chmod +x overlay.sh
sleep 2
./overlay.sh

Code: Select all

#upload.sh
#!/bin/bash
rm overlay.sh*
ncftpput -t 30 -u username@yoursite.com -p password  yoursite.com / /home/pi/weathercam/rear.jpg
cp /home/pi/weathercam/rear.jpg /home/pi/weathercam/image.jpg
#If you have a weather underground PWS FTP account, then remove # from below.
#sleep 2
#ncftpput -y -t 60 -u yourCAM1 -p password webcam.wunderground.com / /home/pi/weathercam/image.jpg
sleep 2
rm rear2.jpg
rm rear3.jpg
rm rear4.jpg
rm image.jpg
mv rear.jpg /home/pi/weathercam/images-today/0$(date +%H%M).jpg
 



Code: Select all

#mov.sh
#!/bin/bash
 cd /home/pi/weathercam/images-yesteday
rm *.jpg
cd /home/pi/weathercam/images-today
cp -fr *.jpg /home/pi/weathercam/images-yesterday/
sleep 5
a=1
for i in *.jpg; do
new=$(printf "%04d.jpg" ${a}) #04 pad to length of 4
mv ${i} ${new}
let a=a+1
done
avconv -r 10 -i %04d.jpg rear.mp4
sleep 3
ncftpput -DD -t 30 -u username@yoursite.com -p password  yoursite.com / /home/pi/weathercam/images-today/rear.mp4
rm *.jpg



Another file called “fswebcam.conf” needs to be created to drive the camera. Remove the ## to use other options:

Code: Select all


device /dev/video0
resolution 640x480
##set brightness=52%
##set contrast=15%
##set saturation=19%
font /usr/share/fonts/truetype/freefont/FreeSansBold.ttf:18
##overlay /home/pi/weathercam/your custom logo.jpg
title "Hometown, USA."
subtitle "Looking Northwest"
timestamp "%m-%d-%Y %H:%M (%Z)"
##info "additional info"
jpeg 90
save /home/pi/weathercam/rear.jpg 
palette MJPEG




Save these images to your weathercam folder:
http://w2swr.com/downloads/index.php?fo ... FtLWZpbGVz
gauges.png Falling.png Rising.png Steady.png

Now create two subfolders in /home/pi/weathercam/
images-today
images-yesterday


Last thing you need to do is edit your PI’s crontab and add the following:

Code: Select all

# Builds and uploads an image every 5 mins on the fives.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/wundercam/runget.sh
#Builds and uploads a timelaps mp4 every night.
56 23 * * * /home/pi/wundercam/mov.sh
#dumps the trash each night
41 23 * * * rm /home/pi/.local/share/Trash/files/*
41 23 * * * rm /home/pi/.local/share/Trash/info/*


I hope you were successful.
Mike, W2SWR
Image

logo9
Posts: 2
Joined: Thu Aug 04, 2016 2:56 pm
Weather Station: 1080
Operating System: Rpi3b
Location: NJ

Re: My Custom Webcam

Postby logo9 » Tue Nov 22, 2016 9:51 pm

I'm using a Rpi3b running weewx... I love the overlays but I don't want to run my home (windows) computer full time. Is there any way I can do overlays with just the pi?
Thanks for any info!!!
J

EDIT: I got it to run on a Rpi3b as a stand alone (Pi only) program. Lots of head scratching for a non-programer!

https://www.wunderground.com/webcams/JW2030/3/show.html

User avatar
Peristeri Center
Posts: 9
Joined: Sun May 31, 2009 12:03 pm
Weather Station: TFA Matrix II 3510.49
Operating System: Peppermint OS 8 (Linux).
Location: Athens-Peristeri GREECE
Contact:

Re: My Custom Webcam

Postby Peristeri Center » Tue Jul 25, 2017 10:35 am

Hey all.

I see it's an "old" topic but i like this overlay. Unfortunately the link to download png images, is "dead" :groan:
Can someone direct me on an active link, for download that images?

Thank's in advance.
N.B.

Bridger
Posts: 32
Joined: Fri Jun 01, 2012 4:58 pm
Weather Station: Davis Vantage Vue
Operating System: Windows XP Pro
Location: New Forest. UK
Contact:

Re: My Custom Webcam

Postby Bridger » Wed Jul 26, 2017 8:43 am

Are these what you are looking for?
You do not have the required permissions to view the files attached to this post.

User avatar
Peristeri Center
Posts: 9
Joined: Sun May 31, 2009 12:03 pm
Weather Station: TFA Matrix II 3510.49
Operating System: Peppermint OS 8 (Linux).
Location: Athens-Peristeri GREECE
Contact:

Re: My Custom Webcam

Postby Peristeri Center » Wed Jul 26, 2017 10:46 am

YES
I look for that. I didn't a reply !
Thank you Peter.

User avatar
Peristeri Center
Posts: 9
Joined: Sun May 31, 2009 12:03 pm
Weather Station: TFA Matrix II 3510.49
Operating System: Peppermint OS 8 (Linux).
Location: Athens-Peristeri GREECE
Contact:

Re: My Custom Webcam

Postby Peristeri Center » Wed Jul 26, 2017 7:15 pm

Thank you, Peter, soooooo.......much.

Now is up and running.

http://peristeri.altervista.org/webcam.htm


Return to “Webcams”

Who is online

Users browsing this forum: ronwright418 and 4 guests