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

How to realize the Control of Qt Onvif head

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "how to achieve Qt Onvif head control". 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 how to achieve Qt Onvif head control.

I. Preface

Head control is also the most commonly used in the onvif function, the most commonly used function is to get the video stream address, the second is the head control, the meaning of the head control is to move the camera with the head up and down, generally the head camera has a small motor, once it receives the correct instructions from 485 or the network, it will trigger the single-chip microcomputer program. Then the single-chip microcomputer program drives the motor to rotate, so relatively speaking, the head camera consumes more power than the ordinary camera, and of course the price is more expensive.

In addition to the user information, the sending command of the head control mainly has three core parameters xyz. Through the combination of these three parameters to realize the control of the head and the focal length, the rotation of the head is mainly to change the value of xy, and the control of the focal length is realized by changing the value of z.

Head control instructions:

The ranges of x, y, z are all between 0 and 1.

If x is negative, it means turning left, and if x is positive, it means turning right.

If y is negative, it means going down; if y is positive, it means going up.

Z is positive, which means closer, z is negative, which means farther away.

Through the combination of x and y, the control of the head is realized.

Through the combination of z, the focal length control is realized.

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 void frmPtz::moveAbsolute () {OnvifDevice * device = frm- > getCurrentDevice (); if (device) {QString profile = frm- > getProfile (); device- > moveAbsolute (profile, x, y, z); frm- > append (5, QString ("perform absolute movement-> x:% 1 y:% 2 z:% 3") .Arg (x) .arg (y) .arg (z)) }} void frmPtz::moveRelative () {OnvifDevice * device = frm- > getCurrentDevice (); if (device) {QString profile = frm- > getProfile (); device- > moveRelative (profile, x, y, z); frm- > append (5, QString ("perform relative movement-> x:% 1 y:% 2 z:% 3") .Arg (x) .arg (y) .arg (z)) }} void frmPtz::setFrm (frmMain * frm) {this- > frm = frm;} void frmPtz::on_btnPtzUp_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0.0; y = 0.1; z = 0.0; moveRelative ();} else {y = 0.1; moveAbsolute () }} void frmPtz::on_btnPtzDown_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0. 0; y =-0.1; z = 0. 0; moveRelative ();} else {y =-0. 0; moveAbsolute () }} void frmPtz::on_btnPtzLeft_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x =-0.1; y = 0; z = 0; moveRelative ();} else {x = 0. 0; moveAbsolute ();}} void frmPtz::on_btnPtzRight_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0.1 Y = 0. 0; z = 0. 0; moveRelative ();} else {x = 0.1; moveAbsolute ();}} void frmPtz::on_btnPtzLeftUp_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x =-0.1; y = 0.1; z = 0. 0; moveRelative () } else {x = 0; y = 0; moveAbsolute ();}} void frmPtz::on_btnPtzLeftDown_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x =-0.1; y =-0.1; z = 0.0; moveRelative ();} else {x = 0.1; y = 0.1 MoveAbsolute ();}} void frmPtz::on_btnPtzRightUp_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0.1; y = 0.1; z = 0. 0; moveRelative ();} else {x = 0. 0; y = 0; moveAbsolute () }} void frmPtz::on_btnPtzRightDown_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0.1; y =-0.1; z = 0.0; moveRelative ();} else {x = 0.1; y = 0.1; moveAbsolute () }} void frmPtz::on_btnPtzZoomIn_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0; y = 0; z = 0.01; moveRelative ();} else {z = 0.01; moveAbsolute ();}} void frmPtz::on_btnPtzZoomOut_clicked () {if (ui- > rbtnMoveRelative- > isChecked ()) {x = 0.0 Y = 0; z =-0.01; moveRelative ();} else {z = 0. 0; moveAbsolute ();}} void frmPtz::on_btnPtzStop_clicked () {OnvifDevice * device = frm- > getCurrentDevice (); if (device) {frm- > setText ("ptzStop"); QString profile = frm- > getProfile (); device- > moveStop (profile) }} void frmPtz::on_btnPtzReset_clicked () {x = 0; y = 0; z = 0; moveAbsolute ();} Thank you for your reading, the above is the content of "how to achieve Qt Onvif head control". After the study of this article, I believe you have a deeper understanding of how to achieve Qt Onvif head control, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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