onvif云台控制,还有有点麻烦的,主要是不知道参数如何填写,通过接近一天的摸索,终于有点名目了。
我使用的是ContinuousMove这个api,介绍如下,网址https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl
ContinuousMove
Description:Operation for continuous Pan/Tilt and Zoom movements.
The operation is supported if the PTZNode supports at least one continuous Pan/Tilt or Zoom space.
If the space argument is omitted, the default space set by the PTZConfiguration will be used.
SOAP action:http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove
Input:
[ContinuousMove]ProfileToken [ReferenceToken]A reference to the MediaProfile.
Velocity [PTZSpeed]A Velocity vector specifying the velocity of pan, tilt and zoom.
PanTilt - optional; [Vector2D]Pan and tilt speed. The x component corresponds to pan and the y component to tilt. If omitted in a request, the current (if any) PanTilt movement should not be affected.
Zoom - optional; [Vector1D]
A zoom speed. If omitted in a request, the current (if any) Zoom movement should not be affected.
Timeout - optional; [duration]An optional Timeout parameter.
Output:
[ContinuousMoveResponse]
此API可以实现云台的上、下、左、右 以及拉近,拉远。
速度调整使用的是类Vector2D ,此类有两个参数,x 和y 范围都在0 ---1之间,x为负数,表示左转,x为正数,表示右转,
y为负数,表示下转,y为正数,表示上转。 通过x和y的组合,来实现云台的控制。
拉近和拉远通过Vector1D,此类有一个参数x 范围也在0--1之间 x为正数表示拉近,x为负数,表示拉远。
另外,x 和y的绝对值越接近1,表示云台的速度越快。
onvif预制位控制 使用的是GotoPreset函数,速度调整还是Vector2D类,和前面一样。预制位设置需要获取全部预制位信息,
具体实现如下
PTZPreset[] presets = ptzClient.GetPresets(MmProfiles[0].token);
if (presets.Length >= presetNumber)
{
var presetToken = presets[presetNumber - 1].token;
ver20Ptz.PTZSpeed velocity = new ver20Ptz.PTZSpeed()
{
PanTilt = vector2D
};
ptzClient.GotoPreset(MmProfiles[0].token, presetToken, velocity);
}
onvif的预置位的属性
name代表预置位的名字,token代表预置位的序号。看如下截图就能明白他们之间的对应关系。
另外,为了方便大家学习,通过vs2017编写的demo如下链接。C#实现。