Informations PTZ Motion for ESCAM G02

Forum for questions and support relating to the 1.30.x releases only.
Locked
xefil
Posts: 53
Joined: Wed Jul 19, 2017 1:30 pm

Informations PTZ Motion for ESCAM G02

Post by xefil »

Hello,

I'm able to move my ESCAM (OnVif 2.04) using NetCat. BTW I'm not able to save Preset and call them.
Using Windows OnVif Device Manager 2.2.250 I'm able to do all.
How can I work with it?
Then, trying to enable Mdetect, it dosn't work. Into logs:

Code: Select all

'zmtrack.pl -m 2' exited abnormally, exit status 255
If I try to execute it manually:

Code: Select all

Tracker daemon 2 (experimental) starting at 18/05/15 23:38:24
Monitor '2' cannot move in map mode
I'm working on Debian9 with ZM1.30.4 (binary)

Thanks,

Simon
Daedilus
Posts: 5
Joined: Sat Jun 09, 2018 7:41 pm

Re: Informations PTZ Motion for ESCAM G02

Post by Daedilus »

Hey, I'm pretty new to this forum but have the same camera that you do and have had moderate success getting things going. I have found and modified a Control script that works pretty well with this camera ESCAM G02 / IPCAMERA / C9F0SeZ0N0P2L0.

Here is a copy of the control script. Hope it helps with things.

Cheers

Code: Select all

# ==========================================================================
#
# ZoneMinder IPCAM2MP Control Protocol Module, $Date: 2009-11-25 09:20:00 +0000 (Wed, 04 Nov 2009) $, $Revision: 0003 $
# Copyright (C) 2001-2008  Philip Coombes
#
# Modified for China 2MP NetIpCam camera by Radmilo Feliox n 2015-05-05 00:03:00
# Modified for ESCAM G02 / IPCAMERA / C9F0SeZ0N0P2L0 / FW: V9.1.6.1.24-20170925 BY PETER ZARGLIS n 2018-06-09 13:45:00
# For more information/cgi-bin commands see https://www.themadhermit.net/wp-content/uploads/2013/03/FI9821W-CGI-Commands.pdf
# 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 China 2MP NetIpCam camera
# control protocol.
#
# ==========================================================================
package ZoneMinder::Control::IPCAM2MP;

use 5.006;
use strict;
use warnings;

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

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

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

# ==========================================================================
#
# China 2MP NetIpCam Control Protocol
#
# ==========================================================================

use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);
use Time::HiRes qw( usleep );

my $loopfactor=100000;

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

sub open
{
    my $self = shift;

    $self->loadMonitor();

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


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

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

sub sendCmd
{
    my $self = shift;
    my $cmd = shift;
    my $result = undef;
    my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
    my $res = $self->{ua}->request($req);
    if ( $res->is_success )
    {
        $result = $res->decoded_content;
    }
    else
    {
        Error( "Error check failed: '".$res->status_line()."'" );
    }
    return( $result );
}

# Reboot camera
sub reset
{
    my $self = shift;
    Debug( "Camera Reset" );
    my $cmd = "cgi-bin/hi3510/sysreboot.cgi";
    $self->sendCmd( $cmd );
}

# Flip image on vertically
sub wake
{
    my $self = shift;
    Debug( "Flip on" );
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-flip=on";
    $self->sendCmd( $cmd );
}


# Flip image off vertically
sub sleep
{
    my $self = shift;
    Debug( "Flip off" );
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-flip=off";
    $self->sendCmd( $cmd );
}

sub moveConUp
{
    my $self = shift;
    my $params = shift;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=up";
    $self->sendCmd( $cmd );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->moveStop( $params );
    }
    else
    {
    $self->moveStop( $params );
    }
}

sub moveConDown
{
    my $self = shift;
    my $params = shift;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=down";
    $self->sendCmd( $cmd );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->moveStop( $params );
    }
    else
    {
    $self->moveStop( $params );
    }
}

sub moveConRight
{
    my $self = shift;
    my $params = shift;
    Debug( "Move Right" );
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=right";
    $self->sendCmd( $cmd );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->moveStop( $params );
    }
    else
    {
    $self->moveStop( $params );
    }
}

sub moveConLeft
{
    my $self = shift;
    my $params = shift;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=left";
    $self->sendCmd( $cmd );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->moveStop( $params );
    }
    else
    {
    $self->moveStop( $params );
    }
}

# The camera can not move diagonally, so we will implement those movements in the next 4 subroutines:
sub moveConUpLeft
{
    my $self = shift;
    my $params = shift;
    my $loopcount=int($self->{Monitor}->{AutoStopTimeout}/$loopfactor);
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        while ( $loopcount  )
        {
             $loopcount--;
             my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=up";
             $self->sendCmd( $cmd );
             my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=left";
             $self->sendCmd( $cmd );

         }
        $self->moveStop( $params );
    }
}

sub moveConUpRight
{
   my $self = shift;
   my $params = shift;
   my $loopcount=int($self->{Monitor}->{AutoStopTimeout}/$loopfactor);
   my $autostop = $self->getParam( $params, 'autostop', 0 );
   if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
   {
         while ( $loopcount  )
         {
             $loopcount--;
             my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=up";
             $self->sendCmd( $cmd );
             my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=right";
             $self->sendCmd( $cmd );
         }
            $self->moveStop( $params );
  }
}

sub moveConDownRight
{
    my $self = shift;
    my $params = shift;
    my $loopcount=int($self->{Monitor}->{AutoStopTimeout}/$loopfactor);
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        while ( $loopcount  )
        {
            $loopcount--;
            my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=down";
            $self->sendCmd( $cmd );
            my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=right";
            $self->sendCmd( $cmd );
        }
        $self->moveStop( $params );
    }
}

sub moveConDownLeft
{
    my $self = shift;
    my $params = shift;
    my $loopcount=int($self->{Monitor}->{AutoStopTimeout}/$loopfactor);
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        while ( $loopcount  )
        {
            $loopcount--;
            my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=down";
            $self->sendCmd( $cmd );
            my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=left";
            $self->sendCmd( $cmd );
        }
        $self->moveStop( $params );
    }
}

sub moveStop
{
    my $self = shift;
    print("autostop\n");
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=ptzctrl&-step=0&-speed=10&-act=stop";
    $self->sendCmd( $cmd );
}

sub getDisplayAttr
{
    my $self = shift;
    my $param = shift;
    my $cmdget = "cgi-bin/hi3510/param.cgi?cmd=getvdisplayattr&-brightness";
    my $resp = $self->sendCmd( $cmdget );
    my @buffer=split(';',$resp);
    my $response=$buffer[$param];
    my @buffer=split('"',$response);
    my $response=$buffer[1];
    return ($response);
}

# presetHome is used to normalize the brightness/contrast/hue/saturation values
sub presetHome
{
    my $self = shift;
    Debug( "Home Preset" );
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-brightness=50&-contrast=50&-saturation=50&-hue=50";
    $self->sendCmd( $cmd );
}

sub presetSet
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Set Preset $preset " );
    my $cmd = "cgi-bin/hi3510/preset.cgi?-act=set&-status=1&-number=$preset";
    $self->sendCmd( $cmd );
}

sub presetGoto
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug( "Goto Preset $preset" );
    my $cmd = "/cgi-bin/hi3510/preset.cgi?-act=goto&-number=$preset";
    $self->sendCmd( $cmd );
}

# Contrast control
sub whiteAbsIn
{
    my $self = shift;
    my $params = shift;
    Debug( "Contrast up" );
    my $dvalue=$self->getDisplayAttr(6);
    if ( $dvalue < 100 )
    {
    $dvalue=$dvalue+5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-contrast=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Contrast control
sub whiteAbsOut
{
    my $self = shift;
    my $params = shift;
    Debug( "Contrast down" );
    my $dvalue=$self->getDisplayAttr(6);
    if ( $dvalue > 0 )
    {
    $dvalue=$dvalue-5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-contrast=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Brightness control
sub irisAbsOpen
{
    my $self = shift;
    my $params = shift;
    Debug( "Brightness up" );
    my $dvalue=$self->getDisplayAttr(4);
    if ( $dvalue < 100 )
    {
    $dvalue=$dvalue+5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-brightness=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Brightness control
sub irisAbsClose
{
    my $self = shift;
    my $params = shift;
    Debug( "Brightness down" );
    my $dvalue=$self->getDisplayAttr(4);
    if ( $dvalue > 0 )
    {
    $dvalue=$dvalue-5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-brightness=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Saturation control
sub zoomAbsTele
{
    my $self = shift;
    my $params = shift;
    Debug( "Saturation up" );
    my $dvalue=$self->getDisplayAttr(5);
    if ( $dvalue < 100 )
    {
    $dvalue=$dvalue+5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-saturation=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Saturation control
sub zoomAbsWide
{
    my $self = shift;
    my $params = shift;
    Debug( "Saturation down" );
    my $dvalue=$self->getDisplayAttr(5);
    if ( $dvalue > 0 )
    {
    $dvalue=$dvalue-5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-saturation=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Hue control
sub focusAbsNear
{
    my $self = shift;
    my $params = shift;
    Debug( "Hue up" );
    my $dvalue=$self->getDisplayAttr(7);
    if ( $dvalue < 100 )
    {
    $dvalue=$dvalue+5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-hue=$dvalue";
    $self->sendCmd( $cmd );
    }
}

# Hue control
sub focusAbsFar
{
    my $self = shift;
    my $params = shift;
    Debug( "Hue down" );
    my $dvalue=$self->getDisplayAttr(7);
    if ( $dvalue > 0 )
    {
    $dvalue=$dvalue-5;
    my $cmd = "cgi-bin/hi3510/param.cgi?cmd=setvdisplayattr&-hue=$dvalue";
    $self->sendCmd( $cmd );
    }
}

1;
xefil
Posts: 53
Joined: Wed Jul 19, 2017 1:30 pm

Re: Informations PTZ Motion for ESCAM G02

Post by xefil »

Hello Daedilus,

Thanks for sharing.
After playing around I was able to let it work succesfully.
BTW I'll try your script as well.

Thanks, Simon
Locked