Can You Give Me the Time of Day?

I’m a believer in both paying back and paying forward. Among
other ways, I’ve done so by donating my time, documented on these
pages, by creating mini-howtos
relating to, among other things, running Xandros Linux Deluxe
3.01, which is what I use, (this version costs $89.95USD but you
can download a free version that is crippled in some ways) in a
Netware environment and how to successfully convert from Windows.
I’ve also paid money to support other Open Source efforts like,
for example, the Mozilla Firefox browser. In addition, I’ve also
donated money to the American Red Cross and Salvation Army for
Katrina relief. Not to brag or anything, but I’ve donated close
to $3,000USD so far this year to various charitable/non-profit or
Open Source projects and have donated at least as much for at least the last three
or four years running.

Having done all that, I’ve very rarely asked for the
assistance of anyone but I’m asking for a small favor now.

I have a couple of security cameras at home that transmit
their images to a secured folder on my website. Every 30 seconds
or so a new image is transmitted from the Seto Shack to my web
host in Pittsburgh that overwrites the current one.

My cameras have built in servers that can display or transmit
images via the Internet. Although, for a time, I opened a port to
the outside world at the Seto Shack so I could access the images
directly from the camera via the Internet, I eventually decided
it wasn’t such a good idea to have a port open at home. So I
closed the web port and just have the webcams ftp utility upload
images to my website.

Given that setup, what I want to do is modify the image by
displaying on the image the date and time that the image was
taken. Knowing that fellow Daynoter Brian Bilbrey had a webcam
with time/date, I searched his site for what he was using. After
narrowing down the search to a number of hits that was usable
(using just “webcam” brought up every page with a masthead link
to his webcam! My bad.), I found that he is/was using something
called Stamp!.

So I downloaded, compiled, and installed Stamp! Although it
does add the date and time to an image (it reads the current
system and then overlays the image with this information), that’s
only part of what I want done. I want something that will
actually read the date/time of the image file itself and display
that in the image. That way, I will know when the image was
actually taken, not when Stamp! ran and checked the system
date/time (Stamp! runs periodically and is not otherwise keyed to
the taking of the image). This would be helpful to me not only
for diagnostic purposes (e.g., to check whether new images are
being uploaded correctly), but more importantly, also for
auditing/legal purposes should an image need to be used in a
court of law.

When wouldn’t the date/time match when the image was taken?
Well, almost every image would be off by as much as 29 seconds
but more worrisome is if, for some reason, the webcams should
stop transmitting, while at the same time Stamp! keeps running.
For example, should someone break into the Seto Shack, it is
possible they might disable the security system. Should that
occur, no new images would be sent, but Stamp!, running on the
webserver that powers seto.org, would continue to run. This means
the last image that was sent would continue to have it’s image
modified with the current time. Over and over again until I
turned Stamp! off. In other words, I would have an image that
perhaps was taken hours ago, but the date stamp would show the
current system time. This would probably cause some problems
should I need to use it as evidence before a court.

I tried Googling for something that would actually read the
file date/time instead of just reading the system clock but, so
far, have been unsuccessful.

In any case, if you know of anything that runs under *nix that
could do what I need done, please leave a comment or email using
the link in the right column of index page for this web site.
Thank you in advance.

[NOON UPDATE]

I’ve found a snippet of Perl code that purports to read a
file’s time stamp. The code is below:

use File::stat;
use Time::localtime;
$date_string = ctime(stat($file)->mtime);
print "file $file updated at $date_string\n";

When I created a Perl script, by adding the line
#!/usr/bin/perl and changed the
$file place holder with the real
file name of test.jpg, and then
executed the script (after setting the file permission for
execution) I got the following error:

Can’t call method “mtime” on an undefined value at ./timer.scr
line 5.

timer.scr is the name of the
executed file and line 5 points to $date_string =
ctime(stat($test.jpg)->mtime);

I know next to
nothing about Perl so I don’t know how to fix this error.

Advertisements

2 responses to “Can You Give Me the Time of Day?

  1. This may and may not be helpfull. I had right the opposit problem. The webcam I had would add a date and timestamp to all it’s immages. Rather annoying as it obscured almost 20% of the immage. The solution happened to be a setting in the driver, the same setting caused to give each immage a unique name (timestamp in the filename) causing the disk to fill up rather fast.
    So maybe you should check what the driver can do in stead of renaming and manipulating the files

  2. Rather than what you have done
    $date_string = ctime(stat($test.jpg)->mtime);
    which is lookign for a variable $test try this

    #!/usr/bin/perl
    use File::stat;
    use Time::localtime;

    $file=’test.jpg’;
    $date_string = ctime(stat($file)->mtime);
    print “file $file updated at $date_string\n”;