Page 1 of 1

Alert if webcam image out-of-date

Posted: Sat 03 Sep 2016 6:11 pm
by sarfend
Hi all,

I wonder if anyone has any suggestions on this one.

On my weather site, I have a display of my station data courtesy of Cumulus and the Saratoga PHP scripts. I also used Cumulus to upload a webcam image every 10 minutes.

It's not uncommon for something to go wrong - either the station stops collecting data, the PC locks.reboots or there's an error, which means my online data is out-of-date. I use a number of solutions to keep everything working (Cumulus Toolbox plus a PHP script that checks all's up to date. Everything works well, and I get email alerts if the weather data is out-of-date. The only thing I can't fix, is the webcam.

On occasion, the webcam capture software stops. Cumulus dutifully uploads whatever image it can find, so the website reports there's a recently-uploaded image, and the site displays an image.

Ideally, what I need is for Cumulus to spot that the image has a filestamp of >15 minutes, generate a tag, and I can detect that tag on the site.

My status page is here: - and using a site monitor, I can get an email alert if any errors appear on this page - what I can't do, is identify the age of the local jpg prior to Cumulus uploading it.

Anyone think of any clever ways around this?



Re: Alert if webcam image out-of-date

Posted: Sat 03 Sep 2016 10:05 pm
by beteljuice
Here's something the beteljuice put together many years ago ...

It uses three different images.
  • Checking Camera Status (loading.jpg - 3 seconds)
    Actual webcam image (cam_1.jpg)
    Off-Line image (offline.jpg)
It uses both Javascript in the web page and a php script to do the timestamp check.

Code: Select all

<!-- web page code -->

function LoadImage1()

        uniq1 = Math.random();
	document.images.webcam1.src = "opt.php?uniq="+uniq1;


function StartDelay()
        window.setTimeout("LoadImage1();", 3000); // status image delay
        window.setInterval("LoadImage1();", 30000); // subsequent loop

function DoIt1()
        window.setTimeout("LoadImage1();", 8000);


<!-- then where you put the image -->

<img src="loading.jpg" id="webcam1" name="webcam1" onload="StartDelay()" width=320 height=240 border=1 style="border-color:#a4a4ff; border-style:solid;">

... and the php file (opt.php)

Code: Select all


// Time to wait for showing the offline image in seconds

// We don't want cached results
// Get the time that the uploaded image is on the server
$calctime=date("U") - filemtime("cam_1.jpg");

// If the uploaded image exists and its new enough
if (file_exists("cam_1.jpg") and $calctime<=$offtime){
} else {
// Else send the predefined off-line image

Re: Alert if webcam image out-of-date

Posted: Mon 12 Sep 2016 10:01 pm
by f4phlyer
Not sure if Beteljuice answered your question but it seems you have more than basic skills. I would think it would be possible to create a script to check the image "metadata" for "create time/date" and compare it to current date, then handle the email the same. There are apps/programs to strip the metadata and put it in a file. Hope this helps