ABS MegaCam 4220 capture and TCP trigger working

Post here to indicate any hardware you have used and which is known to work with ZoneMinder. Not for questions.
skyking
Posts: 84
Joined: Sat Nov 03, 2007 4:07 am

ABS MegaCam 4220 capture and TCP trigger working

Post by skyking »

I have this working in 1.24.1
Debian 5.0 unstable
Source>General


set alarm and maximum FPS to match camera settings

Source>Source

Remote Protocol = HTTP
Remote Method = Simple
Remote Host Path = /mjpg/video.cgi?resolution=640x480

You can enable and use the camera's onboard motion detection and utilize TCP notification as with the axis 207 as shown here:
http://www.zoneminder.com/wiki/index.ph ... nDetection

The camera settings are straightforward. Set up the object detection, event server, and be sure to enable and configure the event schedule to allow notification.


I have looked into getting the PT control working.
This post has some promise, I need a little assistance with writing a new protocol and getting it to load properly.
http://www.zoneminder.com/forums/viewto ... hlight=abs

If anyone has some insight on writing a new ABS.pm and getting it to load up, I'd be grateful. I copied and edited AxisV2.pm and saved it as ABS.pm, but I don't know how to get it loaded properly. I created a new control and specified ABS as the protocol but I get these errors on the control interface:

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 124

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 125

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 126

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 127

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 128

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 129

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 130

Notice: Undefined index: MoveRoot in /usr/share/zoneminder/skins/classic/includes/control_functions.php on line 131




Those lines are:

$cmds['MoveUp'] = $cmds['MoveRoot']."Up";
$cmds['MoveDown'] = $cmds['MoveRoot']."Down";
$cmds['MoveLeft'] = $cmds['MoveRoot']."Left";
$cmds['MoveRight'] = $cmds['MoveRoot']."Right";
$cmds['MoveUpLeft'] = $cmds['MoveRoot']."UpLeft";
$cmds['MoveUpRight'] = $cmds['MoveRoot']."UpRight";
$cmds['MoveDownLeft'] = $cmds['MoveRoot']."DownLeft";
$cmds['MoveDownRight'] = $cmds['MoveRoot']."DownRight";
}

I figure the .pm protocol file is not loading at all.
User avatar
kingofkya
Posts: 1110
Joined: Mon Mar 26, 2007 6:07 am
Location: Las Vegas, Nevada

Post by kingofkya »

post you pm file so we can find the problem

Code: Select all

remember to put it in a code tag so forum dosent mess it up
skyking
Posts: 84
Joined: Sat Nov 03, 2007 4:07 am

Post by skyking »

The camera will respond to commands formatted like this:

Code: Select all

 wget --http-user=admin  --http-password= "http://192.168.0.101/ptz.cgi?move=downleft&speed=10"


I started with the AxisV2.pm file and trimmed out all the features this camera does not support.

Code: Select all

package ZoneMinder::Control::ABS;

use 5.006;
use strict;
use warnings;

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

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

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

# ==========================================================================
#
# Axis V2 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 );
    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" );
}

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

    #print( "http://$address/$cmd\n" );
    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 moveConUp
{
    my $self = shift;
    Debug( "Move Up" );
    my $cmd = "/ptz.cgi?move=up&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConDown
{
    my $self = shift;
    Debug( "Move Down" );
    my $cmd = "/ptz.cgi?move=down&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConLeft
{
    my $self = shift;
    Debug( "Move Left" );
    my $cmd = "/axis-cgi/com/ptz.cgi?move=left";
    $self->sendCmd( $cmd );
}

sub moveConRight
{
    my $self = shift;
    Debug( "Move Right" );
    my $cmd = "/ptz.cgi?move=right&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConUpRight
{
    my $self = shift;
    Debug( "Move Up/Right" );
    my $cmd = "/ptz.cgi?move=upright&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConUpLeft
{
    my $self = shift;
    Debug( "Move Up/Left" );
    my $cmd = "/ptz.cgi?move=upleft&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConDownRight
{
    my $self = shift;
    Debug( "Move Down/Right" );
    my $cmd = "/ptz.cgi?move=downright&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConDownLeft
{
    my $self = shift;
    Debug( "Move Down/Left" );
    my $cmd = "/ptz.cgi?move=downleft&speed=2";
    $self->sendCmd( $cmd );
}


1;
__END__

I tried using admin:@192.168.0.101 for the Control Address.
I'd get the aforementioned PHP errors when I opened the control tab for the camera. If I click on the right control arrow, this is what I get in the log.

Code: Select all

 FAT [Can't access Right member of object of class ZoneMinder::Control::ABS]
User avatar
kingofkya
Posts: 1110
Joined: Mon Mar 26, 2007 6:07 am
Location: Las Vegas, Nevada

Post by kingofkya »

nothing jumps out as a problem did you remember to set it as an executable file

chmod +x file
skyking
Posts: 84
Joined: Sat Nov 03, 2007 4:07 am

Post by skyking »

I tried that, but noticed that none of the other .pm files were chmodded +x
I don't have the experience to go in and build this myself, I will declare a partial victory with the rest of the camera.
User avatar
kp4djt
Posts: 224
Joined: Mon Jun 18, 2007 1:53 am
Location: Tampa, FL

Post by kp4djt »

Did you get this one working? I have one, I was going to see what I could do, but this is not my forte...
Chuck Hast -- KP4DJT --
Web site www.wchast.com
ZM demo www.wchast.com/zm
greckpk
Posts: 10
Joined: Fri Jun 25, 2010 12:00 am

Post by greckpk »

skyking wrote:The camera will respond to commands formatted like this:

Code: Select all

 wget --http-user=admin  --http-password= "http://192.168.0.101/ptz.cgi?move=downleft&speed=10"


I started with the AxisV2.pm file and trimmed out all the features this camera does not support.

Code: Select all

package ZoneMinder::Control::ABS;

use 5.006;
use strict;
use warnings;

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

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

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

# ==========================================================================
#
# Axis V2 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 );
    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" );
}

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

    #print( "http://$address/$cmd\n" );
    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 moveConUp
{
    my $self = shift;
    Debug( "Move Up" );
    my $cmd = "/ptz.cgi?move=up&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConDown
{
    my $self = shift;
    Debug( "Move Down" );
    my $cmd = "/ptz.cgi?move=down&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConLeft
{
    my $self = shift;
    Debug( "Move Left" );
    my $cmd = "/axis-cgi/com/ptz.cgi?move=left";
    $self->sendCmd( $cmd );
}

sub moveConRight
{
    my $self = shift;
    Debug( "Move Right" );
    my $cmd = "/ptz.cgi?move=right&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConUpRight
{
    my $self = shift;
    Debug( "Move Up/Right" );
    my $cmd = "/ptz.cgi?move=upright&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConUpLeft
{
    my $self = shift;
    Debug( "Move Up/Left" );
    my $cmd = "/ptz.cgi?move=upleft&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConDownRight
{
    my $self = shift;
    Debug( "Move Down/Right" );
    my $cmd = "/ptz.cgi?move=downright&speed=2";
    $self->sendCmd( $cmd );
}

sub moveConDownLeft
{
    my $self = shift;
    Debug( "Move Down/Left" );
    my $cmd = "/ptz.cgi?move=downleft&speed=2";
    $self->sendCmd( $cmd );
}


1;
__END__

I tried using admin:@192.168.0.101 for the Control Address.
I'd get the aforementioned PHP errors when I opened the control tab for the camera. If I click on the right control arrow, this is what I get in the log.

Code: Select all

 FAT [Can't access Right member of object of class ZoneMinder::Control::ABS]
Skyking,
This code works fine for me, the only problem was this line:

Code: Select all

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

Code: Select all

my $req = HTTP::Request->new( GET=>" http://".$self->{Monitor}->{ControlAddress}."$cmd" );
And make sure you name the file ABS.pm



edit:
need to change this (funny how it still moved the camera left :)):

Code: Select all

sub moveConLeft 
{ 
    my $self = shift; 
    Debug( "Move Left" ); 
    my $cmd = "/axis-cgi/com/ptz.cgi?move=left"; 
    $self->sendCmd( $cmd ); 
}
To this:

Code: Select all

sub moveConLeft 
{ 
    my $self = shift; 
    Debug( "Move Left" ); 
    my $cmd = "/ptz.cgi?move=left&speed=2"; 
    $self->sendCmd( $cmd ); 
}
Last edited by greckpk on Fri Jun 25, 2010 2:18 am, edited 1 time in total.
User avatar
kp4djt
Posts: 224
Joined: Mon Jun 18, 2007 1:53 am
Location: Tampa, FL

Post by kp4djt »

What directory do I put this in, I have one of these cameras, but when I did a list of directories, I see a large number of places on the directory tree where this thing could
go.
I believe this is the place but I am not sure:
./usr/share/perl5/site_perl/5.10.0/ZoneMinder/Control/abs.pm

But when I try to run it I get this in zmcontrol:
06/24/10 20:56:18.920280 zmcontrol[12216].INF [Control server 6/ starting at 10/06/24 20:56:18]
06/24/10 20:56:28.930486 zmcontrol[12213].FAT [Can't connect: No such file or directory]

The permissions are all the same as the other control files in the /Control directory, also
the owner and group (root root) for all files.
Chuck Hast -- KP4DJT --
Web site www.wchast.com
ZM demo www.wchast.com/zm
greckpk
Posts: 10
Joined: Fri Jun 25, 2010 12:00 am

Post by greckpk »

Hi,

This location is correct location for me:
/usr/local/share/perl/5.10.1/ZoneMinder/Control/ABS.pm

I think that your location should be correct for your version of OS. I'am running Ubuntu 10.4


make sure when you set the camera up in "Control Capability" under "Move" tab check "Can Move", "Can Move Diagonally", and most important "Can Move Continuous"
Last edited by greckpk on Fri Jun 25, 2010 1:17 am, edited 1 time in total.
User avatar
kp4djt
Posts: 224
Joined: Mon Jun 18, 2007 1:53 am
Location: Tampa, FL

Post by kp4djt »

By way I corrected the file name from abs.pm to ABS.pm. But it appears that the system
is not seeing the file, I think I may have it in the wrong directory but not sure which one
to put it in.
Chuck Hast -- KP4DJT --
Web site www.wchast.com
ZM demo www.wchast.com/zm
greckpk
Posts: 10
Joined: Fri Jun 25, 2010 12:00 am

Post by greckpk »

It might be easier for you to copy the AxisV2 file delete the contents and paste the code in it and the rename the file ABS.pm? I know a silly thought.
User avatar
kp4djt
Posts: 224
Joined: Mon Jun 18, 2007 1:53 am
Location: Tampa, FL

Post by kp4djt »

I think I have the wrong directory, as I have tried to see if I can get it to see the ABS.pm
file and it does not appear to do so, but it does see the Axis file, I went into that same
directory and renamed the Axis file, but is it getting from one of several other directories
I think.

Which directory (full tree) is the real one in. I find the Axis file in about 4 directories on
my machine, and I am not sure which is the real thing.
Chuck Hast -- KP4DJT --
Web site www.wchast.com
ZM demo www.wchast.com/zm
User avatar
kp4djt
Posts: 224
Joined: Mon Jun 18, 2007 1:53 am
Location: Tampa, FL

Post by kp4djt »

Yes you are using the same one as me. I will look at it tomorrow, have to get to bed as I
have to get up at 04h30 in the morning to go do a network clean up in a store.
Chuck Hast -- KP4DJT --
Web site www.wchast.com
ZM demo www.wchast.com/zm
greckpk
Posts: 10
Joined: Fri Jun 25, 2010 12:00 am

Post by greckpk »

I don't know if this will help at all, this is how it is setup for me.


This is where it is located (for me on Ubuntu 10.04)
Image

Image

Image

Image

Image

Don't forget the "can pan" and "can tilt"
User avatar
kp4djt
Posts: 224
Joined: Mon Jun 18, 2007 1:53 am
Location: Tampa, FL

Post by kp4djt »

That did it. I was missing some stuff in the control capabilities. Thank you very much. It is working nice now.
Chuck Hast -- KP4DJT --
Web site www.wchast.com
ZM demo www.wchast.com/zm
Post Reply