大华 海康 宇视 摄像头 onvif协议 调整时间 开发过程 整理

1、onvif官网 查看SetSystemDateAndTime 方法。

2、下载 ONVIF Device Test Tool 工具,使用教程可以 在这查看

3、根据Test Tool 工具生成的request进行 Send request 测试。

 有了这个本质就是http请求了,我认为可以自己写http请求尝试,我就不这样做了,直接找了个demo。

4、我用的demo不知道为什么宇视摄像头和海康、大华摄像头的请求xml不一样。

// 宇视
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +

                "    <tds:SetSystemDateAndTime xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tds=\"http://www.onvif.org/ver10/device/wsdl\" xmlns:tt=\"http://www.onvif.org/ver10/schema\">\n" +
                "      <tds:DateTimeType>Manual</tds:DateTimeType>\n" +
                "      <tds:DaylightSavings>false</tds:DaylightSavings>\n" +
                "      <tds:TimeZone>\n" +
                "        <tt:TZ>UTC+08:00</tt:TZ>\n" +
                "      </tds:TimeZone>\n" +
                "      <tds:UTCDateTime>\n" +
                "        <tt:Time>\n" +
                "          <tt:Hour>"+this.hour+"</tt:Hour>\n" +
                "          <tt:Minute>"+this.date.get(Calendar.MINUTE)+"</tt:Minute>\n" +
                "          <tt:Second>"+this.date.get(Calendar.SECOND)+"</tt:Second>\n" +
                "        </tt:Time>\n" +
                "        <tt:Date>\n" +
                "          <tt:Year>"+this.date.get(Calendar.YEAR)+"</tt:Year>\n" +
                "          <tt:Month>"+this.month+"</tt:Month>\n" +
                "          <tt:Day>"+this.date.get(Calendar.DAY_OF_MONTH)+"</tt:Day>\n" +
                "        </tt:Date>\n" +
                "      </tds:UTCDateTime>\n" +
                "    </tds:SetSystemDateAndTime>\n"
// 海康大华。注意时区,海康的时区设置不上,大华的时区设置有bug
"<SetSystemDateAndTime xmlns=\"http://www.onvif.org/ver10/device/wsdl\" xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tt=\"http://www.onvif.org/ver10/schema\">" +
                "                <tt:DateTimeType>Manual</tt:DateTimeType>\n" +
                "                <tt:DaylightSavings>false</tt:DaylightSavings>\n" +
                "                <tt:TimeZone>\n" +
                "                    <tt:TZ>UTC+00:00</tt:TZ>\n" +
                "                </tt:TimeZone>\n" +
                "                <tt:UTCDateTime>\n" +
                "                    <tt:Time>\n" +
                "                        <tt:Hour>"+this.hour+"</tt:Hour>\n" +
                "                        <tt:Minute>"+this.date.get(Calendar.MINUTE)+"</tt:Minute>\n" +
                "                        <tt:Second>"+this.date.get(Calendar.SECOND)+"</tt:Second>\n" +
                "                    </tt:Time>\n" +
                "                    <tt:Date>\n" +
                "                        <tt:Year>"+this.date.get(Calendar.YEAR)+"</tt:Year>\n" +
                "                        <tt:Month>"+this.month+"</tt:Month>\n" +
                "                        <tt:Day>"+this.date.get(Calendar.DAY_OF_MONTH)+"</tt:Day>\n" +
                "                    </tt:Date>\n" +

                "                </tt:UTCDateTime>"+
                "</SetSystemDateAndTime>";

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
可以使用开源的ONVIF Device Manager库来实现Spring Boot与Onvif协议的整合控制摄像头转动。 以下是实现步骤: 1. 在pom.xml文件中引入ONVIF Device Manager依赖: ```xml <dependency> <groupId>com.github.onvif</groupId> <artifactId>onvif-device-manager</artifactId> <version>${onvif.device.manager.version}</version> </dependency> ``` 2. 创建一个OnvifService类,用于调用Onvif Device Manager库的API: ```java @Service public class OnvifService { private static final Logger logger = LoggerFactory.getLogger(OnvifService.class); @Autowired private OnvifDeviceManager onvifDeviceManager; /** * 获取设备信息 * @param ipAddress 设备IP地址 * @param username 用户名 * @param password 密码 * @return 设备信息 * @throws ConnectException 连接异常 * @throws SOAPException SOAP异常 * @throws IOException IO异常 */ public OnvifDeviceInfo getDeviceInfo(String ipAddress, String username, String password) throws ConnectException, SOAPException, IOException { OnvifCamera onvifCamera = onvifDeviceManager.getOnvifCamera(ipAddress, username, password); if (onvifCamera == null) { return null; } return new OnvifDeviceInfo(onvifCamera.getHostname(), onvifCamera.getManufacturer(), onvifCamera.getModel(), onvifCamera.getFirmwareVersion()); } /** * 控制云台转动 * @param ipAddress 设备IP地址 * @param username 用户名 * @param password 密码 * @param tilt 垂直方向转动速度 * @param pan 水平方向转动速度 * @throws ConnectException 连接异常 * @throws SOAPException SOAP异常 * @throws IOException IO异常 */ public void move(String ipAddress, String username, String password, float tilt, float pan) throws ConnectException, SOAPException, IOException { OnvifCamera onvifCamera = onvifDeviceManager.getOnvifCamera(ipAddress, username, password); if (onvifCamera == null) { return; } OnvifPTZ ptz = onvifCamera.getPtz(); if (ptz == null) { return; } ptz.move(tilt, pan); } } ``` 3. 在Controller中注入OnvifService类,调用其API实现控制摄像头转动: ```java @RestController @RequestMapping("camera") public class CameraController { @Autowired private OnvifService onvifService; /** * 获取设备信息 * @param ipAddress 设备IP地址 * @param username 用户名 * @param password 密码 * @return 设备信息 */ @GetMapping("info") public OnvifDeviceInfo getDeviceInfo(String ipAddress, String username, String password) { try { return onvifService.getDeviceInfo(ipAddress, username, password); } catch (ConnectException | SOAPException | IOException e) { e.printStackTrace(); return null; } } /** * 控制云台转动 * @param ipAddress 设备IP地址 * @param username 用户名 * @param password 密码 * @param tilt 垂直方向转动速度 * @param pan 水平方向转动速度 */ @PostMapping("move") public void move(String ipAddress, String username, String password, float tilt, float pan) { try { onvifService.move(ipAddress, username, password, tilt, pan); } catch (ConnectException | SOAPException | IOException e) { e.printStackTrace(); } } } ``` 以上就是使用Spring Boot整合Onvif协议控制摄像头转动的实现步骤。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值