HikVision PTZ control

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Paranoid
Posts: 117
Joined: Thu Feb 05, 2009 10:40 pm

Re: HikVision PTZ control

Post by Paranoid » Sat May 27, 2017 9:36 am

You can get the width and height as follows:

Code: Select all

    $xResolution = $self->{Monitor}{Width};
    $yResolution = $self->{Monitor}{Height};
Tried it on mine and it looks to work okay. It also appears that for the Relative command they have switched X and Y which confused me at first.

Handy tip:
Every time you make a change to the PTZ script you have to search for the zmcontrol process and kill it before ZoneMinder will use your new script. This is a real pain but there is an easy way around it. What you do is enable one of the control functions that you haven't implemented. For example I have enabled the "Can Wake" button. When I make changes to the PTZ script I press the "Wake" button and the script exits because it isn't implemented. Then when I press one of the other buttons (left, right etc) the new script is loaded.

kenworth
Posts: 46
Joined: Tue Feb 11, 2014 1:04 pm

Re: HikVision PTZ control

Post by kenworth » Fri Sep 15, 2017 5:43 pm

I have been playing around with this script (the revised one with relative movement) and while continuous movement and using presets seems to work fine, when I try anything that invokes relative movement I'm getting 403 Forbidden errors in the zmcontrol log. Same thing happens if I try to call zmcontrol from the command line. I have a DS-2DF7286-AEL running the 5.4.0 firmware. I see the comments in the HikVision.pm file about the camera timing out and having to retry commands. Wondering if anyone else has seen this and/or is there an updated version of the pm module?

Thanks!

Paranoid
Posts: 117
Joined: Thu Feb 05, 2009 10:40 pm

Re: HikVision PTZ control

Post by Paranoid » Fri Sep 15, 2017 6:37 pm

Does your camera support "momentary" move space which is what the script is using for relative movement.

Try this url:

Code: Select all

http://<yourcamera>/ISAPI/PTZCtrl/channels/1/capabilities
The response is a block of XML describing the PTZ capabilities.

If you see a section like this:

Code: Select all

<MomentaryPanTiltSpace>
 ...
</MomentaryPanTiltSpace>
<MomentaryZoomSpace> 
 ...
</MomentaryZoomSpace>
Then it does

kenworth
Posts: 46
Joined: Tue Feb 11, 2014 1:04 pm

Re: HikVision PTZ control

Post by kenworth » Fri Sep 15, 2017 6:50 pm

Apparently not, which is strange considering I'm running fairly current FW and on the 2.0 version of the api. Looks like only absolute and continuous movement are available. Relevant XML is below:

<PTZChanelCap xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<AbsolutePanTiltPositionSpace>
<XRange>
<Min>0</Min>
<Max>3600</Max>
</XRange>
<YRange>
<Min>0</Min>
<Max>900</Max>
</YRange>
</AbsolutePanTiltPositionSpace>
<AbsoluteZoomPositionSpace>
<ZRange>
<Min>10</Min>
<Max>300</Max>
</ZRange>
</AbsoluteZoomPositionSpace>
<ContinuousPanTiltSpace>
<XRange>
<Min>-100</Min>
<Max>100</Max>
</XRange>
<YRange>
<Min>-100</Min>
<Max>100</Max>
</YRange>
</ContinuousPanTiltSpace>
<ContinuousZoomSpace>
<ZRange>
<Min>-100</Min>
<Max>100</Max>
</ZRange>
</ContinuousZoomSpace>

Paranoid
Posts: 117
Joined: Thu Feb 05, 2009 10:40 pm

Re: HikVision PTZ control

Post by Paranoid » Fri Sep 15, 2017 7:19 pm

Have some code for moveMap instead

Code: Select all

sub moveMap {
    my $self = shift;
    my $params = shift;
#    Info Dumper $params;
#    Info Dumper $self->{Monitor};
    my $x = $self->getParam( $params, 'xcoord', $self->{Monitor}{Width}/2 );
    my $y = $self->getParam( $params, 'ycoord', $self->{Monitor}{Height}/2 );
    # Flip Y
    $y = $self->{Monitor}{Height} - $y -1;
    # Range is 0 - 255
    $x = int(256 * $x / $self->{Monitor}{Width});
    $y = int(256 * $y / $self->{Monitor}{Height});
    my $pos = "<positionX>$x</positionX><positionY>$y</positionY>";
    my $xml = "<Position3D><StartPoint>$pos</StartPoint><EndPoint>$pos</EndPoint></Position3D>";
    $self->PutCmd("ISAPI/PTZCtrl/channels/$ChannelID/position3D",$xml);
}
You'll have to enable "Can Move Mapped" in the camera capabilities.
When you pop up your camera feed you might have to switch to event view and back to control before the move mapped will work.

Of course, this will only work if you have the Position3D capability. Look for the following:

Code: Select all

<isSupportPosition3D>true</isSupportPosition3D>

kenworth
Posts: 46
Joined: Tue Feb 11, 2014 1:04 pm

Re: HikVision PTZ control

Post by kenworth » Fri Sep 15, 2017 7:42 pm

I do have the position3D capability (whew). I'll give this a shot. Thanks a lot for the help!

pat2
Posts: 73
Joined: Fri Sep 16, 2016 6:35 pm

Re: HikVision PTZ control

Post by pat2 » Mon Jan 29, 2018 4:47 pm

Hi Paranoid,

I have an Hk vision cam working well with PTZ command of IVMS 4200 client.
But I'm not able to run PTZ command with your script in zoneminder.

Probably i'm not able to configure properly

- control type
- control device
- control address

in zoneminder.
Could you help me please?
If you want I could copy the parameters that automatically the IVMS 4200 client give to my camera when i ask to "Add to client".
thanks

Paranoid
Posts: 117
Joined: Thu Feb 05, 2009 10:40 pm

Re: HikVision PTZ control

Post by Paranoid » Mon Jan 29, 2018 6:26 pm

You probably have the "Control Device" wrong.

Go to the following url: http://<your camera/ISAPI/System/deviceInfo
You might have to enter the username and password. This should give you an XML file.
Look for the model tag. Whatever is in there should go in the "Control Device" setting.
The control type should be HikVision and Control address should be username:password@<your camera>

If it still isn't working post the contents of the zmcontrol.log file.

sagitt
Posts: 32
Joined: Mon Apr 30, 2012 1:13 pm

Re: HikVision PTZ control

Post by sagitt » Sat Feb 03, 2018 5:20 pm

works with my DS-2CD2142FWD-IS
only for reboot

but i can set my control device only with logs

my control device is like: IP Camera(XXXXX) and is a part of serial number

bobylapointe69300
Posts: 10
Joined: Wed Feb 14, 2018 6:51 pm

Re: HikVision PTZ control

Post by bobylapointe69300 » Wed Feb 28, 2018 11:48 am

Thanks for the script, fully working on a DS-2CD3Q10FD-IW.

I a running 1.30 ZM on ubuntu server, and can proceed to below controls:
  • Pan move
  • Tilt move
  • Presets (goto and set)
  • Reboot
My control settings :
Control Device: DS-2CD3Q10FD-IW
Control Address: user:password@IPaddress

I use Ffmpeg as control type. I thought there was an autostop

pat2
Posts: 73
Joined: Fri Sep 16, 2016 6:35 pm

Re: HikVision PTZ control

Post by pat2 » Sun Mar 18, 2018 1:21 pm

Paranoid wrote:
Mon Jan 29, 2018 6:26 pm
You probably have the "Control Device" wrong.

Go to the following url: http://<your camera/ISAPI/System/deviceInfo
You might have to enter the username and password. This should give you an XML file.
Look for the model tag. Whatever is in there should go in the "Control Device" setting.
The control type should be HikVision and Control address should be username:password@<your camera>

If it still isn't working post the contents of the zmcontrol.log file.
Hi Paranoid, thanks a lot for your suggestions.
I bought the 3 cameras by Amazon (LEFTEK PoE PTZ IP Camera Mini 1080P 3X Zoom 2.8-8mm 20M IR Distance CCTV Security Camera Outdoor IP67 Weatherproof High Speed IP PTZ Camera- One Key Connection With HIKVISION NVR/CMS):

https://www.amazon.co.uk/LEFTEK-Distanc ... B076MS5YSS

I imagine it's an HIKVISION clone branded LEFTEK (never heard brand) but it's cheap and works well.

For sure it's HIKVISION compatible: I'm able to send PTZ commands through the Hikvision iVMS-4200 client and the CAM works.

I tried:

Code: Select all

http://192.168.1.200/ISAPI/PTZCtrl/channels/1/capabilities
http://192.168.1.200/ISAPI/System/deviceInfo
http://admin:admin@192.168.1.200/ISAPI/PTZCtrl/channels/1/capabilities
http://admin:admin@192.168.1.200/ISAPI/System/deviceInfo

no way: I cannot access the page.

I found the following information in in the System page of the camera:

Basic information
Version: V1.04.10-171122 Time zone: GMT+01:00
Product info: IPC-E14Y07 series SerialNum: 071D3E2768C6

and the following through iVMS-4200:

Image

I found PTZ CAMERA as Device Name in iVMS-4200 client.

Those are the logs I found in the LOG zoneminder webpage (i didn't find the zmcontrol.log file!) when i tried to send PTZ commands (3 times) to the IPCAM:

2018-03-18 16:19:42.986260 zmcontrol 17581 FAT 400 Page not found zmcontrol.pl
2018-03-18 16:19:42.316710 zmcontrol 17579 FAT 400 Page not found zmcontrol.pl
2018-03-18 16:19:41.162800 zmcontrol 17581 INF Control server 7/HikVision starting at 18/03/18 16:19:41 zmcontrol.pl
2018-03-18 16:19:40.943530 zmcontrol 17579 INF Control server 7/HikVision starting at 18/03/18 16:19:40 zmcontrol.pl
2018-03-18 16:19:40.353870 zmcontrol 17561 INF Starting control server 7/HikVision zmcontrol.pl
2018-03-18 16:19:40.023140 zmcontrol 17563 INF Starting control server 7/HikVision zmcontrol.pl

with the following ZM configuration (6 combinations) in Control Tab:

Control Type: Pelco-D (type Remote and then modified Ffmpeg)
Control Device: IPCAM071D3E2768C6 and then modified HK-IPCAM071D3E2768C6 and PTZ CAMERA
Control address: admin:admin@192.168.1.200

please, tell me.
thanks
Last edited by pat2 on Fri Mar 30, 2018 6:58 pm, edited 2 times in total.

bobylapointe69300
Posts: 10
Joined: Wed Feb 14, 2018 6:51 pm

Re: HikVision PTZ control

Post by bobylapointe69300 » Sun Mar 18, 2018 10:08 pm

Is your HTTP camera connection port 8080? (no easy to read that on 1st print screen) If yes, you have to specify it, i.e.:

Code: Select all

http://192.168.1.200:8080/ISAPI/System/deviceInfo
Try to avoid safari as the xml output will not be easy to read. Prefer Firefox or Opera like browser. No need to specify user:password in the command address for this check as you will be prompted to fill them in.
Assuming your rtsp port is 554, try to open a network flow in VLC with:

Code: Select all

rtsp://192.168.1.200:554/Streaming/Channels/1
or any valid rtsp address (in your amazon link, looks like this IPC has onvif. You can also use a tool like onvif device manager to get you camera's flow).
Give the results of these tryouts. This has to be working prior to helping you out with the rest.

pat2
Posts: 73
Joined: Fri Sep 16, 2016 6:35 pm

Re: HikVision PTZ control

Post by pat2 » Mon Mar 19, 2018 7:06 pm

bobylapointe69300 wrote:
Sun Mar 18, 2018 10:08 pm
Is your HTTP camera connection port 8080? (no easy to read that on 1st print screen) If yes, you have to specify it, i.e.:

Code: Select all

http://192.168.1.200:8080/ISAPI/System/deviceInfo
Try to avoid safari as the xml output will not be easy to read. Prefer Firefox or Opera like browser. No need to specify user:password in the command address for this check as you will be prompted to fill them in.
Assuming your rtsp port is 554, try to open a network flow in VLC with:

Code: Select all

rtsp://192.168.1.200:554/Streaming/Channels/1
or any valid rtsp address (in your amazon link, looks like this IPC has onvif. You can also use a tool like onvif device manager to get you camera's flow).
Give the results of these tryouts. This has to be working prior to helping you out with the rest.
hi, thx.

My browser is firefox. the http camera port is 80.
the suggested link is not working, anyway I discovered the device name thorugh iVMS client. It's PTZ CAMERA.

I'm able to see the video stream on ZM or VLC(through rtsp://admin:admin@192.168.1.200:554/1/h264minor or rtsp://admin:admin@192.168.1.200:554/1/h264major), currently the issue is on PTZ command: even if I send, the camera doesn't move.

thanks

bobylapointe69300
Posts: 10
Joined: Wed Feb 14, 2018 6:51 pm

Re: HikVision PTZ control

Post by bobylapointe69300 » Tue Mar 20, 2018 8:18 am

Understood that your issue is with PTZ control, but to troubleshoot that, you have to investigate what commands your camera can accept over http.

Code: Select all

http://192.168.1.200:8080/ISAPI/System/deviceInfo 
is a basic one from HIKVISION API, so if this is not working, then you will not be able to monitor PTZ in ZM with the HIKVISION module...
What about asking your amazon seller (or any seller who can support) a SELTEK API documentation and sharing it there?

pat2
Posts: 73
Joined: Fri Sep 16, 2016 6:35 pm

Re: HikVision PTZ control

Post by pat2 » Tue Mar 20, 2018 12:10 pm

bobylapointe69300 wrote:
Tue Mar 20, 2018 8:18 am
Understood that your issue is with PTZ control, but to troubleshoot that, you have to investigate what commands your camera can accept over http.

Code: Select all

http://192.168.1.200:8080/ISAPI/System/deviceInfo 
is a basic one from HIKVISION API, so if this is not working, then you will not be able to monitor PTZ in ZM with the HIKVISION module...
What about asking your amazon seller (or any seller who can support) a SELTEK API documentation and sharing it there?
:-) I saw...it's sure the camera could accept PTZ commands and it's HIKvision compatible since i'm able to do through the standard Hikvision client (named iVMS 4200. please see the link below). It's working fine with PTZ commands (movements, focus, presets,...) without any configuration by me!!! :D
I only configured in the iVMS4200 client the IP of the cam 192.168.1.200, user admin and pwd admin and it'sworking.

http://en.hikvision.com.106.mountor.com ... ls_84.html

so, that's the reason the PTZ commands for the camera shall work with HIkvision protocol. In ZM too with the proper script/configuration based on HIKvision protocol.
For the camera url to get the info I understand it is the standard url for HIKvision cameras. And i'm worried it's not working with mine.
On the other side since the camera is working with the HIKvision standard client iVMS4200 there should be the compatibility. Probably slightly different urlto get the info..I hope.

I already tried with the seller. The answer I received is poor:

"We use standard Pelco-D protocol":

{ff,01,00,08,00,ff,08,}//ÉÏ
{ff,01,00,10,00,ff,10,}//ÏÂ
{ff,01,00,04,ff,00,04,}//×ó
{ff,01,00,02,ff,00,02,}//ÓÒ
{ff,01,00,20,00,00,21,}//zoom in
{ff,01,00,40,00,00,41,}//zoom out
{ff,01,00,80,00,00,81,}//focus in
{ff,01,01,00,00,00,02,}//focus out
{ff,01,02,00,00,00,03,}//aperture small
{ff,01,04,00,00,00,05,}//aperture big
{ff,01,00,0b,00,01,0d,}//turn off light
{ff,01,00,09,00,01,0b,}//turn on light
{ff,01,00,07,00,01,09,}//to preset point 001
{ff,01,00,03,00,01,05,}//set preset point 001
{ff,01,00,05,00,01,07,}//delete preset point001
{ff,01,00,00,00,00,01,}//stop command

Probably he is a re-seller with a poor knowledge about the technical aspects.

I wrote again to them asking to speak with their technical support.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests