Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Qt Onvif network setting method?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the Qt Onvif network setting method". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the Qt Onvif network setting method".

I. Preface

Using the onvif protocol to obtain and set the network information of the device, this operation is rarely used in many NVR products, and most users are used to configuring directly through the web page of the camera. In fact, the function of modifying the network configuration is available in most NVR. Network parameters mainly include IP address, subnet mask, gateway address, DNS parsing address, NTP address, network card information, network protocol and so on. These can be obtained and set through different onvif commands. It has not been understood why these should be dealt with separately by different commands. In fact, they can be merged into one command, so that setting up network information requires post data for many times.

By grabbing packets, it is found that the commands for obtaining these network parameters are basically similar, except for the authentication header data, there is a keyword in the middle, so in order to maximize the reuse of the code, the general post data and parsing data are integrated into one function, and different keywords are passed in for processing.

The main functions of onvif:

Search for equipment and get information about the equipment, such as manufacturer, model, etc.

Get multiple profile information profile for the device.

Get parameters such as video stream address rtsp and resolution of the corresponding configuration file.

Head control, moving up and down, left and right, focal length magnified and reduced, relative and absolute movement.

Get the preset information and trigger the preset.

Subscribe to events and receive all kinds of messages from the device, especially alarm events such as the alarm of the IO port.

Capture the picture to get the current picture of the device.

Get, create, and delete user information.

Get and device network configuration information such as IP address.

Gets and sets NTP time synchronization and sets device time.

Gets and sets video and picture parameters (brightness, color, saturation).

Restart the device.

The processing flow of onvif:

Bind a multicast IP (239.255.255.250) and a port (3702) to send a data search device in a fixed xml format.

The received data is parsed in xml format to get the Onvif address of the device.

Send the corresponding data to the Onvif address, receive the data and take out the corresponding node data.

Request Onvif address to obtain Media address and Ptz address. Media address is used to obtain detailed configuration files, and Ptz address is used for cloud control.

Ptz control is to send the corresponding data to the Ptz address.

Set up the need for user authentication to organize the user token information to be sent together, and each time it needs to be authenticated.

The data received is not standard xml data and can not be processed according to normal node parsing, so it can only be done with QXmlQuery.

The data returned by each manufacturer's equipment may not be completely consistent, but they are basically inconsistent, so it is necessary to fuzzy find the node value.

Specially uses the underlying protocol parsing, because soap is too bloated and the function name is too alternative, so it is specially lightweight.

Two must-have tools, Onvif Device Manager and Onvif Device Test Tool.

II. Functional features

Broadcast search equipment, support IPC and NVR, return in turn, you can choose different network card IP.

Get the Onvif address, Media address, Profile file, and Rtsp address in turn.

The video stream Rtsp address, such as the main stream substream address, can be obtained for the specified Profile.

Onvif user information can be set for each device, which can be used for authentication to obtain details.

Camera images can be previewed in real time.

Support head control, adjust head up and down, left and right, support absolute movement and relative movement, you can put and reduce the distance of the image.

Any Qt version of Qt4 and Qt5 is supported, and Qt4.7.0 to Qt5.14.2 is tested.

Support any compiler, test mingw, msvc, gcc, clang.

Support any operating system, test xp, win7, win10, android, linux, embedded linux, raspberry pie H3, etc.

Support any Onvif camera and NVR, test Haikang, Dahua, Yushi, Huawei, Hayes chip cores, etc., can be customized and developed.

Unicast search for specified IP addresses and onvif addresses is supported, for example, in the case of cross-network segments.

Support to specify filter criteria to filter search devices.

Support the search interval setting to ensure that all devices are searched back, which is very useful in a large number of equipment sites.

The picture parameters (brightness, color, saturation) can be set.

Support NTP timing and time synchronization settings.

Written by pure Qt, super compact and lightweight, a total of about 2000 lines of code, does not rely on any third-party libraries and components, cross-platform.

Encapsulated the general functions of data sending and receiving parsing, it is very convenient to expand other Onvif processing.

The sending and receiving data text box is provided on the tool to display the sending and receiving data, which is convenient for viewing and analysis.

Support all Onvif devices, neat code, friendly interface, directly introduced into pri can be used.

Third, effect picture

4. Core code QString OnvifOther::writeData (const QString & key, const QString & value, const QString & flag, bool xmlns, bool value4, quint8 type) {if (device- > deviceUrl.isEmpty ()) {return QString ();} QString file = device- > request- > getSendData (key, true, xmlns); QByteArray dataSend = file.toUtf8 () / / the final parameter indicates that the timeout is usually very fast, unless the other party is not online, the card needs to set the timeout QNetworkReply * reply = device- > request- > post (device- > deviceUrl, dataSend, 1000); emit sendData (dataSend, device- > deviceUrl); QStringList results; QByteArray dataReceive; bool ok = device- > checkData (reply, dataReceive, flag); if (ok) {OnvifQuery query; query.setData (dataReceive) If (type = = 0) {if (! value.isEmpty ()) {/ / there may be multiple keywords to get QStringList list = value.split ("|"); foreach (QString str, list) {QString result = value4? Query.getValue4 (str): query.getValue3 (str); if (result! = "- 1") {results

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report