Foscam

From ZoneMinder Wiki
Revision as of 06:30, 9 January 2010 by Daveharris (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Foscam FI8908W IP Camera with PT (no Z) Working in ZM 1.24.2

Just thought this might be useful for anybody using the Foscam IP FI8908W Cameras.

They can be bought on eBay for around £50 and for that money they are a great buy. (Beware of fakes, see here: http://www.gadgetvictims.com/2009/09/yet-another-firmware-for-foscam-fi8908w.html)

A firmware upgrade can be performed to allow Server Push Mode, for FireFox etc.

See here for a instructions and a link to the firmware file: http://www.gadgetvictims.com/2009/07/foscam-ip-camera-part-two.html

I recommend firmware V11.14.1.42 and Web UI V2.4.8.11

Once that is done you can proceed to add the camera into ZoneMinder with the following settings:

General: Name: x Source Type: Remote Function: Modect (up to you though) Enabled: Tick Maximum FPS: Empty (I had some issues with it lagging when I used values here) Alarm Maximum FPS: Empty Source Remote Protocol: HTTP Remote Method: Simple Remote Host Name: x.x.x.x (The IP of the camera) Remote Host Port: 80 Remote Host Path: /videostream.cgi?user=admin&pwd= (assuming you have an admin user on the cam with no password) Remote Image Colours: 24 bit colour Capture Width: 320 (You could use 640 x 480, I found 320 to be better) Capture Height: 240

The other settings are for personal preference only – so I haven’t listed them.

I modified an existing camera control file to create this file which will allow you to pan and tilt the camera from the web interface (working in ZM V1.24.2)

Save the following in the same location as the other .pm files. You can search for “PanasonicIP.pm” on your machine and see where that is. In my case it is:

/usr/share/perl/5.10/ZoneMinder/Control

From a terminal window run:

sudo gedit

Which will open up your text editor in admin mode. Then paste the following between the +++ (excluding the +++) into the text editor:

+++


  1. ==========================================================================
  2. ZoneMinder Foscam FI8908W IP Control Protocol Module, $Date: 2009-11-25 09:20:00 +0000 (Wed, 04 Nov 2009) $, $Revision: 0001 $
  3. Copyright (C) 2001-2008 Philip Coombes
  4. Modified for use with Foscam FI8908W IP Camera by Dave Harris
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. ==========================================================================
  17. This module contains the implementation of the Foscam FI8908W IP camera control
  18. protocol

package ZoneMinder::Control::FoscamFI8908W;

use 5.006; use strict; use warnings;

require ZoneMinder::Base; require ZoneMinder::Control;

our @ISA = qw(ZoneMinder::Control);

our $VERSION = $ZoneMinder::Base::VERSION;

  1. ==========================================================================
  2. Foscam FI8908W IP Control Protocol
  3. ==========================================================================

use ZoneMinder::Debug qw(:all); use ZoneMinder::Config qw(:all);

use Time::HiRes qw( usleep );

sub new {

my $class = shift; my $id = shift; my $self = ZoneMinder::Control->new( $id ); my $logindetails = ""; bless( $self, $class ); srand( time() ); return $self; }

our $AUTOLOAD;

sub AUTOLOAD { my $self = shift; my $class = ref($self) || croak( "$self not object" ); my $name = $AUTOLOAD; $name =~ s/.*://; if ( exists($self->{$name}) ) { return( $self->{$name} ); } Fatal( "Can't access $name member of object of class $class" ); } our $stop_command;

sub open { my $self = shift;

$self->loadMonitor();

use LWP::UserAgent; $self->{ua} = LWP::UserAgent->new; $self->{ua}->agent( "ZoneMinder Control Agent/".ZM_VERSION );

$self->{state} = 'open'; }

sub close { my $self = shift; $self->{state} = 'closed'; }

sub printMsg { my $self = shift; my $msg = shift; my $msg_len = length($msg);

Debug( $msg."[".$msg_len."]" ); }

sub sendCmd { my $self = shift; my $cmd = shift; my $result = undef; printMsg( $cmd, "Tx" );

my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" ); my $res = $self->{ua}->request($req);

if ( $res->is_success ) { $result = !undef; } else { Error( "Error check failed:'".$res->status_line()."'" ); }

return( $result ); }

sub reset { my $self = shift; Debug( "Camera Reset" ); my $cmd = "reboot.cgi?user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Up Arrow

sub moveConUp { my $self = shift; $stop_command = "1"; Debug( "Move Up" ); my $cmd = "decoder_control.cgi?command=0&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Down Arrow

sub moveConDown { my $self = shift; $stop_command = "1"; Debug( "Move Down" ); my $cmd = "decoder_control.cgi?command=2&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Left Arrow

sub moveConLeft { my $self = shift; $stop_command = "1"; Debug( "Move Left" ); my $cmd = "decoder_control.cgi?command=4&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Right Arrow

sub moveConRight { my $self = shift; $stop_command = "1"; Debug( "Move Right" ); my $cmd = "decoder_control.cgi?command=6&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Diagonally Up Right Arrow

sub moveConUpRight { my $self = shift; $stop_command = "1"; Debug( "Move Diagonally Up Right" ); my $cmd = "decoder_control.cgi?command=91&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Diagonally Down Right Arrow

sub moveConDownRight { my $self = shift; $stop_command = "1"; Debug( "Move Diagonally Down Right" ); my $cmd = "decoder_control.cgi?command=93&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Diagonally Up Left Arrow

sub moveConUpLeft { my $self = shift; $stop_command = "1"; Debug( "Move Diagonally Up Left" ); my $cmd = "decoder_control.cgi?command=90&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Diagonally Down Left Arrow

sub moveConDownLeft { my $self = shift; $stop_command = "1"; Debug( "Move Diagonally Down Left" ); my $cmd = "decoder_control.cgi?command=92&user=admin&pwd="; $self->sendCmd( $cmd ); }

  1. Stop

sub moveStop { my $self = shift; Debug( "Move Stop" ); my $cmd = "decoder_control.cgi?user=admin&pwd=&command=1"; $self->sendCmd( $cmd ); }

  1. Move Camera to Home Position

sub presetHome { my $self = shift; Debug( "Home Preset" ); my $cmd = "decoder_control.cgi?command=25&user=admin&pwd="; $self->sendCmd( $cmd ); }

1;



+++

Now save that as ‘FoscamFI8908W.pm’ in the same location where you found the PanasonicIP.pm file.

(This file also assumes there is a user with the name admin and no password. If your setup is different, you will need to change this file). This is a first draft working version, I’ll tidy it up once ive learnt a bit more about perl 

Next you need to add the Control Type.

Click on edit and add a new control with these details:

Main: Name: Foscam FI8908W Type: Remote Protocol: FoscamFI8908W (No space in there) Move: Can Move: Tick Can Move Diagonally: Tick Can Move Continuous: Tick Pan: Can Pan: Tick Tilt: Can Tilt: Tick Presets: Has Presets: Tick Num Presets: 0 Has Home Presets: Tick

Save all that and you should be up and running.

A few more notes that I found useful:

Turning off the annoying green LED: (where x.x.x.x is the IP of your camera)

http://x.x.x.x/set_misc.cgi?led_mode=2&user=admin&pwd=

Stop the camera moving around when you reboot it:

http://x.x.x.x/set_misc.cgi?ptz_center_onstart=0&user=admin&pwd=

I initially had some issues with no images displaying in ZM. I found this to be a shared memory issue, see here:

http://www.zoneminder.com/wiki/index.php/FAQ#What_does_a_.27Can.27t_shmget:_Invalid_argument.27_error_in_my_logs_mean.3F_and_my_cameras_won.27t_display_video_at_higher_resolutions.

I found this guide useful for getting ZM 1.24.2 installed in the first place on my ubuntu box:

http://www.howtoforge.com/video_surveillance_zoneminder_ubuntu

I replaced:

ftp://www.northern-ridge.com.au/zoneminder/ubuntu/dapper/zoneminder_1.22.3-8_i386.deb

with

ftp://www.northern-ridge.com.au/zoneminder/1.24/ubuntu/jaunty/zoneminder_1.24.2-1_i386.deb

I have also heard of people replacing the existing lens in the Foscam Camera (it simply unscrews) with a 160° Wide Angle lens to give a better view. (Search eBay for ‘2.1mm CCTV Lens’). I haven’t tried this myself yet, but will at some point in the future.

On more thing to add. Since upgrading to 1.24.2 (I was originally on 1.23) I have had a few issues with apache locking up. I followed the recommended fix in this thread:

http://www.zoneminder.com/forums/viewtopic.php?p=51045

Which has helped a little but I’m still having a few issues. I have to run this command:

sudo apache2ctl restart

every now and then on the box (which I VNC into from my windows box) to restart apache.

Hope this is useful to some people.

Cheers,

DAVE.