Axis 205 Network Camera image capture

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sinjar
Forum Newbie
Posts: 3
Joined: Thu Jun 17, 2004 7:44 pm

Axis 205 Network Camera image capture

Post 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.
ckuipers
Forum Commoner
Posts: 61
Joined: Mon Mar 24, 2003 6:10 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
PAW Projects
Forum Commoner
Posts: 30
Joined: Tue Jun 15, 2004 7:43 am
Contact:

Post 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);
?>
sinjar
Forum Newbie
Posts: 3
Joined: Thu Jun 17, 2004 7:44 pm

Post 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.
ckuipers
Forum Commoner
Posts: 61
Joined: Mon Mar 24, 2003 6:10 am

Post 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...
sinjar
Forum Newbie
Posts: 3
Joined: Thu Jun 17, 2004 7:44 pm

Post 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">";

?>
Post Reply