Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Displaying webcam images - got a recursive dir Iterator

Hardware/software/hints and tips/discussion/webcam links etc
Post Reply
Warrandyte
Posts: 41
Joined: Sat 06 Apr 2013 11:46 pm
Weather Station: Fine Offset with Solar
Operating System: Windows XP, 7 8 and 10
Location: TIrrannaville NSW Australia

Displaying webcam images - got a recursive dir Iterator

Post by Warrandyte »

http://www.warrandytefarm.com/test/getimagenames.php

the code is below for anyone who wants one that works on php4+

Code: Select all

<?php

/**
 * @author Rob France
*/
$myfile = new RecursiveDirectoryIterator("webcam/");
$display = Array ('jpeg', 'jpg' );
foreach(new RecursiveIteratorIterator($myfile) as $file)
{
    if (in_array(strtolower(array_pop(explode('.', $file))), $display))
/**        echo "<img src='" . $file . "'width='600' height='400'><br/> \n";
 uncomment the above to display the images */
        echo $file . "<br/> \n";
}
?>
now I have that's going, I need to filer by camera number and date, probably using drop downs but I get kind of stuck there.

its been a lot of headaches trying to get all the recursive stuff to work

webcams is a subdirectory of the root from where the script is run

another one getimages.php will give the images using the same code but theres a lot of them and i dont want to blow peoples bandwidth

There is probably also a much better way of doing this using glob functions or similar but I cant convince my hosting people to get away from php4

I have used the filenames Cam1_ cam2_ etc and the dates are the main folder names apart from a few rogues that have crept in there.
You do not have the required permissions to view the files attached to this post.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Displaying webcam images - got a recursive dir Iterator

Post by beteljuice »

Warrandyte wrote:the code is below for anyone who wants one that works on php4+ ...
I've never seen / used

Code: Select all

RecursiveDirectoryIterator()
RecursiveIteratorIterator()
according to the blurb they are php5.
I'd be doing it a more 'old fashioned' way.
now I have that's going, I need to filer by camera number and date, probably using drop downs but I get kind of stuck there.
Really need an example of a couple of 'full' file path / names, plus how do you want to present them ?
eg. latest / asked for one then list of others, or perhaps latest / asked for one then thumbnails of the others ? etc. etc.
Image
......................Imagine, what you will KNOW tomorrow !
Warrandyte
Posts: 41
Joined: Sat 06 Apr 2013 11:46 pm
Weather Station: Fine Offset with Solar
Operating System: Windows XP, 7 8 and 10
Location: TIrrannaville NSW Australia

Re: Displaying webcam images - got a recursive dir Iterator

Post by Warrandyte »

They all list under the link.

Apologies i meant 5.4 rather than 5.5. My subversive subversion thinking.

I went to throw them all into an array sorted by filename which gives the date and filtered by camera number which is the Filename prefix (as i think most cameras allow this method)

As you can see from the output they list under webcam folber by date yyyymmdd then subfolders by hour (h24)

However to give a general solution others can pick up and use then it probably needs to be a bit configurable.

Images vary but getting the latest image for a certain file prefix eg Cam1 would be preferable.

Then being able to select backwards by date or time or hour in this case.

I was surprised there wanst already a gallery page out there already but i gather its beyond many people.

Of all the coding sites no one ever posts a final solution leaving everyone to reinvent the wheel.

For those of us that develop in the 5 spare minutes a day between screams of kids. Its hard to keep focussed.

Oh the good old days doing GPS stuff where i could just stay up all day and night, even take the laptop to the park or coffee house!
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Displaying webcam images - got a recursive dir Iterator

Post by beteljuice »

I'm still not following your directory architecture ....

are you saying:
webcam/yyyymmdd/[h01 > h24]/...
cam1_?????.jpg
cam2_?????.jpg

... and what is the format of _?????, eg. would there be more than one instance of cam1_ in eg. h01 folder ?

It doesn't look like the friendliest of structures to reverse engineer, especially as the cam id is last man in.

... and although I've never used it I'm a little concerned about:

Code: Select all

foreach(new RecursiveIteratorIterator($myfile) as $file)
{
Shouldn't that be more like ?

Code: Select all

$iterator = new RecursiveIteratorIterator($myfile);
foreach($iterator as $file)
{
Image
......................Imagine, what you will KNOW tomorrow !
Warrandyte
Posts: 41
Joined: Sat 06 Apr 2013 11:46 pm
Weather Station: Fine Offset with Solar
Operating System: Windows XP, 7 8 and 10
Location: TIrrannaville NSW Australia

Re: Displaying webcam images - got a recursive dir Iterator

Post by Warrandyte »

/webcam/yyyymmdd/hh/Cam(x)__YYYYMMDDhhmmssms.jpg and its a bugger.

the number of images is dependant on the hour divided by minutes per image (or seconds per image if you had unlimited bandwidth)

4 cameras, same (ha ha) firmware versions

2 different methods

two under YYYYMMDD directly, the other two use the subfolder by hour and you cant do much about the image name.

Ive tried a few different cams to see if there was one good version, but no, and writing something like this it may as well take care of a few types of cameras.

I have tried so many camera and application combinations but they all seem to have issues. yawcam was great till I moved OS then it wouldn't work again, and 4 instances were very resource hungry, same with webcamxp and webcam7.
Post Reply