http://www.zoneminder.com/forums/viewto ... ht=vivotek
Followed the instructions on this forum with no luck. Does anybody have a script for the SD7151 PTZ Dome Camera?
Thanks
Vivotek SD7151 PTZ Control Script
Vivotek SD7151 scrito
well here's the script developed by Normando and base from:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
for install in ubuntu 10.04 rename it as VivotekSd7151.pm and put in in:
/usr/share/perl5/ZoneMinder/Control
as the complete path looks like : /usr/share/perl5/ZoneMinder/Control/VivotekSd7151.pm
for different distro copy it in your "control" perl modules.
# ==========================================================================
#
# This module contains the implementation of the Vivotek SD7151 protocol
# It is easy to adapt to other Vivotek cameras. I have found a lot of commands with Wireshark
# This protocol get some info from the camera through receiveCmd function.
# Implement a pseudo diagonal movement
# Where go "presetClear" function from php code?
# Any improve is welcome, and please share it
# Normando Hall nhall[AT]unixlan[DOT]com[DOT]ar
#
package ZoneMinder::Control::VivotekPT7135;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
our $VERSION = $ZoneMinder::Base::VERSION;
# ==========================================================================
#
# Vivotek SD7151 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 receiveCmd
{
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg( $cmd, "Rx" );
#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."$cmd" );
my $res = $self->{ua}->request($req);
my $content = $res->content();
if ( $res->is_success )
{
$result = $content;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}
return( $result );
}
sub reset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "/cgi-bin/admin/setparam.cgi?System_Reset=3";
$self->sendCmd( $cmd );
}
sub moveMap
{
my $self = shift;
my $params = shift;
my $xcoord = $self->getParam( $params, 'xcoord' );
my $ycoord = $self->getParam( $params, 'ycoord' );
my $imagewidth = $self->{Monitor}->{Width};
my $imageheight = $self->{Monitor}->{Height};
Debug( "Move Map to $xcoord,$ycoord at $imagewidth/$imageheight" );
if ( $imagewidth == "640" )
{
$xcoord = $xcoord/2;
$ycoord = $ycoord/2;
}
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?cam1&x=$xcoord&y=$ycoord";
$self->sendCmd( $cmd );
}
sub moveRelUp
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDown
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Down - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Left - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Right - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Up/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
# test di zoom della camera
#sub zoomtele
#{
# my $self = shift;
# my $params = shift;
# my $panspeed = $self->getParam( $params, 'panspeed' );
# my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
# Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?zoom=tele&speedtele=$telespeed";
# $self->sendCmd( $cmd );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
# $self->sendCmd( $cmd );
#}
#fine del test
sub whiteAuto
{
my $self = shift;
Debug( "White Auto" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=0";
$self->sendCmd( $cmd );
}
sub whiteMan
{
my $self = shift;
Debug( "White Man" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=2";
$self->sendCmd( $cmd );
}
sub In
{
my $self = shift;
Debug( "White In" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=1";
$self->sendCmd( $cmd );
}
sub Out
{
my $self = shift;
Debug( "White Out" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=3";
$self->sendCmd( $cmd );
}
sub presetClear
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Clear Preset $preset" );
my $cmd = "/cgi-bin/admin/preset.cgi?delpos=$preset&Submit=Delete";
$self->sendCmd( $cmd );
}
sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisx";
my $rx = $self->receiveCmd( $cmd );
my ($axisx) = $rx =~ /([-0-9]+)/;
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisy";
my $rx = $self->receiveCmd( $cmd );
my ($axisy) = $rx =~ /([-0-9]+)/;
Debug( "Set Preset $preset at $axisx and $axisy" );
my $cmd = "/cgi-bin/admin/setparam.cgi?camctrl_presetname_$preset=$preset&camctrl_presetpan_$preset=$axisx&camctrl_presettilt_$
$self->sendCmd( $cmd );
}
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Goto Preset $preset" );
my $cmd = "/cgi-bin/recall.cgi?recall=$preset";
$self->sendCmd( $cmd );
}
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=home";
$self->sendCmd( $cmd );
}
1;
__END__
Under control tab of your monitor:
Controllable: check
Control Device: none
Control Address: the camera IP, or user:pass@camera_ip
Return Location: Home
and follow the same instruction gave from normando at:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
remenber to change the name from Vivotek PT7135 to: Vivotek SD7151
the script work pretty fine, and can controlo up, down, lef, right, return to home, no zoom, no focus, no mapped areas. we will get you up to date in case of new development.
many many thanks to normando for his script.
Remember also to donate to zoneminder.
ilios
http://www.zoneminder.com/forums/viewto ... ht=vivotek
for install in ubuntu 10.04 rename it as VivotekSd7151.pm and put in in:
/usr/share/perl5/ZoneMinder/Control
as the complete path looks like : /usr/share/perl5/ZoneMinder/Control/VivotekSd7151.pm
for different distro copy it in your "control" perl modules.
# ==========================================================================
#
# This module contains the implementation of the Vivotek SD7151 protocol
# It is easy to adapt to other Vivotek cameras. I have found a lot of commands with Wireshark
# This protocol get some info from the camera through receiveCmd function.
# Implement a pseudo diagonal movement
# Where go "presetClear" function from php code?
# Any improve is welcome, and please share it
# Normando Hall nhall[AT]unixlan[DOT]com[DOT]ar
#
package ZoneMinder::Control::VivotekPT7135;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
our $VERSION = $ZoneMinder::Base::VERSION;
# ==========================================================================
#
# Vivotek SD7151 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 receiveCmd
{
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg( $cmd, "Rx" );
#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."$cmd" );
my $res = $self->{ua}->request($req);
my $content = $res->content();
if ( $res->is_success )
{
$result = $content;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}
return( $result );
}
sub reset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "/cgi-bin/admin/setparam.cgi?System_Reset=3";
$self->sendCmd( $cmd );
}
sub moveMap
{
my $self = shift;
my $params = shift;
my $xcoord = $self->getParam( $params, 'xcoord' );
my $ycoord = $self->getParam( $params, 'ycoord' );
my $imagewidth = $self->{Monitor}->{Width};
my $imageheight = $self->{Monitor}->{Height};
Debug( "Move Map to $xcoord,$ycoord at $imagewidth/$imageheight" );
if ( $imagewidth == "640" )
{
$xcoord = $xcoord/2;
$ycoord = $ycoord/2;
}
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?cam1&x=$xcoord&y=$ycoord";
$self->sendCmd( $cmd );
}
sub moveRelUp
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDown
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Down - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Left - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Right - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Up/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
# test di zoom della camera
#sub zoomtele
#{
# my $self = shift;
# my $params = shift;
# my $panspeed = $self->getParam( $params, 'panspeed' );
# my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
# Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?zoom=tele&speedtele=$telespeed";
# $self->sendCmd( $cmd );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
# $self->sendCmd( $cmd );
#}
#fine del test
sub whiteAuto
{
my $self = shift;
Debug( "White Auto" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=0";
$self->sendCmd( $cmd );
}
sub whiteMan
{
my $self = shift;
Debug( "White Man" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=2";
$self->sendCmd( $cmd );
}
sub In
{
my $self = shift;
Debug( "White In" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=1";
$self->sendCmd( $cmd );
}
sub Out
{
my $self = shift;
Debug( "White Out" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=3";
$self->sendCmd( $cmd );
}
sub presetClear
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Clear Preset $preset" );
my $cmd = "/cgi-bin/admin/preset.cgi?delpos=$preset&Submit=Delete";
$self->sendCmd( $cmd );
}
sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisx";
my $rx = $self->receiveCmd( $cmd );
my ($axisx) = $rx =~ /([-0-9]+)/;
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisy";
my $rx = $self->receiveCmd( $cmd );
my ($axisy) = $rx =~ /([-0-9]+)/;
Debug( "Set Preset $preset at $axisx and $axisy" );
my $cmd = "/cgi-bin/admin/setparam.cgi?camctrl_presetname_$preset=$preset&camctrl_presetpan_$preset=$axisx&camctrl_presettilt_$
$self->sendCmd( $cmd );
}
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Goto Preset $preset" );
my $cmd = "/cgi-bin/recall.cgi?recall=$preset";
$self->sendCmd( $cmd );
}
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=home";
$self->sendCmd( $cmd );
}
1;
__END__
Under control tab of your monitor:
Controllable: check
Control Device: none
Control Address: the camera IP, or user:pass@camera_ip
Return Location: Home
and follow the same instruction gave from normando at:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
remenber to change the name from Vivotek PT7135 to: Vivotek SD7151
the script work pretty fine, and can controlo up, down, lef, right, return to home, no zoom, no focus, no mapped areas. we will get you up to date in case of new development.
many many thanks to normando for his script.
Remember also to donate to zoneminder.
ilios
F5 is our mantra
Vivotek SD7151 scrito
SORRY USE THIS SECOND ONE
well here's the script developed by Normando and base from:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
for install in ubuntu 10.04 rename it as VivotekSd7151.pm and put in in:
/usr/share/perl5/ZoneMinder/Control
as the complete path looks like : /usr/share/perl5/ZoneMinder/Control/VivotekSd7151.pm
for different distro copy it in your "control" perl modules.
# ==========================================================================
#
# This module contains the implementation of the Vivotek SD7151 protocol
# It is easy to adapt to other Vivotek cameras. I have found a lot of commands with Wireshark
# This protocol get some info from the camera through receiveCmd function.
# Implement a pseudo diagonal movement
# Where go "presetClear" function from php code?
# Any improve is welcome, and please share it
# Normando Hall nhall[AT]unixlan[DOT]com[DOT]ar
#
package ZoneMinder::Control::VivotekSD7151;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
our $VERSION = $ZoneMinder::Base::VERSION;
# ==========================================================================
#
# Vivotek SD7151 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 receiveCmd
{
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg( $cmd, "Rx" );
#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."$cmd" );
my $res = $self->{ua}->request($req);
my $content = $res->content();
if ( $res->is_success )
{
$result = $content;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}
return( $result );
}
sub reset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "/cgi-bin/admin/setparam.cgi?System_Reset=3";
$self->sendCmd( $cmd );
}
sub moveMap
{
my $self = shift;
my $params = shift;
my $xcoord = $self->getParam( $params, 'xcoord' );
my $ycoord = $self->getParam( $params, 'ycoord' );
my $imagewidth = $self->{Monitor}->{Width};
my $imageheight = $self->{Monitor}->{Height};
Debug( "Move Map to $xcoord,$ycoord at $imagewidth/$imageheight" );
if ( $imagewidth == "640" )
{
$xcoord = $xcoord/2;
$ycoord = $ycoord/2;
}
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?cam1&x=$xcoord&y=$ycoord";
$self->sendCmd( $cmd );
}
sub moveRelUp
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDown
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Down - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Left - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Right - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Up/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
# test di zoom della camera
#sub zoomtele
#{
# my $self = shift;
# my $params = shift;
# my $panspeed = $self->getParam( $params, 'panspeed' );
# my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
# Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?zoom=tele&speedtele=$telespeed";
# $self->sendCmd( $cmd );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
# $self->sendCmd( $cmd );
#}
#fine del test
sub whiteAuto
{
my $self = shift;
Debug( "White Auto" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=0";
$self->sendCmd( $cmd );
}
sub whiteMan
{
my $self = shift;
Debug( "White Man" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=2";
$self->sendCmd( $cmd );
}
sub In
{
my $self = shift;
Debug( "White In" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=1";
$self->sendCmd( $cmd );
}
sub Out
{
my $self = shift;
Debug( "White Out" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=3";
$self->sendCmd( $cmd );
}
sub presetClear
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Clear Preset $preset" );
my $cmd = "/cgi-bin/admin/preset.cgi?delpos=$preset&Submit=Delete";
$self->sendCmd( $cmd );
}
sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisx";
my $rx = $self->receiveCmd( $cmd );
my ($axisx) = $rx =~ /([-0-9]+)/;
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisy";
my $rx = $self->receiveCmd( $cmd );
my ($axisy) = $rx =~ /([-0-9]+)/;
Debug( "Set Preset $preset at $axisx and $axisy" );
my $cmd = "/cgi-bin/admin/setparam.cgi?camctrl_presetname_$preset=$preset&camctrl_presetpan_$preset=$axisx&camctrl_presettilt_$
$self->sendCmd( $cmd );
}
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Goto Preset $preset" );
my $cmd = "/cgi-bin/recall.cgi?recall=$preset";
$self->sendCmd( $cmd );
}
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=home";
$self->sendCmd( $cmd );
}
1;
__END__
Under control tab of your monitor:
Controllable: check
Control Device: none
Control Address: the camera IP, or user:pass@camera_ip
Return Location: Home
and follow the same instruction gave from normando at:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
remenber to change the name from Vivotek PT7135 to: Vivotek SD7151
the script work pretty fine, and can controlo up, down, lef, right, return to home, no zoom, no focus, no mapped areas. we will get you up to date in case of new development.
many many thanks to normando for his script.
Remember also to donate to zoneminder.
ilios
well here's the script developed by Normando and base from:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
for install in ubuntu 10.04 rename it as VivotekSd7151.pm and put in in:
/usr/share/perl5/ZoneMinder/Control
as the complete path looks like : /usr/share/perl5/ZoneMinder/Control/VivotekSd7151.pm
for different distro copy it in your "control" perl modules.
# ==========================================================================
#
# This module contains the implementation of the Vivotek SD7151 protocol
# It is easy to adapt to other Vivotek cameras. I have found a lot of commands with Wireshark
# This protocol get some info from the camera through receiveCmd function.
# Implement a pseudo diagonal movement
# Where go "presetClear" function from php code?
# Any improve is welcome, and please share it
# Normando Hall nhall[AT]unixlan[DOT]com[DOT]ar
#
package ZoneMinder::Control::VivotekSD7151;
use 5.006;
use strict;
use warnings;
require ZoneMinder::Base;
require ZoneMinder::Control;
our @ISA = qw(ZoneMinder::Control);
our $VERSION = $ZoneMinder::Base::VERSION;
# ==========================================================================
#
# Vivotek SD7151 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 receiveCmd
{
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg( $cmd, "Rx" );
#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."$cmd" );
my $res = $self->{ua}->request($req);
my $content = $res->content();
if ( $res->is_success )
{
$result = $content;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}
return( $result );
}
sub reset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "/cgi-bin/admin/setparam.cgi?System_Reset=3";
$self->sendCmd( $cmd );
}
sub moveMap
{
my $self = shift;
my $params = shift;
my $xcoord = $self->getParam( $params, 'xcoord' );
my $ycoord = $self->getParam( $params, 'ycoord' );
my $imagewidth = $self->{Monitor}->{Width};
my $imageheight = $self->{Monitor}->{Height};
Debug( "Move Map to $xcoord,$ycoord at $imagewidth/$imageheight" );
if ( $imagewidth == "640" )
{
$xcoord = $xcoord/2;
$ycoord = $ycoord/2;
}
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?cam1&x=$xcoord&y=$ycoord";
$self->sendCmd( $cmd );
}
sub moveRelUp
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDown
{
my $self = shift;
my $params = shift;
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Down - Speed $tiltspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Left - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
Debug( "Move Right - Speed $panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Move Up/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelUpLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Up/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl.cgi?move=up&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownRight
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Right - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=right&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
sub moveRelDownLeft
{
my $self = shift;
my $params = shift;
my $panspeed = $self->getParam( $params, 'panspeed' );
my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=left&speedpan=$panspeed";
$self->sendCmd( $cmd );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
$self->sendCmd( $cmd );
}
# test di zoom della camera
#sub zoomtele
#{
# my $self = shift;
# my $params = shift;
# my $panspeed = $self->getParam( $params, 'panspeed' );
# my $tiltspeed = $self->getParam( $params, 'tiltspeed' );
# Debug( "Step Down/Left - Speed $tiltspeed/$panspeed" );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?zoom=tele&speedtele=$telespeed";
# $self->sendCmd( $cmd );
# my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=down&speedtilt=$tiltspeed";
# $self->sendCmd( $cmd );
#}
#fine del test
sub whiteAuto
{
my $self = shift;
Debug( "White Auto" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=0";
$self->sendCmd( $cmd );
}
sub whiteMan
{
my $self = shift;
Debug( "White Man" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=2";
$self->sendCmd( $cmd );
}
sub In
{
my $self = shift;
Debug( "White In" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=1";
$self->sendCmd( $cmd );
}
sub Out
{
my $self = shift;
Debug( "White Out" );
my $cmd = "/cgi-bin/admin/setparam.cgi?Video_Whitebalance=3";
$self->sendCmd( $cmd );
}
sub presetClear
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Clear Preset $preset" );
my $cmd = "/cgi-bin/admin/preset.cgi?delpos=$preset&Submit=Delete";
$self->sendCmd( $cmd );
}
sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisx";
my $rx = $self->receiveCmd( $cmd );
my ($axisx) = $rx =~ /([-0-9]+)/;
my $cmd = "/cgi-bin/admin/getparam.cgi?camctrl_axisy";
my $rx = $self->receiveCmd( $cmd );
my ($axisy) = $rx =~ /([-0-9]+)/;
Debug( "Set Preset $preset at $axisx and $axisy" );
my $cmd = "/cgi-bin/admin/setparam.cgi?camctrl_presetname_$preset=$preset&camctrl_presetpan_$preset=$axisx&camctrl_presettilt_$
$self->sendCmd( $cmd );
}
sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
my $preset = ( $preset - 1 );
Debug( "Goto Preset $preset" );
my $cmd = "/cgi-bin/recall.cgi?recall=$preset";
$self->sendCmd( $cmd );
}
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "/cgi-bin/camctrl/camctrl.cgi?move=home";
$self->sendCmd( $cmd );
}
1;
__END__
Under control tab of your monitor:
Controllable: check
Control Device: none
Control Address: the camera IP, or user:pass@camera_ip
Return Location: Home
and follow the same instruction gave from normando at:
http://www.zoneminder.com/forums/viewto ... ht=vivotek
remenber to change the name from Vivotek PT7135 to: Vivotek SD7151
the script work pretty fine, and can controlo up, down, lef, right, return to home, no zoom, no focus, no mapped areas. we will get you up to date in case of new development.
many many thanks to normando for his script.
Remember also to donate to zoneminder.
ilios
F5 is our mantra