# onvif protocol
Simple management of onvif IP-devices cameras. onvif is an implementation of ONVIF protocol for managing onvif IP devices. The purpose of this library is convenient and easy management of IP cameras and other devices that support ONVIF standard.
## Installation
To install the library, use **go get**:
```go
go get github.com/use-go/onvif
```
## Supported services
The following services are implemented:
- Device
- Media
- PTZ
- Imaging
- Event
- Discovery
- Auth(More Options)
- Soap
## Using
### General concept
1) Connecting to the device
2) Authentication (if necessary)
3) Defining Data Types
4) Carrying out the required method
#### Connecting to the device
If there is a device on the network at the address *192.168.13.42*, and its ONVIF services use the *1234* port, then you can connect to the device in the following way:
```go
dev, err := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234"})
```
*The ONVIF port may differ depending on the device , to find out which port to use, you can go to the web interface of the device. **Usually this is 80 port.***
#### Authentication
If any function of the ONVIF services requires authentication, you must use the `Authenticate` method.
```go
device := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234", Username: "username", Password: password})
```
#### Defining Data Types
Each ONVIF service in this library has its own package, in which all data types of this service are defined, and the package name is identical to the service name and begins with a capital letter. onvif defines the structures for each function of each ONVIF service supported by this library. Define the data type of the `GetCapabilities` function of the Device service. This is done as follows:
```go
capabilities := device.GetCapabilities{Category:"All"}
```
Why does the `GetCapabilities` structure have the Category field and why is the value of this field `All`?
The figure below shows the documentation for the [GetCapabilities](https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl). It can be seen that the function takes one Category parameter and its value should be one of the following: 'All', 'Analytics',' Device ',' Events', 'Imaging', 'Media' or 'PTZ'`.
![Device GetCapabilities](docs/img/exmp_GetCapabilities.png)
An example of defining the data type of `GetServiceCapabilities` function in [PTZ](https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl):
```go
ptzCapabilities := ptz.GetServiceCapabilities{}
```
The figure below shows that `GetServiceCapabilities` does not accept any arguments.
![PTZ GetServiceCapabilities](docs/img/GetServiceCapabilities.png)
*Common data types are in the xsd/onvif package. The types of data (structures) that can be shared by all services are defined in the onvif package.*
An example of how to define the data type of the CreateUsers function in [Devicemgmt](https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl):
```go
createUsers := device.CreateUsers{User: onvif.User{Username:"admin", Password:"qwerty", UserLevel:"User"}}
```
The figure below shows that ,in this example, the `CreateUsers` structure field must be a User whose data type is the User structure containing the Username, Password, UserLevel, and optional Extension fields. The User structure is in the onvif package.
![Device CreateUsers](docs/img/exmp_CreateUsers.png)
#### Carrying out the required method
To perform any function of one of the ONVIF services whose structure has been defined, you must use the `CallMethod` of the device object.
```go
createUsers := device.CreateUsers{User: onvif.User{Username:"admin", Password:"qwerty", UserLevel:"User"}}
device := onvif.NewDevice(onvif.DeviceParams{Xaddr: "192.168.13.42:1234", Username: "username", Password: password})
device.Authenticate("username", "password")
resp, err := dev.CallMethod(createUsers)
```
## Great Thanks
Enhanced and Improved from: [goonvif](https://github.com/yakovlevdmv/goonvif)
我和这个世界
- 粉丝: 22
- 资源: 4616
最新资源
- 永磁同步电机(pmsm)模型预测控制(MPC)matla b simulink仿真模型,有PI矢量控制,直接预测控制(有限集模型预测控制)(这个其中包括做了单矢量和双矢量或者可以成为三矢量的有限集预测
- Google Chrome浏览器ChromeDriver驱动下载(Chrome版本:132.0.6834.84)win64
- Google Chrome浏览器ChromeDriver驱动下载(Chrome版本:132.0.6834.84)win32
- 从0到1搭建推荐系统 - 数据驱动的算法与架构设计(带数据集)
- 汇川H3U标准程序,程序有本体脉冲控制的三轴定位,有总线控制的汇川伺服定位,轴点动,回零,相对定位绝对定位,程序结构清晰,分模块控制,是工控者学习的好案例
- 从0到1搭建推荐系统 - 数据驱动的算法与架构设计(带数据集)
- S7-200Smart 恒压供水程序样例+485通讯样例
- 基于simulink三自由度汽车操纵模型(侧向,侧倾,横摆)带数据参数,有详细公式文档 具有特殊性,发出不 哦(高于或等于MATLAB 2016a版本的都可打开模型)
- C++编写,qt框架,windows串口调试助手,多线程运行,性能好,效率高,不丢数据,保证代码质量
- 从0到1搭建推荐系统 - 数据驱动的算法与架构设计(带数据集)
- . NET C# WPF图书管理系统源码 .net C# WPF图书管理系统源码 自己开发,纯源码 主要技术:C#、基于wpf开发、sql server数据库的增删改查 源码特点:代码完整规范,采
- 西门子Smart200和台达ⅤFD一M系列变频器通讯程序 Smart和三菱E700或D7O0变频器通讯程序,程序带注释,包括接线图纸,变频器参数设置,全都有,拿到即可以用,节约开发时间
- ofdm 水声通信 qpsk fpga
- COMSOL手性超材料文献模拟模型 计算左右旋圆偏振下的吸收、反射、透射率(材料参数未与文献一致 趋势吻合)
- 昆仑通态MCGS与3台力士乐VFC-x610变频器通讯程序 实现昆仑通态触摸屏与3台力士乐VFC-x610变频器通讯,程序稳定可靠 器件:昆仑通态TPC7062KD触摸屏,3台力士乐VFC-x610变
- Unity3d 基于UniStorm插件和xx天气API实现实时天气系统源码工程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论1