norihiro / obs-face-tracker

Face tracking plugin for OBS Studio
GNU General Public License v2.0
342 stars 29 forks source link

Custom option for PTZ controls #160

Open istvanmate opened 3 days ago

istvanmate commented 3 days ago

Source/filter types

Is your feature request related to a problem? Please describe. No.

Describe the solution you'd like We are using low budget HikVision PTZ cameras. They accept HTTP PUT commands for PTZ controls. Example (in PowerShell):

$url = "http://$ipaddress/ISAPI/PTZCtrl/channels/1/continuous"
$buffer = $wc.UploadString($url, "PUT", '<?xml version: "1.0" encoding="UTF-8"?><PTZData><pan>'+$pan+'</pan><tilt>'+$tilt+'</tilt><zoom>'+$zoom+'</zoom></PTZData>')

$pan, $tilt is the camera speed -100..+100 (we us speeds up to 15). $zoom is -3..+3 (we basically use -1, +1). 0 is stop.

Describe alternatives you've considered There are no alternatives at this moment, other than buying tracking capable camera.

Additional context

Authentication is required:

$wc = [System.Net.WebClient]::new()
$wc.Credentials = new-object System.Net.NetworkCredential("username", (New-Object System.Management.Automation.PSCredential -ArgumentList "username", (ConvertTo-SecureString -AsPlainText -Force "password")).GetNetworkCredential().Password)
norihiro commented 3 days ago

Could you point a spec document describing the protocol such as the XML schema for the PUT request?

Or, do you think it is a good idea to implement this plugin to call a power-shell script every time changing the PTZ control?

istvanmate commented 3 days ago

I could not find a protocol document at that time, I reverse engineered via developer tools. We use PowerShell as a proxy, because of CORS. Direct access from the plugin will not require a proxy. The PUT request is an XML to the following URL:

http://username:password@ip.address/ISAPI/PTZCtrl/channels/1/continuous

The following XML starts turning camera left with speed of 1:

<?xml version: "1.0" encoding="UTF-8"?><PTZData><pan>-1</pan><tilt>0</tilt><zoom>0</zoom></PTZData>

The following XML starts tilting the camera down with speed of 3:

<?xml version: "1.0" encoding="UTF-8"?><PTZData><pan>0</pan><tilt>-3</tilt><zoom>0</zoom></PTZData>

The following XML starts moving the camera up and right with speed of 2:

<?xml version: "1.0" encoding="UTF-8"?><PTZData><pan>2</pan><tilt>2</tilt><zoom>0</zoom></PTZData>

Zoom is very basic, it has 3 speeds, and the speed of 1 is already pretty fast. Nevertheless, the following XML starts zooming the camera in:

<?xml version: "1.0" encoding="UTF-8"?><PTZData><pan>0</pan><tilt>0</tilt><zoom>1</zoom></PTZData>

The following XML stops camera movement:

<?xml version: "1.0" encoding="UTF-8"?><PTZData><pan>0</pan><tilt>0</tilt><zoom>0</zoom></PTZData>