java onvif是什么,让我们一起了解一下?
ONVIF规范描述了网络视频的模型、接口、数据类型以及数据交互的模式。并复用了一些现有的标准,如WS系列标准等。ONVIF规范的目标是实现一个网络视频框架协议,使不同厂商所生产的网络视频产品(包括摄录前端、录像设备等)完全互通。
实战操作:
Java如何整合ONVIF云台控制获取RTPM流地址,控制摄像机左右上下角度?
搜索发现设备获取设备信息转动摄像头提供两种方式:
第一种main方法里直接发现设备获取到设备ip获取流地址或者转动摄像头。
List onvifPointer = OnvifDiscovery.discoverOnvifDevices();
for (OnvifPointer ref : onvifPointer) {
System.out.println(ref.toString());
System.out.println("设备地址:" + ref.getAddress());
System.out.println("设备名:" + ref.getName());
System.out.println("设备:" + ref.getOnvifDevice());
System.out.println(ref.getSnapshotUrl());
}
OnvifDevice nvt = onvifPointer.get(0).getOnvifDevice();
// 获取设备信息
GetDeviceInformationResponse deviceInformation = nvt.getDevices().getDeviceInformation();
System.out.println("设备制造商: " + deviceInformation.getManufacturer());
System.out.println("设备模型: " + deviceInformation.getModel());
System.out.println("设备固件版本: " + deviceInformation.getFirmwareVersion());
System.out.println("设备序列号: " + deviceInformation.getSerialNumber());
System.out.println("设备硬件id: " + deviceInformation.getHardwareId());
// 获取token
List profiles = nvt.getDevices().getProfiles();
for (Profile profile : profiles) {
System.out.println("profile==" + profile);
}
String profileToken = profiles.get(0).getToken(); // PROFILE_000
// 设置StreamSetup
StreamSetup streamSetup = new StreamSetup();
Transport transport = new Transport();
transport.setProtocol(TransportProtocol.UDP);
streamSetup.setStream(StreamType.RTP_UNICAST);
streamSetup.setTransport(transport);
// 获取流地址
String getStreamUri = nvt.getMedia().getStreamUri(profileToken, streamSetup);
System.out.println("getStreamUri:" + getStreamUri);
// 获取视频参数
String videoSourceToken = profiles.get(0).getVideoSourceConfiguration().getSourceToken();
System.err.println("videoSourceToken=====" + videoSourceToken);
ImagingSettings20 imagingSettings20 = nvt.getImaging().getImagingSettings(videoSourceToken);
System.err.println(imagingSettings20.getBacklightCompensation().getMode());
// 设置视频参数上下转动
nvt.getPtz().continuousMove(profileToken, -1, 1, 1);
nvt.getPtz().stopMove(profileToken);第二种直接ip地址和用户名密码获取流地址或者转动摄像头。
try {
OnvifDevice nvt = new OnvifDevice nvt = new OnvifDevice("192.168.1.200:80", "admin","admin");
// 获取设备信息
GetDeviceInformationResponse deviceInformation = nvt.getDevices().getDeviceInformation();
System.out.println("设备制造商: " + deviceInformation.getManufacturer());
System.out.println("设备模型: " + deviceInformation.getModel());
System.out.println("设备固件版本: " + deviceInformation.getFirmwareVersion());
System.out.println("设备序列号: " + deviceInformation.getSerialNumber());
System.out.println("设备硬件id: " + deviceInformation.getHardwareId());
List profiles = nvt.getDevices().getProfiles();
for (Profile profile : profiles) {
System.out.println("dddd==" + profile);
}
String profileToken = profiles.get(0).getToken(); // PROFILE_000
StreamSetup streamSetup = new StreamSetup();
Transport transport = new Transport();
transport.setProtocol(TransportProtocol.UDP);
streamSetup.setStream(StreamType.RTP_UNICAST);
streamSetup.setTransport(transport);
// 获取流地址
String getStreamUri = nvt.getMedia().getStreamUri(profileToken, streamSetup);
System.out.println("getStreamUri:" + getStreamUri);
// 获取视频参数
String videoSourceToken = profiles.get(0).getVideoSourceConfiguration().getSourceToken();
System.err.println("videoSourceToken=====" + videoSourceToken);
ImagingSettings20 imagingSettings20 = nvt.getImaging().getImagingSettings(videoSourceToken);
System.err.println(imagingSettings20.getBacklightCompensation().getMode());
// 设置视频参数上下转动
nvt.getPtz().absoluteMove(profileToken, 0, 0, 0.5f);
// nvt.getPtz().stopMove(profileToken);
// System.err.println(nvt.getPtz().getPresets(profileToken));
} catch (ConnectException e) {
System.err.println("Could not connect to NVT.");
} catch (SOAPException e) {
e.printStackTrace();
}以上就是小编今天的分享了,希望可以帮助到大家。