目前只是做到实现旋转,相关的参数还要根据需求仔细研究,代码如下:
MediaProfile[] profiles = null;
DeviceClient device = new DeviceClient(binding, new EndpointAddress(deviceUri.ToString()));
DeviceService.Service[] services = device.GetServices(false);
DeviceService.Service xmedia2 = services.FirstOrDefault(s => s.Namespace == "http://www.onvif.org/ver20/media/wsdl");
if (xmedia2 != null)
{
Media2Client media = new Media2Client(binding, new EndpointAddress(deviceUri.ToString()));
media.ClientCredentials.HttpDigest.ClientCredential.UserName = "";
media.ClientCredentials.HttpDigest.ClientCredential.Password = "";
media.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
profiles = media.GetProfiles(null, null);
}
PTZClient pTZClient = new PTZClient(binding, new EndpointAddress(deviceUri.ToString()));
pTZClient.ClientCredentials.HttpDigest.ClientCredential.UserName = "";
pTZClient.ClientCredentials.HttpDigest.ClientCredential.Password = "";
pTZClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
PTZService.PTZNode[] nodeList = pTZClient.GetNodes();
PTZVector translation = new PTZVector();
translation.PanTilt = new PTZService.Vector2D() { x = 0.5f, y = 1.0f, space = "http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace" };
translation.Zoom = new PTZService.Vector1D() { x = 1.0f, space = "http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace" };
PTZSpeed speed = new PTZSpeed();
speed.PanTilt = new PTZService.Vector2D() { x = 0.5f, y = 0.5f, space = "http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace" };
speed.Zoom = new PTZService.Vector1D() { x = 0.5f, space = "http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" };
pTZClient.RelativeMove(profiles[0].token, translation, speed);
鉴权就不写了,根据自己球机的登录账密填上去就可以了