Dahua webcam - getting / setting position via API

aidan

n3wb
Joined
Aug 16, 2023
Messages
1
Reaction score
0
Location
United Kingdom
Hi All,

my first post to this forum so please be gentle :)

We have a Dahua webcam that we control via the HTTP API. That works OK. I'd like to be able to offer the functionality to create "personal presets" for different webcam users - ideally without storing these presets on the camera (although that remains the fallback option as I believe we have 300 preset slots "on cam").

To explain further, I want a user to be able to PTZ the camera to a position and then click a "save as preset" button. I see there is a /cgi-bin/ptz.cgi?action=getStatus&channel=0 PTZ command so i thought I'd be able to
  • call that command
  • store the relevant values from that command away as a "personal preset" for the user
  • then feed the relevant values from the above command into a Dahua API PTZ call to move the cam back to the "personal preset".

I've put an example of the output from the PTZ getStatus call and believe I have plugged every combination of the status.AbsPosition and status.Position data values into the /cgi-bin/ptz.cgi?action=start&channel=0&code=PositionABS and /cgi-bin/ptz.cgi?action=start&channel=0&code=Position APIs but the camera ends up pointing no where near expected!!!

I'd naively thought it would be simple to ask the cam "where are you pointed" and then use that data to tell it to "point 'here'". Seems like I was wrong!

Has anyone been here before and learnt how to cast the required magic runes?

Many thanks

Aidan

status.AbsPosition[0]=9694
status.AbsPosition[1]=426
status.AbsPosition[2]=320
status.Action=Preset
status.ActionID=8
status.Focus.FocusPosition=0.000000
status.Focus.Status=Idle
status.FocusMapValue=4096
status.Iris.IrisValue=6.000000
status.Iris.Status=Idle
status.MoveStatus=Idle
status.PanTiltStatus=Idle
status.Postion[0]=96.940000
status.Postion[1]=4.260000
status.Postion[2]=13.653333
status.PresetID=8
status.TaskName=Manual
status.TrackStatus=Idle
status.ZoomMapValue=9045
status.ZoomStatus=Idle
status.ZoomValue=310
 
Top