Reputation: 318
I'm trying to control a PTZ camera with the http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl file.
I can use the GotoPreset function without a problem but the ContinuousMove function throws an ProtocolException.
Page 77 of this guide shows an example of how the ConinuousMove function should be used.
Following this guide provided me with the following code:
OnvifMediaClient.Profile[] profs = this.mediaClient.GetProfiles();
OnvifMediaClient.Profile profile = mediaClient.GetProfile(profs[0].token);
OnvifPTZ.PTZConfigurationOptions options = PtzClient.GetConfigurationOptions(profile.token);
OnvifPTZ.PTZSpeed velocity = new OnvifPTZ.PTZSpeed();
velocity.PanTilt = new OnvifPTZ.Vector2D();
velocity.Zoom = new OnvifPTZ.Vector1D();
velocity.PanTilt.x = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max;
velocity.PanTilt.y = options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max;
velocity.PanTilt.space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI;
velocity.Zoom.x = options.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max;
velocity.Zoom.space = options.Spaces.ContinuousZoomVelocitySpace[0].URI;
PtzClient.ContinuousMove(profile.token, velocity, "1000");
Thread.Sleep(2000);
PtzClient.Stop(profile.token, true, true);
But there are some differences with the code in the guide, for example the actual ContinuousMove function requires 3 parameters in my code instead of 2 as in the guide. The extra parameter is a timeout so i think that won't make that much difference but maybe some other things are different that cause my code to fail.
I dit read the awnser of this question in wich the person said the PTZ camera didn't support the ver20. But when I add a service reference to the wsdl with ver20 changed to ver10 I get a message that adding the wsdl failed because it contains links that could not be resolved. Also when i paste the ver10 url (http://www.onvif.org/onvif/ver10/ptz/wsdl/ptz.wsdl) in my webbrowser it shows an xml instead of an wsdl.
How can I use the right wsdl file if i'm not using it already or what could resolve the behaviour in my current setup?
Upvotes: 4
Views: 8698
Reputation: 318
I found a solution.
It turns out I misunderstood the timeout parameter in PtzClient.ContunuousMove. In the previous wsdl version (ver10) you had to call the Stop function everytime you wanted the current PTZ action to stop. In ver20 of the wsdl the PTZ function (unless the Stop function is called) will last as long as specified in the timeout parameter. I thought it was a response timeout or something but it's not.
Calling ContinuousMove now looks like this:
PtzClient.ContinuousMove(profile.token, velocity, "PT1S");
Where the number in the string stands for the amount of seconds the PTZ action should last.
Hope it helps someone.
Upvotes: 5