0
votes

I am using ONVIF protocol to control IP-cameras. Currently got stuck on zoom controlls with different cameras. I am using PTZBinding wsdl [https://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl], tried ContinuousMove and RelativeMove fucntions, but it apperars to work in different ways on different cameras.

ContinuousMove function takes velocity and timeout, RelativeMove function takes vector and velocity.

I. e., first camera works perfect with ContinousMove, but with RelativeMove it always apply maximum/minimus zoom, and vice versa with second camera. Didn't try AbsoluteMove because I can't find way to get current zoom value. Can't find universal method to control zoom on multiple cameras, asking for your help.

Any advices will be helpful, I will provide source code if needed.

1

1 Answers

0
votes

Solved this problem by getting current zoom value with GetStatus and then controlling using AbsoluteMove. There is a source code:

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_);
      }
    }