In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to achieve Qt onvif snapping pictures". In daily operation, I believe that many people have doubts about how to achieve Qt onvif snapping pictures. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to achieve Qt onvif snapping pictures". Next, please follow the editor to study!
I. Preface
In the past, I didn't know that onvif could also do capture function, until recently, when I re-tested with Onvif Device Test Tool tool, I found that there was still an interface for capturing images, so I ran and analyzed the data to be sent and received, and then added it to my encapsulated onvif operation class. This capture scenario has an application scenario that captures images directly through onvif after giving an alarm, without the need to open real-time video streams, which basically does not take up any resources.
The process of snapping pictures
Send GetSnapshotUri to get the screenshot path to the corresponding token.
Request this path through get. Note that it is recommended to bring user information here.
The returned data is the data of the picture, which can be loaded with QImage's loadFromData after receiving.
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.
Gets and sets the device time.
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
Supports multi-screen switching, full-screen switching, etc., including 1 "4" 6 "8" 9 "13" 16 "25" 36 "64 screen switching.
Support alt+enter full screen, esc exit full screen.
Custom message box + error box + inquiry box + prompt box in the lower right corner (including multiple formats).
17 sets of skin styles are changed at will, all styles are unified, including menus and so on.
The head dashboard mouse moves up to highlight, and eight directions are accurately identified.
The bottom screen toolbar (screen division switch + screenshot sound, etc.) is moved up to highlight.
You can change the logo+ Chinese software name + English software name in the upper left corner of the configuration file.
Encapsulated Baidu map, view switching, motion trajectory, equipment location, mouse press to obtain longitude and latitude and so on.
Support picture map, the device button can drag freely on the picture map to automatically save location information.
On Baidu Maps and Picture Maps, double-click the video to preview the camera real-time video.
Stack forms, each form is a separate qwidget, making it easy to write your own code.
Top right mouse button menu, can dynamically control the time CPU+ upper left corner panel + lower left corner panel + upper right corner panel + lower right corner panel show and hide, support to restore the default layout.
Toolbars can place multiple small icons and close icons.
The left side and the right side can be dragged and stretched, and the width and height position can be automatically remembered and restored after restart.
Double-click the camera node to automatically play the video, double-click the node to automatically add videos in turn, automatically jump to the next one, and double-click the parent node to automatically add all the videos under that node.
The camera node is dragged to the corresponding form to play the video, and the local file can be dragged to play directly.
The video screen form supports dragging and swapping and instant response.
Double-click the node + drag the node + drag the form to change the position, and the url.txt is automatically updated.
Support loading channel video playback from url.txt, automatically memorizing the video corresponding to the last channel, and automatically opening and playing after the software starts.
Lower right corner volume bar control, lose focus automatically hide, volume bar with mute icon.
Integrate Baidu online map and offline map, you can add the corresponding location of the device, automatically generate the map, support zooming and adding coverings and so on.
Drag the video out of the channel form to automatically delete the video.
The right mouse button can delete the current + all videos and take screenshots of current + all videos.
Video recorder management, camera management, you can add, delete, modify, import and export print information, and immediately apply new equipment information to generate a tree list without restarting.
In the pro file, you are free to open or load the map.
Video playback can be switched freely by two kernels, vlc+ffmpeg, both of which can be set in pro.
You can set 1 "4" 9 "16 screen polling, you can set the polling interval and the polling stream type, etc. Click the start polling button on the right side of the toolbar at the bottom of the main interface, and click stop polling again.
By default, the mouse pointer is automatically hidden without operation for more than 10 seconds.
Support onvif search equipment, support any onvif camera, including but not limited to Haikang Dahuayu Shitian Weiye Huawei and so on.
Support onvif pan control, can move the head camera up and down, including reset and focal length adjustment, etc.
It also supports sqlite, mysql, postsql and other databases.
Can save video, can be selected for storage or single file storage, optional storage interval.
The video stream communication mode tcp+udp can be set, and the video decoding can be set as speed priority, quality priority, balance and so on.
Can set hard decoding type, support qsv, dxva2, d3d11va and so on.
Opengl is used by default to draw video, ultra-low CPU resource consumption, support for yuyv and nv12 two formats to draw, very powerful.
Highly customizable, users can easily derive their own functions on this basis, supporting linux and mac systems.
Third, effect picture
4. Core code QString OnvifDevice::getSnapshotUri (const QString & profileToken) {QString file = OnvifHelper::getFile (": / send/getSnapshotUri.xml"); file = file.arg (request- > getUserToken ()) .arg (profileToken); QByteArray dataSend = file.toUtf8 (); QNetworkReply * reply = request- > post (mediaUrl, dataSend); emit sendData (dataSend, mediaUrl); QByteArray dataReceive; bool ok = checkData (reply, dataReceive, "request Screenshot") If (ok) {OnvifQuery query; query.setData (dataReceive); snapUrl = query.getSnapUrl (); if (! snapUrl.isEmpty ()) {/ / add user authentication, emit receiveInfo (snapUrl) that also needs authentication to take pictures; QString userInfo = QString ("http://%1:%2@").arg(userName).arg(userPwd); SnapUrl = snapUrl.replace ("http://", userInfo);}} return snapUrl;} QImage OnvifDevice::snapImage (const QString & profileToken) {/ / filtering can also be considered here, for example, if snapUrl already exists, there is no need to obtain the address getSnapshotUri (profileToken); QImage image If (! snapUrl.isEmpty ()) {/ / request image data reply 1080p probably requires 600ms / / QEventLoop synchronous blocking acquisition is used by default, and there is no card main interface QNetworkReply * reply = request- > get (snapUrl); QByteArray dataReceive; bool ok = checkData (reply, dataReceive, "receive Screenshot", false) If (ok) {/ / the following line of code is very time-consuming 1080p pictures probably need 80ms if you need frequent screenshots suggested to put into the thread processing image.loadFromData (dataReceive);}} return image;} at this point, the "Qt onvif screenshots of how to achieve" the end of the study, I hope to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.