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

Within Zoneminder you can add various cameras, usb cams, network cams etc. If you are using a network camera, you need to write custom code in Perl to be able to control the Pan, Tilt and Zoom (PTZ) from within the web interface. This is something I wrote a little while back and thought it might be useful for anybody using the Foscam IP FI8908W Cameras with ZoneMinder.

They can be bought on eBay for around £50 and for that money they are a great buy. (Beware of fakes, see here)

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.

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:

+++

# ==========================================================================
#
# ZoneMinder Foscam FI8908W IP Control Protocol Module, $Date: 2009-11-25 09:20:00 +0000 (Wed, 04 Nov 2009) $, $Revision: 0001 $
# Copyright (C) 2001-2008 Philip Coombes
# Modified for use with Foscam FI8908W IP Camera by Dave Harris
#
# 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 should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the Foscam FI8908W IP camera control
# 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;

# ==========================================================================
#
# Foscam FI8908W IP Control Protocol
#
# ==========================================================================

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 );
}

#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 );
}

#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 );
}

#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 );
}

#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 );
}

#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 );
}

#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 );
}

#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 );
}

#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 );
}

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

#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;

__END__

+++

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.

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

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.

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.

I’d also like to thank PacoLM who wrote a nice function to switch between camera modes.

# Choose video preset
# preset 1 -> 50 Hz mode (0)
# preset 2 -> 60 Hz mode (1)
# preset 3 -> outdoors mode (2)
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, ‘preset’ );
my $preset = ( $preset – 1 );
Debug( “Goto Preset $preset” );
my $cmd = “camera_control.cgi?param=3&value=$preset&user=admin&pwd=”;
$self->sendCmd( $cmd );
}

The original ZoneMinder thread can be found here.

Update…

I edited the perl file so that the button presses in ZoneMinder only move the camera slightly, and not continuously by adding in a stop command after sending each move command:

#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 );
my $cmd = “decoder_control.cgi?command=1&user=admin&pwd=”;
$self->sendCmd( $cmd );
}

I also created a copy of the file, but inverted all the commands, as cameras thats are mounted upside down were moving the wrong way. This way I can select the invert control file if it’s mounted this way round.

Update: Thanks to Dan (See comments below) who came up with a much neater and more functional solution. This now includes support for Iris, White Balance and Presets, cheers Dan!

# ==========================================================================
#
# ZoneMinder Foscam FI8908W IP Control Protocol Module, $Date: 2009-11-25 09:20:00 +0000 (Wed, 04 Nov 2009) $, $Revision: 0001 $
# Copyright (C) 2001-2008 Philip Coombes
# Modified for use with Foscam FI8908W IP Camera by Dave Harris
# Updates for Iris, Contrast, Presets and code rewrite
# Copyright (C) 2011 Daniel Rich
#
# 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 should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the Foscam FI8908W IP camera control
# 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;

# Change these for your camera username/password
our $FCUser = “admin”;
our $FCPass = “password”;

our $FCMoveSleep = 0.50;    # Time to move before stopping
# Don’t chnage any values below here
our %FCParams = ();
our $FCDirection = undef;    # Direction we are currently moving
our %FCMove = ( “Up”         => [ 0, 1 ],
        “Down”       => [ 2, 3 ],
        “Right”      => [ 4, 5 ],
        “Left”       => [ 6, 7 ],
        “Up Right”   => [ 90, 1 ],
        “Up Left”    => [ 91, 1 ],
        “Down Right” => [ 92, 1 ],
        “Down Left”  => [ 93, 1 ],
        “Vertical Patrol” => [ 26, 27 ],
        “Horizon Patrol”  => [ 28, 29 ],
          );
our %FCControl = ( “Resolution”  => [ 0, { "320x240" => 8,
                           "640x480" => 32 } ],
           “Brightness”  => [ 1, undef ],
           “Contrast”    => [ 2, undef ],
           “Mode”        => [ 3, { "50Hz" => 0,
                              "60Hz" => 1,
                           "Outdoor" => 2 } ],
           “Flip/Mirror” => [ 5, { "Default" => 0,
                           "Flip"    => 1,
                           "Mirror"  => 2,
                           "Both"    => 3 } ],
         );

# ==========================================================================
#
# Foscam FI8908W IP Control Protocol
#
# ==========================================================================

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’;
$self->getFCParams();
}

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

sub printMsg
{
    my($self,$msg) = @_;

    if ( zmDbgLevel() > 0 )
    {
        my $self = shift;
        my $msg = shift;
        my $prefix = shift || “”;
        $prefix = $prefix.”: ” if ( $prefix );

        my $line_length = 16;
        my $msg_len = int(@$msg);

        my $msg_str = $prefix;
        for ( my $i = 0; $i < $msg_len; $i++ )
        {
            if ( ($i > 0) && ($i%$line_length == 0) && ($i != ($msg_len-1)) )
            {
                $msg_str .= sprintf( “\n%*s”, length($prefix), “” );
            }
            $msg_str .= sprintf( “%02x “, $msg->[$i] );
        }
        $msg_str .= “[".$msg_len."]“;
        Debug( $msg_str );
    }
}

sub getFCParams
{
  my $self = shift;

  my $req = HTTP::Request->new( GET=>”http://”.$self->{Monitor}->{ControlAddress}.”/get_camera_params.cgi?user=$FCUser&pwd=$FCPass” );
  my $res = $self->{ua}->request($req);

  if ( $res->is_success ) {
    # Parse results setting values in %FCParams
    my $content = $res->decoded_content;
    while ($content =~ s/var\s+([^=]+)=([^;]+);//ms) {
      $FCParams{$1} = $2;
    }
  } else {
    Error( “Error check failed:’”.$res->status_line().”‘” );
  }
}

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=$FCUser&pwd=$FCPass”;
$self->sendCmd( $cmd );
}

# Camera control – giving a control options and possible arg, control the cam
sub controlCam
{
  my ($self, $params, $ctrl, $arg) = @_;

  unless (defined $FCControl{$ctrl}) {
    printMsg( “Control $ctrl: control unknown” );
    return;
  }
  my $param = $FCControl{$ctrl}[0];
  my $val = $arg;
  if ($FCControl{$ctrl}[1] eq “HASH”) {
    unless (defined $FCControl{$ctrl}{$arg}) {
      printMsg( “Control $ctrl-$arg: control unknown” );
      return;
    }
    $val = $FCControl{$ctrl}[1]{$arg};
  }
  Debug( “Control $ctrl $arg” );
  my $cmd = “camera_control.cgi?param=$param&value=$val&user=$FCUser&pwd=$FCPass”;
  $self->sendCmd( $cmd );
}

# Camera movement – given a direction, move the camera that way
sub moveCam
{
  my($self,$params, $dir) = @_;

  unless (defined $FCMove{$dir}) {
    printMsg( “Move $dir: direction unknown” );
    return;
  }
  my $autostop = $self->getParam( $params, ‘autostop’, 0 );
  my $orientation = $self->getParam( $params, ‘orientation’, 0 );
  Debug( “Move $dir ($autostop, $orientation)” );
  $self->moveStop if ($FCDirection);
  $FCDirection = $dir;
  my $val=$FCMove{$FCDirection}[0];
  my $cmd = “decoder_control.cgi?command=$val&user=$FCUser&pwd=$FCPass”;
  $self->sendCmd( $cmd );
  if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
  {
    Debug( “Move autostopping in $autostop s.” );
    usleep( $self->{Monitor}->{AutoStopTimeout} );
    $self->moveStop;
  }
}

#Up Arrow
sub Up
{
  my($self,$params) = @_;
  $self->moveConUp($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConUp
{
  my($self,$params) = @_;
  $self->moveCam($params,’Up’);
}

#Down Arrow
sub Down
{
  my($self,$params) = @_;
  $self->moveConDown($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConDown
{
  my($self,$params) = @_;
  $self->moveCam($params,’Down’);
}

#Left Arrow
sub Left
{
  my($self,$params) = @_;
  $self->moveConLeft($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConLeft
{
  my($self,$params) = @_;
  $self->moveCam($params,’Left’);
}

#Right Arrow
sub Right
{
  my($self,$params) = @_;
  $self->moveConRight($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConRight
{
  my($self,$params) = @_;
  $self->moveCam($params,’Right’);
}

#Diagonally Up Right Arrow
sub UpRight
{
  my($self,$params) = @_;
  $self->moveConUpRight($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConUpRight
{
  my($self,$params) = @_;
  $self->moveCam($params,’Up Right’);
}

#Diagonally Down Right Arrow
sub DownRight
{
  my($self,$params) = @_;
  $self->moveConDownRight($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConDownRight
{
  my($self,$params) = @_;
  $self->moveCam($params,’Down Right’);
}

#Diagonally Up Left Arrow
sub UpLeft
{
  my($self,$params) = @_;
  $self->moveConUpLeft($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConUpLeft
{
  my($self,$params) = @_;
  $self->moveCam($params,’Up Left’);
}

#Diagonally Down Left Arrow
sub DownLeft
{
  my($self,$params) = @_;
  $self->moveConDownLeft($params);
  usleep( $FCMoveSleep );
  $self->moveStop;
}
sub moveConDownLeft
{
  my($self,$params) = @_;
  $self->moveCam($params,’Down Left’);
}

#Stop
sub moveStop
{
  my($self,$params) = @_;
  Debug( “Move Stop” );
  my $val = 1;
  if ($FCDirection) {
    $val=$FCMove{$FCDirection}[1];
  }
  my $cmd = “decoder_control.cgi?command=$val&user=$FCUser&pwd=$FCPass”;
  $self->sendCmd( $cmd );
  $FCDirection = undef;
}

#Move Camera to Home Position
sub presetHome
{
  my($self,$params) = @_;
  Debug( “Home Preset” );
  my $cmd = “decoder_control.cgi?command=25&user=$FCUser&pwd=$FCPass”;
  $self->sendCmd( $cmd );
}

# Brightness/Contrast
sub irisAbsOpen
{
    my ($self,$params,$val) = @_;
    $self->getFCParams() unless($FCParams{‘brightness’});
    my $step = $self->getParam( $params, ‘step’ );
    $FCParams{‘brightness’} += $step;
    $FCParams{‘brightness’} = 255 if ($FCParams{‘brightness’} > 255);
    Debug( “Iris $FCParams{‘brightness’}” );
    $self->controlCam($params,”Brightness”,$FCParams{‘brightness’});
}
sub irisAbsClose
{
    my ($self,$params,$val) = @_;
    $self->getFCParams() unless($FCParams{‘brightness’});
    my $step = $self->getParam( $params, ‘step’ );
    $FCParams{‘brightness’} -= $step;
    $FCParams{‘brightness’} = 0 if ($FCParams{‘brightness’} < 0);
    Debug( “Iris $FCParams{‘brightness’}” );
    $self->controlCam($params,”Brightness”,$FCParams{‘brightness’});
}

sub whiteAbsIn
{
    my ($self,$params) = @_;
    $self->getFCParams() unless($FCParams{‘contrast’});
    my $step = $self->getParam( $params, ‘step’ );
    $FCParams{‘contrast’} += $step;
    $FCParams{‘contrast’} = 6 if ($FCParams{‘contrast’} > 6);
    Debug( “White $FCParams{‘contrast’}” );
    $self->controlCam($params,”Contrast”,$FCParams{‘contrast’});
}
sub whiteAbsOut
{
    my ($self,$params) = @_;
    $self->getFCParams() unless($FCParams{‘contrast’});
    my $step = $self->getParam( $params, ‘step’ );
    $FCParams{‘contrast’} -= $step;
    $FCParams{‘contrast’} = 0 if ($FCParams{‘contrast’} < 0);
    Debug( “White $FCParams{‘contrast’}” );
    $self->controlCam($params,”Contrast”,$FCParams{‘contrast’});
}

# Presets
sub presetSet
{
  my($self,$params) = @_;
  my $preset = $self->getParam( $params, ‘preset’, 1 );
  Debug( “Set Preset $preset” );
  my $val = 30 + ($preset * 2);    # set preset 0 is 30
  my $cmd = “decoder_control.cgi?command=$val&user=$FCUser&pwd=$FCPass”;
  $self->sendCmd( $cmd );
}
sub presetGoto
{
  my($self,$params) = @_;
  my $preset = $self->getParam( $params, ‘preset’, 1 );
  Debug( “Goto Preset $preset” );
  my $val = 31 + ($preset * 2);    # go preset 0 is 31
  my $cmd = “decoder_control.cgi?command=$val&user=$FCUser&pwd=$FCPass”;
  $self->sendCmd( $cmd );
}

1;

  • Juan Andres

    Hi..
    In first place I want to thanks for all your work specialy in the zoneminder group..
    Now I want to beg you for help.. I’m making my university thesis and I have to make FOSCAM FI8908W work in zoneminder in order to make a CCTV ip for a building but for one reason I can’t make it.. I all ready install zoneminder; I add a new monitor with all the parameters that you have in your post.. but the ip of the camera still in red collor and when I open the monior It shows a black screen.
    Please I need help because I want to be an Engineer and this is the first step in order to make an enormous cctv ip.
    Greattings

  • http://dave.harris.net/ Dave

    Hi there, glad the post was useful to you. Perhaps check that the camera is set to a static IP, and that you can access the camera from a web browser on your zoneminder server, to rule out any firewall issues. Also check that the user name and passwrd set on the camera is the same as in ZM, i used admin with no password to keep things simple. #
    Assuming that is all ok. Its worth having a look at the log files to see if there is any information in there. On my first ZM server i had a shared memory issue, take a look 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

    Let me know how you get on and if there is anything in the logs that might point to where the problem is. Cheers & good luck! Dave.

  • Juan

    Thanks for your help :)
    I found the problem it was that in the camera build in server the resolution wan preset in 640×480 and in zoneminder it was in 320×240 thats why it did’nt work now i’m tryng PT work…
    I’ll working all the weekend in this but it look cool.
    Thanks for everythink
    Greattings.

    Aguante linux y zoneminder :)

  • Juan

    Hi Dave..

    Me again…

    I have a problem with the pt in zoneminder with the foscam :( , but I’m working in that..
    I’m working over CentOS 5.4 and there seems to be a problem with perl and zoneminder..
    Well my question is in witch linux distro did you work I need the version please??

    thanks for all your help :)

    Greattings from Ecuador

    Aguante linux y Zoneminder

  • http://dave.harris.net/ Dave

    I never managed to get it working in 640×480, although i’m moving it over to a new server later this week, so will try again then – this ones got a bit more power. I used Ubuntu, infact my most recent install is on Ubuntu Desktop 10.04 on a Hyper-V box, see here http://dave.harris.net/post/2010/05/26/Installing-Ubuntu-1004-with-ZoneMinder-124-on-Hyper-V.aspx

    Hope that helps. :)

  • qdftowner

    hi dave, you should try to append "&onestep=1" to your commands, it will move only step by step the camera, will be more accurate and no need to append anymore a stop command…

  • http://dave.harris.net/ Dave

    Good skills, I’ll try that tonight! Thank you qdftowner!

  • SiMH

    Hi Dave, nice tutorial but I am having problems with this script that you wrote for P/T.
    I think that maybe something broke during the copy/paste, I tried to locate it but no luck. Could you please attach it as a file for download?
    I am getting: http://pastebin.com/25HMytgN
    When I change my protocol to PanasonicIP it ‘works’ fine (the camera does not move but no error is displayed – only in zmcontrol.log I can see the connection failed)
    That is why I assume that the problem lies within the script.

    Cheers :)

  • http://dave.harris.net/ Dave

    hi, sorry for the delayed reply, ive been away for a bit, looks like perhaps you have the IP address incorrect in ZM? check that ti IP addres in the ‘control address’ field under ‘control’ is set to that same IP as your camera (omit the +++ at the start and end too). I need to rewrite my config with the code ‘qdftowner’ wrote above also.

  • SiMH

    Hi Dave, last time I was here my comment was invisible, so I didn’t expect you to reply at all :)
    Anyway, thanks. As a matter of fact I’ve dropped my previous setup when I discovered susestudio.com I am not an opensuse user but I think that Novell did great job with it, and I used it to create ZoneMinder appliance http://susegallery.com/a/atN5c5/zoneminder-appliance
    Now your script works great and I plan to include it in this appliance? Do you mind?

  • http://dave.harris.net/ Dave

    I had to change the blog so that comments needed to be approved – as i was getting stacks of spam, people trying to improve their google rankings i think!
    I’ll take a look at that link a bit later on (in a bit of a rush this morning), that’s fine by me though, glad i could help,good luck! Cheers, Dave :)

  • SiMH

    Hi Dave.
    I think I sorded out most of the things with my appliance, I managed to migrate from heavy apache2 to lightweight lighttpd and I *think* that everythink works just fine :)
    If you would have the chance to check it, comments would be much appriciated.

    cheers

  • http://dave.harris.net/ Dave

    Good work, i’ll try and have a look later this week :)

  • Gonzalo

    Dave,

    First of all, thank you very much for posting this. It saved me long hours of frustration and hair pulling. I’m almost done with Ubuntu 10.04 + Zoneminder 1.24.2 + Foscam FI8908W IP cameras. (Additional info that might be useful to set the context: HW on which ZM is running is a Quad-Core with 2 Gb of memory. The cameras’ firmware was upgraded to the latest version from July 2010). Everything on Zoneminder runs flawlessly when the cameras’ resolution is set at 320×240. However, when I set them at 640×480 all sorts of weird things start to happen. For example, I can set only one camera at 640×480. ZM won’t allow me to set all of them to this higher resolution, that is, the 2nd, 3rd, 4th, etc. will be deactivated (marked in red). Another weirdness is that ZM doesn’t allow me to scale the feed that’s being displayed at 640×480. Scaling, on the other hand, works perfectly at 320×240.
    Not enough shared memory I thought. Everybody seems to hit it. So I followed to the letter the advice on the FAQ entry you referred Juan Andres to on your first reply. I tried many different settings of shared memory. Unfortunately none of them fixed the issues with the 640×480 resolution. What’s more, CPU usage remains very very low and memory consumption always remains at ~23%. It seems ZM is not a CPU or memory hog, not even with 6 cameras!

    To switch back & forth between the 320×240 and 640×480 resolutions I appended &resolution=8 or &resolution=32 respectively to the command that’s being sent to the camera. See http://www.gadgetvictims.com/2010/05/new-firmware-for-foscam-cameras.html

    What do you think? Do you know how to make ZM handle the 640×480 res. (on all its cameras, that is) as smooth as the 320×240 one?
    I installed the binary version of ZM from Ubuntu’s repositories. Do you think I should recomile ZM with the –enable–mmap=yes switch in order to make it 640×480-friendly? Assuming this stems from not enough shared memory…

    Thanks in advance!
    Gonzalo

  • http://dave.harris.net/ Dave

    Hi Gonzalo,

    The HW you listed should be more than capable, I now have 3 cameras (im yet to get them all of these plus the others permanently mounted), but these 3 are running 640*480 now.

    I increased the shared memory recently, by going ‘sudo gedit’ then opening ‘etc\sysctl.conf’ and then adding this line at the bottom:

    kernel.shmmax = 467772160

    Now all 3 happily run in 640 * 480, running MODECT, my CPU (Intel Core 2 Duo E84000 @ 3GHz – VM) is at about 78% constant and memory is only at about 276MB constant. Give it a go. Hope that helps.

    Cheers,

    Dave.

    PS, thx for the tip on switching resolution via the URL :)

  • Pete_c

    Hello Dave,

    Thank-you for posting your Foscam Control script! Saved much time. I’ve been using ZM now for quite a few years. Its currently running at the 23.3 version with an 8 chip 878a video card with 8 analogue feeds, an addition Panasonic IP camera (years now) and most recently added the Foscam IP camera. ZM Linux base is PC Linux. Not sure what is going on with my Foscam. If I leave it disconnected from ZM it continues to work fine. If I connect it to ZM I only get a few hours out of the Foscam and it locks up. I am using "/videostream.cgi?user=admin&pwd=&resolution=32&rate=13" and have the video set up for 640X480 (as the other 9 cameras). The firmware on the new camera is: 11.14.2.26 and Embeded Web UI Version is 2.4.8.14.
    I am wondering if I should downgrade the version of firmware?

    PeteC

  • http://dave.harris.net/ Dave

    Hi Pete,

    No worries, glad it was helpful to you. I’ve recently swapped back to 320*240 for a few reasons. It takes up way less space, i often view the feeds via a VPN and this was runnig very slow and also i just dont think my server or even home network was upto running multiple cameras at the higher resolution. In the lower resolution its a lot quicker and happier.

    The lockup issue sounds strange tho, ive never had the camera itself lockup, the web interface for ZM has stopped responding a few times but i just reset apache to fix that, altho ZM itself has never had any issues.

    Im using /videostream.cgi?user=admin&pwd= and I dont specify the frame rate or resolution, i just set this on the camera webgui, if you try your 9 cameras at 320*240 do you still get the lockups? My one camera runs over a homeplug (out of wireless range and cant run a cable to it) and that just on 320*240 is using about 2,911kbps so its pretty network intensive if you add it all up.

    I cant imaging downgrading firware would make much difference although stranger things have happened lol.

    Let me know how you get on.

    Cheers,

    Dave.

  • pete_c

    Hello Dave,

    Thank-you for your suggestions.

    I’m running the other 9 streams at 640 / 480 (8 analogue and 1 Panasonic IP). ZM isn’t locking up. Its been like this for years now. Its just a hobby but its set up at home just for the garage as a test. Base network is Gig plus two other 10/100 switches. I have a few toys on the network. This is only the second IP cam though on the network.

    I’ll try removing the framerate cgi setting and bring it to 320 by 240 to see what happens. If I disconnect ZM from ZM cam 10 / Foscam then it continues to work fine (but haven’t tried 24 hour streaming to my desktop).

    Cheers,

    Pete

  • pete_c

    I was going to give it a try to set all of the cams at 320X240; then noticed that I have one set at 720X480 (running well for over 6 months). Odd that ZM let me set this camera and not be able to set the Foscam to 320X240.

    I can stream reasonably with my HTC / 3G mobile connection.

    The Foscam is still running fine now over 12 hours without the ZM connection. I was going to try just bringing Firefox up with the Foscam interface to see how long that lasts. Next then will change cams to 320X240 and let it run a bit.

    I should update ZM – have another box sitting for update with another 878A/8 Chip card in it but haven’t had a chance.

    I appreciate your help Dave.

  • Ivan

    Hi Dave I have made some changes on your script and tested on my Foscam.
    I have removed the user and password from script. You can put the user and password on the Control Address
    USER:PASSWORD@IP:PORT.
    Worked fine here with my user and pass. Now no need to change the script to select user/pass.

    I adjusted the script to accept the AutoStopTimeout configuration. I’m using 0.5 with good results.

    I have already included the Patrol commands on the script, but I did not checked the ZM interface to see how I can add them. But it works when called from command line using zmcontrol.pl

    The file is available here :
    http://dicas.ivanfm.com/equipamentos/foscam-fi8908w/FoscamFI8908W.pm

  • pete_c

    I like your Hedgehog house with the Foscam in it!

    Locked up (bricked) Foscam last week. Its a new HW version and only the new FW would work with it. I was able to JTAG it, install the older binaries then update the FW with newest (provided by Foscam Tech).

    Also installed a 2.1mm wide angle lens on the camera. Difficult to install. Works except the IR LEDs reflect across top of lens making it almost useless to use with LEDs on.

  • http://dave.harris.net/ Dave

    Lol, cheers!

    Thanks for the info on the 2.1mm lens also, i was about to buy a couple, but i may not bother now if its going to reflect the IR light.

    Cheers,

    Dave.

  • Andrew

    Hello !

    I need some help keeping the horizontal and vertical pan running all of the time on the FOSCAM FI8908W. After 120 seconds it just stops. Does anyone have any ideas ?

  • http://dave.harris.net/ Dave

    Andrew, what are you running to initiate the pan, are you doing it via the web gui?

  • http://dave.harris.net/ Dave

    Andrew, i just ran fiddler and the cmmand for the horizontal pan is:
    http://x.x.x.x/decoder_control.cgi?command=28
    It seems though that it will only run for 2 minutes and i would guess this is a ‘feature’ of the camera’. You could just write a vbscript to run and call this every 120 seconds.

  • Jim

    Hi Dave, great work on the PT script, and other things too.

    I am unable to get the FI8908 to move from the ‘control’ section buttons..
    If I use the cgi script directly on the web browser, it works fine.
    Can you guess at what I am doing wrong?..followed your instructions and double checked my work.
    Thank you!

  • Jim

    To add to my last post, With a sniffer, the packet going out (on my button press) appears to be incomplete..
    POST /PANTILTCONTROL.CGI HTTP/1.1\r\n

    and the response is file not found
    HTTP HTTP/1.1 404 Not Found (text/html)

    I am using Ubuntu 10.10, ZM 1.24.2 and tried 3 browsers all same results.
    thanks!
    Jim

  • Nate

    Do you know of anyway to enter in a delay between to two commands to alter the rate that the camera moves?

    i.e.
    #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 );
    ((((((Time delay entered here)))))
    my $cmd = "decoder_control.cgi?command=1&user=admin&pwd=";
    $self->sendCmd( $cmd );
    }

  • ZoneMan

    Hi,

    I tried getting this setup on 8.04. The control files are located as "/usr/bin/zmcontrol-panasonic.pl" etc. Not in any perl folder. Initially I get an error saying it cannot locate Zoneminder/Control.pm.

    (My camera responds to all url commands I have seen for foscams.)

    Has anyone come across anything like this?

  • ZoneMan

    Hi,

    trying to get this setup on 8.04. The control files are listed as "/usr/bin/zmcontrol-panasonic.pl" etc

    ever come across this?

    Thanks

  • Sohail

    Hey Dave,

    Thanks to your tutorial I got my foscam setup and working perfectly!

    Now for more cameras! Just bought an rs485 pelco-D compatible camera off ebay it has Pan/Tilt and 27x optical zoom!

    Thanks!!!

  • Ryan

    Its been a long time since I did anything in Perl, but I think you can use alert() to create a timeout event.

    Google "perl timeout alert" and you should find some examples.

  • http://dave.harris.net/ Dave

    No worries Sohail, glad it worked for you. 27 x zoom, rar, how much did that set you back? Cheers, Dave.

  • http://www.trumpoceanclub.com/html/index.php panama city condominium rentals

    This is the perfect blog for anyone who wants to know about this topic. The article is nice and its pleasant to read. I have known very important things over here. I admire the valuable advice you make available in your expertly written content. I want to thank you for this informative read; I really appreciate sharing this great.

  • Paolo

    Hi Dave,
    Thanks for this usefull tutorial but my camera won’t move.
    When I click on the arrow I get an error message.

    Something like:
    Control response was status = undefined
    message = /usr/bin/zmcontrol.pl –autostop –command=moveConLeft –id=6=>

    If I try to execute this command from shell I get:
    lordice@ubuntu:~$ sudo /usr/bin/zmcontrol.pl start –autostop –id=6 –command=moveConLeft
    Can’t connect: No such file or directory at /usr/share/perl5/ZoneMinder/Debug.pm line 349
    ZoneMinder::Debug::Fatal(‘Can\’t connect: No such file or directory’) called at /usr/bin/zmcontrol.pl line 154

    Any idea? i’m reading a lot of topic on the web but without success :-(

  • Paolo

    in the file zmcontrol.log:

    02/27/2011 06:21:28.290409 zmcontrol[2012].INF [Starting control server 6/Foscam]
    02/27/2011 06:21:28.295708 zmcontrol[2013].INF [Control server 6/Foscam starting at 11/02/27 06:21:28]
    02/27/2011 06:21:38.302858 zmcontrol[2012].FAT [Can't connect: No such file or directory]

    • Steven

      me too!

  • Paolo

    :-) hheheheh….

    on my .pm file i wrote:
    package ZoneMinder::Control::FoscamFI8908W;

    instead of:
    package ZoneMinder::Control::FoscamFI8918W;

    Thank you :-)

  • Dan

    Dave,

    Thanks for a great module, you made getting my new camera up and running a whole lot easier!

    I have an updated version of your perl module that adds support for iris, white balance, presets, and simplifies some of the code a bit. Are you interested in an updated copy or should I just post it to the zoneminder wiki?

  • http://dave.harris.net/ Dave

    sorry for the delayed reply, if you could send me a copy that would be fantastic, i’d be very interested to see it. Regards, Dave.

  • http://www.webhostings.in/ Website Hosting India

    Keep working ,great job!

  • John

    Trying this out with ZM 1.24.4.

    Noted for F8918W cameras the left and right controls are reversed.
    Also the PTZ seems to be not working after upgrading to 1.24.4 . Anyone having similar issues?

  • John

    Ok n/m found out I had to install json.
    Now I got a new problem. It won’t stop moving when I click on any direction until it reaches the end of the camera’s movements limit in that direction.

  • http://dave.harris.net/ Dave

    Hi John, can’t say I’ve come across that issue im afraid, is this a problem specifically using Dan’s new code or in general? Cheers, Dave.

  • http://twitter.com/the0loko Julio González

    I can’t make this work, what i have to type in the control tab (in control address)?? Also I have tried making my own script and it does nothing, always shows this error:

    Control response was status = undefined
    message = /usr/bin/zmcontrol.pl –autostop –command=moveConUpRight –id=1=>

    I Don’t know how to solve this. Maybe i have to make it executable or something? That’s annoying for me! Thanks

  • Daksh

    I’m facing the same problem as Julio. Using zoneminder 1.25 on ubuntu 12.04

    • dphuk

      It’s been a while since I played with this, if I get a chance I’ll get the latest version on my box and give it another go. Is the Foscam file name correct and in the correct location?

      • boss

        Also facing this same problem with zm 1.25 on ubuntu 11.10 x64.  FoscamFI8918W.pm file name and location are correct.

        • boss

          File location is /opt/zm/share/perl/5.12.4/ZoneMinder/Control/FoscamFI8918W.pm.  But in the zm log file, I get “Can’t connect: No such file or directory”.  Not sure what file it’s referring to, as it’s in the same place as AxisV2.pm and all of the other PTZ .pm files.

          • John F

            I have same problem:  ZoneMinder 1.25;  the error is coming from the “load ZoneMinder::Control::$protocol” command in zmcontrol.pl, from the section of code that forks and runs this in the child process, it seems to hang here, and the parent process times-out and exits.  I’m not a perl hacker, but I’m looking at it now, something is not right, I am 100% certain my filenames and file/directory permissions are correct, so I can’t fathom why the load command can’t find the foscam .pm file…. I’ll report back when/if I find the problem.

          • http://www.facebook.com/profile.php?id=632599250 Kevin Johnson

            Any luck with this? I also have the control problem like everyone else.

          • Gaz

            The problem is due to the printMsg sub routine. Replace the more latest printMsg with the printMsg sub in the initial post and works fine

          • Chris

            Were you able to find a resolution to this problem? I’m using a Foscam FI8910W and encountering the same issue. 1.25.0

          • John Falkenthal

            Yes, I made some code changes which fixed everything, I don’t recall what they were now, but they were pretty simple. If I get time in the next day or so, I’ll go back and remember what I did, and post it.

  • Norberto Bensa

    Hello!

    Thanks for this information. I got my unbranded clone working! 

    But Dan’s script seems to have a bug in printMsg. zmcontrol takes all the available memory, machine starts to swap like crazy and takes ages to respond.

    Replacing printMsg with the one in the first script, makes it work. 

    I’m not a Perl expert. Maybe someone wants to take a look.

    Regards,
    Norberto