Dahua http api for setting the focus

drakejest

Young grasshopper
Joined
Sep 9, 2022
Messages
60
Reaction score
9
Location
Asia
I have the Dahua PTZ model: DH-SD59225UN-HNI running on the latest firmware available on Dahua's website. I need to run automations on it using http API calls. So far i am able to move the cameras where i want to and even zoom on the correct level.

For example here is the api call for moving to an absolute position with a zoom level according to the API

Code:
http://admin:admin1234@192.168.0.3/cgi-bin/ptz.cgi?action=start&channel=1&code=PositionABS&arg1=239&arg2=22&arg3=0


But my problem lies in adjusting the focus, according to that pdf ( which i found in this forum and they said is the same as dahua is using) to adjust focuse i must send

Code:
http://admin:admin1234@192.168.0.3/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0.5&zoom=-0.5
problem is i get a response error 400: Bad Request. Which is unfortunate because i need focus to work, the autofocus is not enough as it keeps focusing on the wrong things.

i did found something that works with the focus

Code:
http://admin:admin1234@192.168.0.3/cgi-bin/ptz.cgi?action=start&channel=1&code=FocusNear
http://admin:admin1234@192.168.0.3/cgi-bin/ptz.cgi?action=start&channel=1&code=FocusFar
it does work, but it sometime over / under shoot the focus.

Can anyone help me find the correct api for focus. It would be nice if it was a numerical value so i can finely tune it to focus on the correct object.
 

Attachments

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
25,046
Reaction score
48,849
Location
USA
Nobody has been able to figure out how to do the focus for a PTZ.

All the other Dahua cameras, you can open up the focus tab and hover over the slider to get the focus number.

That doesn't exist in the PTZs and is probably why an API doesn't work.
 

drakejest

Young grasshopper
Joined
Sep 9, 2022
Messages
60
Reaction score
9
Location
Asia
Nobody has been able to figure out how to do the focus for a PTZ.
Really ? If i want to control something on a camera Focus is definitely one of them, so its kind of weird that you cannot control them as finely tuned


That doesn't exist in the PTZs and is probably why an API doesn't work.
You mean controllable focus in the camera? im pretty sure there is. Im even able to adjust the focus in smartPSS.

Even if the command is just increment / decrement focus, with that i can atleast work around it to get the desired result
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
25,046
Reaction score
48,849
Location
USA
Of course you can control the focus of the PTZ camera and do it in incremental steps...what I said was you don't get the ability to set the focus to a number like you can on the fixed cameras....and it is a focus NUMBER that is needed for an API to work.

The fixed camera gives you the ability to put your mouse over a cursor and get the focus number or run an API command to get that number as a decimal.

1662777398039.png

Whereas the PTZ controls only give you incremental focus but without a number that you can force it to and as you saw if you run the API command to get the focus it returns bad response:

1662777462554.png

We have tried to figure that out with the Dahua PTZs so that we can use them as an LPR (license plate reader).

For LPR where you run tight field of views and fast shutters, the cameras have nothing to focus on because the image is black at night. Without the ability to call up a focus number, we are forced to run it at a specific field of view location early while there is still enough light for it to get a focus.

So say we wanted to run the PTZ at one field of view until 11pm and then turn it to a different field of view to use for LPR, we have the API for the preset and zoom, but not the focus, so then all the plates are blurry.
 

drakejest

Young grasshopper
Joined
Sep 9, 2022
Messages
60
Reaction score
9
Location
Asia
I have tried every command in that document that has something to do with the focus and they all returned as an error. I think you are right there might be no way to adjust the focus.


I just find that weird. they have api for very many things but not adjusting focus.


the only thing that work are these 2 api:

Code:
http://admin:admin1234@192.168.0.3/cgi-bin/ptz.cgi?action=start&channel=1&code=FocusNear
http://admin:admin1234@192.168.0.3/cgi-bin/ptz.cgi?action=start&channel=1&code=FocusFar
problem with them is they wont stop focusing , so focusNear will keep adjusting its focus until it reached the minimum.
 
Top