C# ONVIF协议PTZ控制球机学习

目前只是做到实现旋转,相关的参数还要根据需求仔细研究,代码如下:

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

鉴权就不写了,根据自己球机的登录账密填上去就可以了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Java实现ONVIFPTZ控制,可以按照以下步骤进行: 1. 首先,需要通过Java的网络编程技术连接到ONVIF设备。可以使用Java的Socket类库来建立网络连接。为此,需要知道ONVIF设备的IP地址和端口号。 2. 通过建立的网络连接,可以发送SOAP消息来实现PTZ控制ONVIF协议是基于SOAP的,使用SOAP消息来与设备进行通信。SOAP消息包含了控制云台的指令,比如移动、变焦、调亮度等。 3. 需要熟悉ONVIF协议中与PTZ相关的消息格式和内容。ONVIF协议定义了一系列用于设备管理和控制的消息结构。可以通过查阅ONVIF协议的文档来了解如何构建PTZ控制相关的消息。 4. 解析设备返回的响应消息,根据响应结果判断控制是否成功。设备会返回一个SOAP响应消息,其中包含了对控制指令的处理结果。可以使用Java的XML解析库来解析返回的SOAP响应消息。 5. 根据需要编写Java代码来完成PTZ控制的具体功能。可以通过构建合适的SOAP消息发送给设备,实现云台的移动、变焦、调光等操作。 6. 进行测试和调试,确保PTZ控制功能正常工作。可以通过编写简单的Java应用程序来测试PTZ控制功能,模拟用户对云台的操作。 需要注意的是,使用Java实现ONVIFPTZ控制需要熟悉ONVIF协议的相关内容,并了解SOAP消息的构成和解析过程。此外,还需要有一定的网络编程经验和Java编程能力。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值