1. 当前位置:网站首页 > Python

通过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()

本文最后更新于2022-6-28,已超过 3个月没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
版权说明

本文地址:http://www.liuyangdeboke.cn/?post=11
未标注转载均为本站远程,转载请注明文章出处:

发表评论

联系我们

在线咨询:点击这里给我发消息

微信号:17721538135

工作日:9:00-23:00,节假日休息

扫码关注