Using Cam4You and Canon A70 as webcam

I’ve had a lot of people reach the site from google looking for information about using their canon A70 (or similar models) as a webcam. Having got the Cam4You utility to work I thought I’d give a quick run through of the how of getting it to work.

Step 1: Install Application and turn camera on

Sensible really, but install the cam4you utility and when thats done turn your camera on in the “preview” mode, while connected to your computer. You should then, when running the application see the following image:

Step 1 - First Screenshot of Cam4You utility

Choose “Pictures->Take picture remote” from the menu and continue.

Step 2: Configure Directories and Start Remote Connection

Next, choose the download directory, and any settings you want and then click the “Start Remote Process” button.

Step 2 - Setup and start remote connection screenshot

Step 3: Setup webcam settings

Next, go to the webcam tab and enter the filename you want the webcam file to have. This can then be uploaded on a regular basis using whatever program you want to your web-site.

Step 3 -Setup webcam settings screenshot

Step 4: Configure Timings

Finally, set the timings. You can set a start-time, which must be in the future else the application will not work (if you want it to start straight away then untick the “Use Start” checkbox.
Set the interval – every 10 minutes, or whatever you decide (every hour even).
Then set the end criteria, if any, either stop time, maximum number of pictures, both, or neither. If the stop time is in the past it will never stop :D

Step 4 - Configure timings screenshot

Then click the “Start taking pictures remote” button. If this button is grayed out then go back to the first tab (“Remote”) and click the “Start Remote Process” button again. If the camera fails to take any pictures (or the Time left to next shot counts UP) then check the start time is in the future, not in the past!

Again, you will probably need both a tripod of some description and a power supply, so be warned. Finally, there are lots of settings you can fiddle with, compression quality, size of image, zoom, exposure etc but I shall let you play with them. Enjoy.

Save bandwidth with PHP caching

I have a php script that generates my list of amazon books, but due to the fact that this generates a lovely delay each time the page loads I set this to be a javascript page, using a document.write to output the html.

This has another side benefit, that I can use browser caching to save on my bandwidth by only refreshing the web service and outputting the whole page if its a old copy.

I decided that I’d only refresh the amazon javascript every day, anytime you see the books listed after that it’ll be a cached copy on your local system.

To implement this you need to be using apache, doesn’t work in IE.

You’re looking for a header called “If-Modified-Since” which the browser will send to see if a new copy is available.

$allheaders = getallheaders();
$if_modified_since = preg_replace(‘/;.*$/’, ”, $allheaders[‘If-Modified-Since’]);
$if_modified_time = strtotime($if_modified_since);

The getallheaders() function is a apache only function. Then you parse this header to get the time and convert to a time integer.

$part = 24 * 60 * 60;
$t = floor(time()/$part)*$part;

if ($if_modified_time > $t) {
   header(“HTTP/1.0 304 Not Modified”);
   exit;
}

This takes the current time, and flattens it to the nearest day. Then if the last modified since time if greater than this floored time send back the not modified header and exit.

Then, finally, if this is a ‘new’ file then send the last modified time as the current time.

$gmdate_mod = gmdate(‘D, d M Y H:i:s’, time()) . ‘ GMT’;
header(“Last-Modified: $gmdate_mod”);
header(“Content-Type: application/x-javascript”);

This output the Last-Modified header with the current timestamp. It also output the content-type as javascript, so it is handled properly.

Hope this helps.