PTZ integration.

Hi all, we need to implement PTZ on our SDK based project, but it seems to be quite limited.

XProtect Web Client uses some simple API, with just the command provided as parameter “ptzMove”:

<?xml version="1.0" encoding="utf-8"?>
<Communication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<ConnectionId>72b5eda7-4d63-4c0b-864c-d83f856e551b</ConnectionId>
	<Command SequenceId="400">
		<Type>Request</Type>
		<Name>ControlPTZ</Name>
		<InputParams>
			<Param Name="CameraId" Value="f10b6b6f-5a40-4c7f-8bc1-00e0d1a9937f" />
			<Param Name="PtzMove" Value="Right" />
		</InputParams>
	</Command>
</Communication>

this seems to move the camera of just some degrees.

We need to implement a fast move(eg. “Move Left of 20 degress at maximum speed”) or “point & click” move, ie. “move the camera centering on the clicked point”.

We haven’t been able to detect a Web Service / Native C# API to perform this movements, in order to reproduce XProtect Smart Client behaviour, and its superior PTZ control compared to XProtect Web Client.

Are this functions provided?

How can call/integrate them?

Thanks for support.

I was ready to answer the day before yesterday, but I hesitated and checked with a Milestone developer. This was lucky because new functionality was introduced in XProtect Mobile Server 2016 R2 (which release yesterday). Up until then there was nothing better than what you already saw.

The ControlPTZ command has been extended with new parameters.

-–

Swipe – it is used to change the camera orientation by moving it in the direction of the swipe. The swipe direction and length are calculated based on the start and end points of the gesture. The swipe speed is calculated based on the time it took to perform the gesture from the start point to the end point. The calculated direction defines the direction of the PTZ movement, whereas the length and the speed are used to determine the amount of the PTZ movement.

RequestName: ControlPTZ

InputParams: {“Type”: “Swipe”, “CameraId”: cameraID, “GestureXPercent”: x, “GestureYPercent”: y, “GestureDuration”: duration}

            GestureYPercent, GestureYPercent – the percentage of distance between start and finish \[-100:100\]

            GestureDuration – the duration between start and finish (milliseconds)

-–

Tap-and-hold – it is used to change the camera orientation by moving it in the direction of the tap. The reference point of the movement is the center of the screen. The tap and the reference points are used to calculate the direction and the speed of the camera movement.

RequestName: ControlPTZ

InputParams: {“Type”: “TapAndHold”, “CameraId”: cameraID, “GestureXPercent”: x, “GestureYPercent”: y, "GestureTimeout”: timeout}

            GestureXPercent, GestureYPercent – the percentage of distance between center of screen and touched point \[-100:100\]

            GestureTimeout – max delay between ptz move commands if there are no new commands after this gesture timeout the server stops the ptz movement. 2000 is max but I'm not sure.(milliseconds)

-–

This is intended for mobile usage, you should play around with the parameters in order to see what is the actual behavior and if this going to work for you.

Remember that you must upgrade if you want to use the new parameters.

Hi Bo, does this new parameter ‘tap-and-hold’ support zoom? What will be the InputParams like?

The gesture zoom (pinch zoom) is implemented with the standard command described in the original question, where PtzMove is either ZoomIn or ZoomOut:

or

If I need to implement ‘press-and-hold’ for both ZoomIn and ZoomOut on mouse-press and mouse-release events, instead of mouse-click, the standard PtzMove does not allow that as it is based on mouse-click.

Will the “tap-and-hold” in new XProtect Mobile Server 2016 R2 has such functionality?

The answer is that currently Milestone Mobile Server doesn’t support continuous zoom, but it can be mimicked for the purpose of press-and-hold by initializing an interval (with setInerval()) on mouse down, which sends every second or so:

or

And then clear the interval on mouse up.

I tried to integrate with a Milestone-compliant video encoder and have encountered that for under Pelco-D protocol, the video encoder triggers a zoom-in command and followed by a stop command.

I need the video encoder to trigger a zoom-in command only on mouse down and trigger a stop command on mouse up.

Wiill setInterval() on mouse down help? How is it done? I cannot find any milestone reference/example on this.

As explained in the previous reply – “Milestone Mobile Server doesn’t support continuous zoom, but it can be mimicked for the purpose of press-and-hold by initializing an interval (with setInerval()) on mouse down, which sends every second or so.”

About setInterval():

setInterval() is part of the JavaScript API and is used to trigger repeatedly (every X milliseconds) a block of code. The zoom command should be put in that block of code, to be fired repeatedly while the mouse button is held down.

Does it make sense? There is no sample on this.