JMK-UP-010 IP cam w/ptz working

Post here to indicate any hardware you have used and which is known to work with ZoneMinder. Not for questions.
Post Reply
CoYoTe
Posts: 33
Joined: Sat Jul 18, 2009 12:56 pm
Location: Buenos Aires, Argentina

JMK-UP-010 IP cam w/ptz working

Post by CoYoTe »

Product Name JMK-UP-010
Brief Name UP-010
Product Serial Number 00168E1955aa
Hardware Version 1.0.0.0
Firmware Version 1.1.0.12

Service Provider Link
http://www.jmk.com.cn

This is a basic dome IP cam, with a limited PTZ control. It only can PAN/TILT, and controls bright and contrast.
Can work at 160x120, 320x240 or 640x480.
The webserver is very simple.

It works fine with Zoneminder 1.24.2

Detailed implementation:

Remote Protocol : HTTP
Remote Method: SIMPLE
Remote Server Name: [CAM-IP ADDRESS]
Remote Server Port: 80
Remote Server Link: /cgi/sf.cgi
Remote Image Colours: 24 bits
Captura Ancho (pixels): 320
Captura Alto (pixels):240

Anonymous access must be enabled via webserver to get image.

to get PTZ working, a script is needed (based on axis control script)

In my box (Debian Squeeze + Zoneminder 1.24.2), the perl control scripts are located at
/usr/local/share/perl/5.10.1/ZoneMinder/Control

Here, you need to create a file called jmkup10.pm

and paste this into it

Code: Select all

# ==========================================================================
#
# ZoneMinder JMK API Control Protocol Module, $Date: 2009-11-10 06
#
# 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 JMK camera control
# protocol
#
package ZoneMinder::Control::jmkup10;

use 5.006;
use strict;
use warnings;

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

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

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

# ==========================================================================
#
# jmkup10 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 fallo: '".$res->status_line()."'" );
    }

    return( $result );
}

sub moveConUp
{
    my $self = shift;
    Debug( "Move Up" );
    my $cmd = "/cgi-bin/action?action=cam_mv&diretion=cam_up&lang=eng";
    $self->sendCmd( $cmd );
}

sub moveConDown
{
    my $self = shift;
    Debug( "Move Down" );
    my $cmd = "/cgi-bin/action?action=cam_mv&diretion=cam_down&lang=eng";
    $self->sendCmd( $cmd );
}

sub moveConLeft
{
    my $self = shift;
    Debug( "Move Left" );
    my $cmd = "/cgi-bin/action?action=cam_mv&diretion=cam_left&lang=eng";
    $self->sendCmd( $cmd );
}

sub moveConRight
{
    my $self = shift;
    Debug( "Move Right" );
    my $cmd = "/cgi-bin/action?action=cam_mv&diretion=cam_right&lang=eng";
    $self->sendCmd( $cmd );
}

sub presetHome
{
    my $self = shift;
    Debug( "Home Preset" );
    my $cmd = "/cgi-bin/action?action=cam_mv&diretion=cam_home&lang=eng";
    $self->sendCmd( $cmd );
}
In CONTROL tab of the cam settings (remember under general OPTION to enable OPT_CONTROL so ZoneMinder can control PTZ cameras) the settings must be:

Controllable: Mark
Control Type: Must be EDITED finally name it jmkup10
Control Device: left it blank
Control Address: admin:123456@ip-of-the-cam
Auto Stop Timeout: 10.00
Track Motion: enabled
Track Delay: 1
Return Location: Home
Return Delay: 1

Edit controls, and ADD a new one called jmlup10

the items i dont mention must be left at default value (blank or 0)

on MAIN tab

Name: jmkup10
Type: Remote
Protocol: jmkup10

on MOVE tab

Can Move : mark
Can Move Continuous: mark

on PAN tab

Can Pan: mark

on TILT tab

Can Tilt : mark

on PRESETS tab

Has Presets: mark
Num Presets: 0
Has Home Preset: mark

And that's it, now you can control cam via CONTROL link in single cam view or in multiple using the same link.
Alejandro
Post Reply