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 write Qt Security Video Surveillance system to realize offline reconnection

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "Qt how to write security video surveillance system to achieve offline reconnection", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Qt how to write security video surveillance system to achieve offline reconnection" it!

I. Preface

Offline reconnection was done a long time ago. Basically, the method is to create a variable to store the last time the picture was received, and then start a timer to judge that if you are not in pause mode, the difference between the current time and the last time you received the picture exceeds the set timeout. For example, 5s is considered to be offline, then call the close method to close it, call open to reopen the video stream, and repeat in turn.

At the beginning, I found that if the time of the last picture received was updated in the widget of the video stream control, it would be fake death after a long time, obviously it was still in the process of drawing, but this time would not be updated. It was also seen on the Internet that some people had encountered similar problems. It was only normal to move this variable to the decoding collection thread later, and the correct thing to do was to put it in the collection thread. After all, after hard decoding opengl display, it was right. It has nothing to do with painter, or after the video stream is handed over to the handle, it has nothing to do with painter and must be processed from the source.

The video stream control comes with an automatic reconnection mechanism, so that users do not need to worry about how to reconnect when they use it again, they only need to turn on the automatic reconnection attribute, which is on by default, and there is another case where the automatic reconnection attribute may be turned off. For example, to play a local video file, sometimes it only needs to be played once, and there is no need to replay it after the playback is completed, if it is really needed. Then the associated playback signal can be re-open by itself.

In the course of specific use, it is found that in a video surveillance system, for example, if there are 16 channels, if they are automatically reconnected into a single video stream control, there will be a situation in which the network is down and then restored, then the 16 channels are likely to be instantly restored at the same time, when the CPU and memory soar, or even the program crashes, so how can it be done? After that, a new class is rewritten to manage all the video controls in the video surveillance channel, and a timer is turned on to queue up the devices that need to be reconnected, instead of instantly reconnecting all the devices leading to an instant surge of pressure.

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. The core code void FFmpegThread::run () {while (! stopped) {/ / initializes the operation if (isPlay) {if (init ()) {initSave (); emit receivePlayStart ();} else {break; emit receivePlayError () } isPlay = false; continue;} if (isPause) {/ / if normal is assumed here, the time to continue updating during the pause period lastTime = QDateTime::currentDateTime (); msleep (1); continue;} / / rescheduled time.restart () QMutexLocker locker (& mutex); if (av_read_frame (formatCtx, packet) > = 0) {/ / update the last decoding time lastTime = QDateTime::currentDateTime (); / / determine whether the current packet is video or audio int index = packet- > stream_index; if (index = = videoStreamIndex) {existImage = true DecodeVideo ();} else if (index = = audioStreamIndex) {decodeAudio ();}} else if (! isRtsp) {/ / if it is not a video stream, it means that the video file is played break;} av_packet_unref (packet); av_freep (packet) Msleep (1);} emit sig_stopSave (); / / release resources at the end of the thread msleep (100); free (); stopped = false; isPlay = false; isPause = false; existImage = false; emit receivePlayFinsh (); qDebug () getLastTime (); int sec = lastTime.secsTo (now); if (sec > = timeout) {restart () }} at this point, I believe you have a deeper understanding of "how to write Qt security video surveillance system to achieve offline reconnection". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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