WXforum.net

Weather Software => RaspberryPI Weather Software => Topic started by: rosegeek on April 25, 2020, 09:13:26 PM

Title: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: rosegeek on April 25, 2020, 09:13:26 PM
With a Pi-4 I set up a DIY timelapse with overlayed weather conditions.  I set up the Pi to run ffmpeg (free) to grab images from camera every 10 seconds, saved to USB drive, then pull conditions from meteobridge and overlay them on the captured image.  After an hour, I use ffmpeg to merge all the images (with overlayed conditions) into an mp4 timelapse.  Final step is to upload the timelapse(s) to my site.
Then I can set the Pi up headless, hidden away let it do it's thing 24/7.
Sample Timelapse:
http://www.weather.gloryhomemi.com/weathercam/cool_sunset_timelapse.mp4

I can share details if interested.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: 92merc on April 26, 2020, 12:12:17 AM
I would be interested in the details.  I'd likely do it via a Windows PC.

I have a web server already running on my Weather PC, so I'd probably serve them up that way.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Garth Bock on April 26, 2020, 10:07:54 PM
Awesome !
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: josecmorales on April 27, 2020, 10:57:05 AM
Pretty awesome, would you mind to explain it? i´m insteresting!
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: USAF_Pride on May 01, 2020, 06:30:49 AM
Here is a github project for timelapse.  I've used this for building projects and is quite customizable:

https://github.com/Tom25/ipcam-timelapse
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: wxthomson on May 01, 2020, 08:54:03 PM
Very Cool!

Also interested.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Bushman on May 01, 2020, 10:30:37 PM
In Windows, you could use PowerShell or even a simple batch file to call FFMPEG.  The weather conditions overlay can be done with Imagemajick once you write out a text file.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Wayne Orwig on May 03, 2020, 09:10:30 AM
With a Pi-4 I set up a DIY timelapse with overlayed weather conditions. 

I can share details if interested.

I am interested in knowing how you overlayed the weather data onto the images.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: USAF_Pride on May 03, 2020, 01:06:49 PM
With a Pi-4 I set up a DIY timelapse with overlayed weather conditions. 

I can share details if interested.

I am interested in knowing how you overlayed the weather data onto the images.

What camera are you using?
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Wayne Orwig on May 04, 2020, 12:17:40 PM
With a Pi-4 I set up a DIY timelapse with overlayed weather conditions. 

I can share details if interested.

I am interested in knowing how you overlayed the weather data onto the images.

What camera are you using?

I have two cameras.
One is a simple USB camera on a RaspberryPI port, that I use 'fswebcam' once a minute to grab an image. I save the last ten images, and use 'convert' to make an animated GIF of those.
The other camera FTPs an image to my Raspberry PI web page.

I have the JSON with the data. I'm looking for a convenient way to overlay some of the text on the images. I currently have an HTML file, and cron runs 'chromium' to run the javascript in the html file and outputs the web page to a captured image. It works for a still image, but it is clunky.

http://hogmountain.asuscomm.com/image.png (http://hogmountain.asuscomm.com/image.png)
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: rosegeek on May 05, 2020, 10:05:05 PM
For Win10 you can see the below post for more details how to implement.  Basically, use Win Task Mgr to trigger events (at startup to set camera streaming, each min to capture still, each hr to create timelapse).
https://www.wxforum.net/index.php?topic=39226.msg403562#msg403562
For Linux:  The Pi-4 is very capable SBC.  Process was similar to Win but instead of setting up RTSP (real-time streaming protcol) to run continuously and only capture frames every 10 seconds (uses 25% cpu) I setup an infinite loop to RTSP  a single image every 10 seconds - resulting in only 10% cpu load on average.  Trick is to make sure loop can finish within 10 seconds or else images will not be evenly spaced in timelapse that looks bad.  The Pi-4 can do it iwithin 4 sec's.
Overview:  This all runs in 4 bash scripts.
1) CRON triggers "Image_from_cam.sh" @restart captures jpg images from camera every 10 seconds - runs forever.  Stores in dir "timelapse" on USB drive.
2) CRON triggers "Overlay_text.sh" every minute:  reads meteobridge weather data (customizable) to "conditions.txt" file (current conditions from station).  Use ffmpeg to overlay conditions.txt to on all jpg images captured from 1).  Store in new dir to accumulate images for timelapse processing in next step (jpg_with_overlay).   Also save in another dir (long) for 8hr timelapse.
3) CRON triggers "TimelapseRTSP.sh" every hr:  Use ffmpeg to build mp4 from jpg's in dir jpg_with_overlay.  Then upload to site using SCP (secure CP).
4) CRON triggers "TimelapseRTSP_long.sh" every 8hrs:  Same as 3 except makes timelapse from dir "long"
Bonus:  in 3) and 4) added banner during sunset time "Sunset XX:XX" in Amber before sunset and in Red after.  Fun, not req'd!
Note:  CRONs have optional Log files for debug and history.  Scripts written to run from anywhere (no local dir references) - all point to USB drive.
Directory Structure:  See definitions in files to see.  Adjust to your choice.
Files attached: changed .sh to .txt for upload to this site.
Encouragement:  I'm no software guy (as you s/w guys will see from my "code").  I tried to make it somewhat fail-safe using all direct dir references.  Use at your own risk.  Enjoy the process of DIYing your own system.  Much more fun IMHO to learn instead of paying someone to do the same thing!  Happy to help you along the process.  However, you need to do your own homework!
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Bushman on May 05, 2020, 10:48:04 PM
Interesting workflow.  Why FFMPEG vs. ImageMajick CONVERT?
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: rosegeek on May 05, 2020, 10:52:53 PM
With a Pi-4 I set up a DIY timelapse with overlayed weather conditions. 

I can share details if interested.

I am interested in knowing how you overlayed the weather data onto the images.

What camera are you using?
I use Reolink POE Camera RLC-410.  There is a HD and 5MP version.  I have both running in parallel on my Pi-4 in 16:9 aspect ratio.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: rosegeek on May 05, 2020, 11:07:07 PM
Interesting workflow.  Why FFMPEG vs. ImageMajick CONVERT?
Prob can use either.  FFMPEG is much more in use though (about 3x).  I've used FFMPEG for RTSP single image, videos, overlay and timelapse - very stable and reliable although 100% command line.  What is your take?
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Bushman on May 05, 2020, 11:51:25 PM
I use a lot of D-Link cameras and they all create time-stamped photos so for me, overlaying with ImageMagick  is easier.  Plus you can pretty much script the whole thing in Python pon a PC rather than piece-mealing it.  But your solution(s0 is cool!
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Wayne Orwig on May 06, 2020, 10:53:45 AM
Interesting workflow.  Why FFMPEG vs. ImageMajick CONVERT?

Does convert do text overlays? I have not found an option for that.
I never would have thought to use ffpmeg for text overlays.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: rosegeek on May 06, 2020, 01:29:40 PM
I use a lot of D-Link cameras and they all create time-stamped photos so for me, overlaying with ImageMagick  is easier.  Plus you can pretty much script the whole thing in Python pon a PC rather than piece-mealing it.  But your solution(s0 is cool!
D-Link have one wireless consumer grade camera.  Reolink has a wide selection (that's all they do).  I use a POE that is has excellent price:performance, no lag/stability issues that can occur with WiFi solutions.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: Bushman on May 06, 2020, 02:02:56 PM
Interesting workflow.  Why FFMPEG vs. ImageMajick CONVERT?

Does convert do text overlays? I have not found an option for that.
I never would have thought to use ffpmeg for text overlays.

Example: "convert img1.jpg -font helvetica -pointsize 9 -draw "text 167,554 'userName'" -pointsize 7 -draw "text 145,596 'userTitle'" img1b.jpg"  This is the way that Meteobridge does it too.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: USAF_Pride on May 07, 2020, 08:14:14 AM
I use Dahua cameras and via an API, I can continually update the text directly on the camera (other cameras can do this as well). My workflow is as follows:
1. you get the weather information you want to display on the camera, and then send an HTTP call to the camera to set the text
2. Run ipcam-timelapse at selected intervals

If you wanted to, you could have 1 script via cron setting the weather information every minute, but have the timelapse pull it every 5. This way when you live view the screen, the current data is loaded.  The trick is to avoid lower end consumer cameras that don't allow API calls to set the text directly on the camera.
Title: Re: Weathercam Timelapse with Overlay Weather data on a RP-4
Post by: rosegeek on May 07, 2020, 10:22:53 PM
Maybe we are getting away from original intention of the post.  Timelapse on a RP-4.  Yes, there are turn-key solutions and paid sites that create and host timelapse, but this is about a DIY project that allows for complete flexibility and creativity.  I never used a Rasp Pi before.  I learned it is quite capable of processing images and creating timelapse from multiple streams simultaneously.  It's been fun learning "how to" and I hope this post inspires others to do the same.