我正在使用ONVIF协议来控制IP摄像头.目前只能用不同的相机控制变焦。我使用的是wsdl https://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl,,它尝试了ContinuousMove和RelativeMove功能,但在不同的相机上以不同的方式工作。
ContinuousMove函数取速度和超时值,RelativeMove函数取矢量和速度。
也就是说,第一台相机在ContinousMove上工作得很好,但是对于RelativeMove,它总是使用最大/最小的变焦,反之亦然。没有尝试AbsoluteMove,因为我找不到获得当前缩放值的方法。无法找到通用的方法来控制变焦对多个相机,寻求您的帮助。
任何建议都会有帮助,如果需要的话我会提供源代码。
发布于 2020-08-26 13:21:23
利用GetStatus获取电流变焦值,再用AbsoluteMove进行控制,解决了这一问题。有一个源代码:
public void StartZoom (Direction direction)
{
if (zoomEnabled_)
{
var ptzStatus_ = ptzClient_.GetStatus(profile_.token);
moveVector_.PanTilt = ptzStatus_.Position.PanTilt;
moveVector_.Zoom = ptzStatus_.Position.Zoom;
var zoomSpace = options_.Spaces.AbsoluteZoomPositionSpace;
var minZoom = zoomSpace[0].XRange.Min;
var maxZoom = zoomSpace[0].XRange.Max;
moveVelocity_.Zoom.x = 0;
if (direction.HasFlag(Direction.ZoomIn))
{
if (ptzStatus_.Position.Zoom.x + 1 / 20F <= maxZoom)
{
moveVelocity_.Zoom.x = velocityZoomIn_;
moveVector_.Zoom.x += 1 / 20F;
}
else
{
moveVector_.Zoom.x = maxZoom;
}
}
else if (direction.HasFlag(Direction.ZoomOut))
{
if (ptzStatus_.Position.Zoom.x - 1 / 20F >= minZoom)
{
moveVelocity_.Zoom.x = velocityZoomOut_;
moveVector_.Zoom.x -= 1 / 20F;
}
else
{
moveVector_.Zoom.x = minZoom;
}
}
ptzClient_.AbsoluteMove(profile_.token, moveVector_, moveVelocity_);
}
}https://stackoverflow.com/questions/63593264
复制相似问题