Dahua API and Relative Camera Movement

chris_19

n3wb
Apr 4, 2019
3
0
Terra Firma
According to the Dahua API spec 1.67, the following should cause the camera to pan relatively 100*

http://xxx.xxx.xxx.xxx/cgi-bin/ptz....ively&channel=0&arg1=100&arg2=0&arg3=0&Arg4=0

However, it results in:

Error
Bad Request!

A little digging shows a JS method named 'moveRelatively' However, there does not appear to be an associated 'Relatively' cgi method.

The other methods listed in the API doc under the PTZ control section appear to work.

Any thoughts?

Chris
 
per the version of the guide I am looking at, the command syntax is...
http://<ip>/cgi-bin/ptz.cgi?action=[action]&channel=[ch]&code={code}&arg1=[argstr]& arg2=[argstr]&arg3=[argstr]

so it looks like your command should be...
http://<ip>/cgi-bin/ptz.cgi?action={start|stop}&channel=0&code=Relatively&arg1=100&arg2=0&arg3=0[/code]

PS - I had to change the 'code=' argument (on the 1st line above) to curly brackets 'code={code}' to prevent the interpreter from changing my entry to a code formatted section, .e.g,

Code:
 
Last edited:
I don't see the 'Relatively' code option for ptz.cgi in this Amcrest API.
They do eliminate things sometimes. Bottom line is match (by date) the camera fw and api version as closely as you can for best results.

You're looking at some combination of:
4.5.18 Get coordinates of current window
4.5.19 Set coordinates of current window
4.10.9 PTZ Move directly
4.10.8 Get PTZ status
4.10.7 PTZ control command

Using ONVIF would be another option.
 
I don't see the 'Relatively' code option for ptz.cgi in this Amcrest API.

Indeed it does look like they have removed it. At least from the cgi interface. The JS libraries seems to support it, but I have not documentation on those.

The doc @tangent mentions has a 'Position' code which appears to produce relative movement. The units are not clear, but doing a little testing seems to indicate that in the pan plane, a value of 100 translates into counter-clockwise (looking at the camera from the bottom end-on) to the tune of ~0.035 degrees.

If I can get the units down, this will do what I need it to.

Thanks for the help!
 
So this would be a very inefficient way to do absolute positioning of the camera (but then, that is what 'PositionABS' is for). That said, the underlying math seems to indicate a logarithmic function is driving this motion:

degrees = -18.99666 + 6.9773*ln(position)

Although the low end of this regression is not really accurate.

At any rate, it does provide a means of very small increments of relative movement, and a value of 100 reliably produces the movement described in my previous post, FWIW.
 
You can set lots of presets. Generally switching between presets is a good option.
 
Hi Guys, I have a Dahua Starlight 4mp speed dome. I am building a wireless alarm control system that will basically when triggered on an input tell the PTZ to go to a given preset location using HTTP api commands. I have the goto preset function working perfectly however the camera is set to tour and I also want to be able to control this on / off tour via the api call. Command gets sent and returns OK however still in tour mode. I have tried all the combination, anyone know where I am going wrong?

Here is preset control working:
Here is tour stop not working but OK response:
Any help would be greatly appreciated. Big thanks Dans