IPCamera
(IP Camera Image Retrieval)

IP Camera image

See the download page to obtain this program

Overview

IPCamera allows images from a remote (Internet-connected) camera to be retrieved, stored, archived and displayed on a web page. Besides a Java program to retrieve and manipulate images, a Perl program is provided to organise images, and sample HTML pages with a Perl CGI script are provided to display these.

To see what the code does, look at images from the Loch Ard Sailing Club Web Camera.

The code has been tested with the Tenvis JPT3815, but should work with similar models by the same and other manufacturers. (Several essential identical cameras are marketed under different brand names.)

Configuration

GetCamera

The core program is the GetCamera Java class that is used to retrieve one image from an IP camera. This can be used on its own, but offers more capabilities when used with the get_camera Perl script.

Certain constants should be adjusted in GetCamera before compiling and running it:

CAMERA_PASSWORD
Set this if access to the IP camera is protected by a password.
CAMERA_USERNAME
xSet this if access to the IP camera requires a username
HUE_AMOUNT
Set this if the camera requires an adjustment in the hue of the image. The Tenvis JPT3815 may produce images that have unconvincing greens, so adjusting the hue can make the images look more natural.
SATURATION_AMOUNT
Set this if the camera requires an adjustment in the hue of the image. The Tenvis JPT3815 may produce images that look a bit washed out, so increasing the saturation can make the images look more natural.

Camera images are typically 640 pixels wide and 480 pixels high. After retrieving an image, its hue and saturation are adjusted (possibly without change). The current day and time are placed in the bottom left corner of the image. A thumbnail image (scaled 25% by default) is then produced. GetCamera might be called as follows:

    java GetCamera http://mycamera.dyndns.org:81 image159.jpeg
  

This will create the following in the current directory: 'image159.jpeg' (full image) and 'image159s.jpeg' (thumbnail image, 's' for small).

get_camera

The Perl program get_camera is an auxiliary program that collects and organises images. The program aims to store only a limited number of images, numbered 001, 002, etc. Image 001 is always the latest, with earlier images being 'shuffled down' until they exceed the maximum image count. The number of images preserved is a program constant (16 by default). In addition, get_camera will store one image at noon for archival purposes in the archive directory.

A log of image retrievals is maintained. If an image cannot be retrieved, a warning email is sent to primary and secondary recipients. This requires the Perl packages Mail::Mailer and Mail::Send; these can be installed from CPAN if necessary. To prevent a flurry of failure messages, email is sent intermittently (default every 3 hours).

Certain constants should be adjusted in get_camera before running it (see the customise subroutine):

CAMERA_HOST
Set this to the IP camera host name (e.g. 'mycamera.dyndns.org').
CAMERA_PORT
Set this to the IP camera port (e.g. '81').
CC
Set this to the email address of the secondary recipient (probably an alternative camera maintainer, e.g. maintainer2@firm.com').
FROM
Set this to the email address of the sender (probably the camera software developer, e.g. 'developer@firm.com').
SMTP
Set this to the host name of the SMTP server for sending email (e.g. 'smtp.firm.com').
TO
Set this to the email address of the primary recipient (probably the camera maintainer, e.g. 'maintainer1@firm.com').

get_camera can be run from the command-line without parameters. More typically it would be run on a scheduled basis (e.g. every half hour during daylight). On Windows this might be done using Task Scheduler, or on Unix with cron.

Web Pages

The web page images1.html is provided as a template that could be adapted to statically display the 16 most recent images.

The web page images2.html is provided as a template that could be adapted to generate the most recent images dynamically. This requires server-side execution of CGI scripts (e.g. as in the Apache web server). It calls the get_images CGI script with the path to where images can be found. The result is a dynamically generated HTML table (with 4 columns and 16 images by default). The script path and image path need to be set in the template web page provided.

Licence

This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation - either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but without any warranty, without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.

You may re-distribute this software provided you preserve its existing files. Bug reports should be sent to Ken Turner, who would also appreciate receiving any corrections and comments.

History

Version 1.0: First public release, Ken Turner, 18th February 2013


Up arrow Up one level to Graphical Utilities

Web Ken Turner Home   Email    Search Search Web Pages

Last Update: 18th February 2013
URL: http://www.cs.stir.ac.uk/~kjt/software/graph/ipcamera.html