通过WSDiscovery、camera_discovery库广播发现局域网内网络设备(打印机、摄像头)的案例
局域网内快速检索在线的网络设备,并快速获得要的数据
pip3 install WSDiscovery
pip3 install camera_discovery
检索局域网内摄像机,并获得rtsp地址
import CameraDiscovery
camera_ip = CameraDiscovery.ws_discovery()
print(camera_ip)
camera = CameraDiscovery.CameraONVIF(camera_ip[0], "admin", "admin")
camera.camera_start()
rtsp_str = camera.get_rtsp()
print(rtsp_str)
检索在线网络设备
from wsdiscovery.discovery import ThreadedWSDiscovery as WSDiscovery
from wsdiscovery.publishing import ThreadedWSPublishing as WSPublishing
from wsdiscovery import QName, Scope
# Define type, scope & address of service
ttype1 = QName("http://www.onvif.org/ver10/device/wsdl", "Device")
scope1 = Scope("onvif://www.onvif.org/Model")
xAddr1 = "localhost:8080/abc"
# Publish the service
wsp = WSPublishing()
wsp.start()
wsp.publishService(types=[ttype1], scopes=[scope1], xAddrs=[xAddr1])
# Discover it (along with any other service out there)
wsd = WSDiscovery()
wsd.start()
services = wsd.searchServices()
for service in services:
print(service.getEPR() + ":" + service.getXAddrs()[0])
wsd.stop()
版权说明
本文地址:http://www.liuyangdeboke.cn/?post=11
未标注转载均为本站远程,转载请注明文章出处:
发表评论