Java整合ONVIF云台控制获取RTPM流地址,控制摄像机左右上下角度

Java整合ONVIF云台控制获取RTPM流地址,控制摄像机左右上下角度

效果如下

在这里插入图片描述

搜索发现设备 获取设备信息 转动摄像头 提供两种方式

  1. 第一种main方法里直接发现设备获取到设备ip获取流地址或者转动摄像头。
List<OnvifPointer> 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<Profile> 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);
  1. 第二种直接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<Profile> 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();

		}

源码连接:https://download.csdn.net/download/qq_42459147/85601083
如果过期请加扣扣:1500203050

  • 4
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值