IT科技

當前位置 /首頁/IT科技 > /列表

onvif,java

<link rel="stylesheet" href="https://js.how234.com/third-party/SyntaxHighlighter/shCoreDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><script type="text/javascript"> SyntaxHighlighter.all(); </script>

java onvif是什麼,讓我們一起了解一下?

ONVIF規範描述了網絡視頻的模型、接口、數據類型以及數據交互的模式。並複用了一些現有的標準,如WS系列標準等。ONVIF規範的目標是實現一個網絡視頻框架協議,使不同廠商所生產的網絡視頻產品(包括攝錄前端、錄像設備等)完全互通。

java 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());// 獲取tokenList profiles = nvt.getDevices().getProfiles();for (Profile profile : profiles) {System.out.println("profile==" + profile);}String profileToken = profiles.get(0).getToken(); // PROFILE_000// 設置StreamSetupStreamSetup 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_000StreamSetup 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();}

TAG標籤:java onvif #