Page 1 of 1

Axis 205 Network Camera image capture

Posted: Thu Jun 17, 2004 7:44 pm
by sinjar
Howdy,

I am trying to create a php script that will capture an image from my Axis 205 network camera every minute or so.

Sounds simple enough. I've done it before with other network cams but this one is a different.

The direct path to the camera's live image snapshot is http://www.exampleserver.com/jpg/image.jpg
(My camera is currently not online)

To view some live axis 205 cams here is a google search. Here is a sample snapshot

I have tried fopen($img_url), imagecreatefromjpeg ($img_url), and I also tried curl and Wget. Each php script I create using any of the above will hang and hang when trying to grab the image snapshot from the camera.

Here is a very simple example which works with any other jpg image but for some reason it just hangs with the netcam image snapshot:

Code: Select all

$img_url = "http://webcam1.webcows.se/jpg/image.jpg";

//create image 
$im = ImageCreateFromJpeg($img_url);

//output the image to the browser
header('Content-type: image/jpeg');
imagejpeg($im);
Any ideas would be much appreciated.

Posted: Thu Jun 17, 2004 8:10 pm
by ckuipers
I'd be interested in the same for the Axis 2120.

I've been able to do ftp uploads from this camera to a server and fetch the pics from there. But this is not very stable. The ftp client dies after a while.

So if someone found a way to do this straight from the camera, I'd be very interested.

Posted: Thu Jun 17, 2004 9:01 pm
by feyd
the google link provided seems to result in pages that require an ActiveX or MJPG plug-in.. At any rate, only mozilla seems to pull up the files without any problem.. although I didn't install the activex control.

Posted: Fri Jun 18, 2004 3:47 am
by PAW Projects
Does it work if you grab the image with file(), and then create a new GD image from that string?

Code: Select all

<?
$img_data = implode('', file('http://webcam1.webcows.se/jpg/image.jpg'));
$img = imagecreatefromstring ($img_data);
?>

Posted: Fri Jun 18, 2004 5:18 pm
by sinjar
Does it work if you grab the image with file(), and then create a new GD image from that string?
Nope, Whenever I try to open the image as a file the script just runs and runs and runs.

I have heard that Wget might work for this but I am not very familiar with Wget or how to use it with PHP.

Posted: Sun Jun 20, 2004 3:23 am
by ckuipers
The thing with these cameras is that they don't save the pics on the camera itself, but on a server. In my opinion it won't be possible to get the pictures straight from the camera.
If you manage to setup the ftp uploads in a more stable way than I could, you can do it like that...

Posted: Sun Jun 20, 2004 8:24 am
by sinjar
Well I got it working. Had to use unix Wget.

Code: Select all

<?php
// delete old image
if (file_exists("image.jpg")) unlink("image.jpg")

// Path to Axis 205 camera snapshot
$img_path =  "http://somecam.axiscam.net:8080/jpg/image.jpg";

// Grab the image with wget
// wget saves the image to the current dir if no dir is specified
$exec_str = "wget ".$img_path;
exec ($exec_str);


echo "<img src= "image.jpg" border="0">";

?>