Updating a webcam image

Post Reply
User avatar
Steve Harpin
Observer
Observer
Posts: 48
Joined: Wed Dec 13, 2017 7:08 pm
Location: York England
Station model: Fine Offset WH1080
Software: Cumulus

Updating a webcam image

Post by Steve Harpin » Thu Sep 17, 2020 8:29 am

I am currently engaged in trying to find the absolute neatest way to project my weather webcam image up onto my Meteo site. I have heard comments about the image accumulation propensities of Jachym's webcam plugin (as opposed to the block which I use with simple links to various other weather webcams) and, even when I had a Reolink camera that actually did that successfully it, sadly, knocked off after several months and absolutely refused ever to co-operate again. Thanks for all the hard work, Jachym, but this particular plugin has left me personally baffled. Others say it works great and that has left me somewhat envious but still baffled :roll: Now we come up to the present time and I have binned the Reolink (no patience with the clunky client software)and got a Foscam which is a big, big improvement. I have also obtained a WD NAS on which to store a lifetime's worth of snapshots and time-lapse videos. Perfecto. The Foscam is currently doing just those two features and storing them on the NAS. What I am really intrigued by is the notion of putting a script on the NAS that pushes a constantly updated snapshot up to a webpage of my own design which I can then link to Meteo, probably on the menu bar. I have read that this appears highly possible on another thread on the forum but, tantalisingly, no examples. Currently I have done away with the cronjob for updating the webcam image as I would prefer, as I say, to NOT use the webcam plugin I have started to teach this fossilised old brain the basics of php but if anyone out there can give me a headstart I would much appreciate it
Image

ZSN
Newbie
Newbie
Posts: 7
Joined: Fri Dec 04, 2020 8:09 am
Location: Zimbabwe
Station model: Davis 2 Pro
Software: Weatherlink
Contact:

Re: Updating a webcam image

Post by ZSN » Thu Dec 10, 2020 7:51 am

Hi I'll start by saying that i'm no IT expert and have battled through a lot to get things to work. I hope that my 2 cents adds some value to you.
Camera
I am using a standard HikVision POE IP security camera (4mp) as my weather cam. The motivation is that they a readily available and easy to set up. In the HikVision software on the camera I set it up to FTP images to my web server host at 5 minute intervals. You can set parameters such as:-
  • a schedule when you want to send images and the resolution of the images.
  • hikconnect if you would like to be able to view your camera in real time from your phone.
  • motion triggered events instead of time
  • the folder under your FTP root directory to save the files and the file prefix.

FTP Image Files
These are uploaded to a directory eg /ftp root/cams/site/, each with a unique timestamped file name.
For you NAS you will then have a list of files you can keep indefinitely. The problem is meotemplate needs a specific file name to you webcam image so I use a cron job running every 3 minutes to find the latest file rename it to image.jpg and delete everything else. I do not need the history, as Metotemplate can store the 5 minute image.jpg files and i can easily select how long i would like to keep them for in the template so no need to have the original documents.
The Cron
This I run every three minutes from the ftp/webhost.

Code: Select all

<?php
#############################################################################################################
## Script to rename Hikvision IP uploaded files containing date and time in file name to a new fixed filename
## adapted from morfeas2002 http://kalamata.meteoclub.gr/
## CAUTION this script will remove any ???.jpg uploaded files from the folder except the latest file, that is renamed to image.jpg
#############################################################################################################

//date_default_timezone_set("Europe/London");
$dir = "./"; // change to suit your system relative to where this script is executed
$pattern = '\.(jpg)$';
//
$newstamp = 0;
$newname = "";
//
if ($handle = opendir($dir)) {
while (false !== ($fname = readdir($handle))) {
// Eliminate current directory, parent directory
if (preg_match('/^\.{1,2}$/',$fname)) continue;
// Eliminate other pages not in pattern
if (! preg_match('/\.(jpg)$/',$fname)) continue;
// -------------
$pinakas[] = $fname;
}
//
sort($pinakas);
//
$posot = count($pinakas);
//
if ($posot>1) $newname = $pinakas[$posot-2];
if ($posot==1) $newname = $pinakas[$posot-1];
}
closedir ($handle);
// $newname
//
copy("./$newname", "./image.jpg"); // change to suit your system relative to where this script is executed
//
$filesa = glob('./*.jpg'); // change to suit your system relative to where this script is executed
// Remove the newest from your list. added my K Leliard
array_pop($filesa );

// Delete all the other files - if you want to keep them then comment this out
array_walk($filesa,'myunlink');
//
function myunlink($t)
{
unlink($t);
}
echo ("done")
?>
meteotemplate
If you read the webcam plugin notes it says to move the updateWebcam.php to the /load/crons folder - once i did this the plugin worked a lot better surprisingly.

Hope this helps

johnathan
Observer
Observer
Posts: 29
Joined: Thu Apr 08, 2021 1:14 pm
Station model: wh1080
Software: WU

Re: Updating a webcam image

Post by johnathan » Wed Jan 12, 2022 1:21 pm

A custom software development company https://mlsdev.com/ can use a proprietary approach, which means they own the intellectual property, and therefore make it impossible for you to copy what they've done. This can result in businesses becoming dependent on their proprietary technologies. In some cases, you may want to use a different language or format than what is currently available. It's important to ask about the specific languages and formats that a software development company is familiar with, as this will affect the quality of the product.

Post Reply