Qt writing visual large-screen electronic signage system 31-module 9 video surveillance

I. Introduction

The video surveillance module uses ffmpeg as the decoding core, and can fill in a video address in the system settings. It also supports local video files, USB cameras, remote onvif cameras (Hikvision Dahua, etc.), and network video addresses. There is a video address by default in the large-screen system. Monitoring, if you need to display more than one, you can add multiple video monitoring modules. In this system, the small module of each smallest unit is a class, and you can display as many as you need, and the secondary module is used as a suspension module. The stop form is embedded in the main interface mainwindow, and it can be dragged to any position to be embedded automatically.

The video surveillance module has multiple parameter settings for users to set. At first, it was built-in and hardcoded in the code. Later, with the change of the user scene, the parameter setting is more flexible. The parameters are as follows:

  • Video stretching: some customers need to stretch and fill some need to be proportionally zoomed;
  • Video callback: Some boards or computers do not have opengl or the version is too low, and video callbacks need to be turned on to draw images normally;
  • Play audio: After it is turned on, the sound in the video and video stream will be played;
  • Video loop: After the video is turned on, it will repeat immediately after the video is played;
  • Timeout time: the time out for opening the video, some network addresses need to be set longer;
  • Communication mode: video stream is played by TCP or UDP protocol;

Video surveillance kernel features:

  1. Multi-threaded real-time playback of video stream + local video + USB camera, etc.
  2. Support windows+linux+mac, support ffmpeg3 and ffmpeg4, support 32-bit and 64-bit.
  3. Multi-threaded display images, not stuck on the main interface.
  4. Automatically reconnect webcam.
  5. You can set the border size, i.e. offset and border color.
  6. You can set whether to draw the OSD label, that is, the label text or the picture and the label position.
  7. Two OSD positions and styles can be set.
  8. Whether to save to file and file name can be set.
  9. You can directly drag and drop files to the ffmpegwidget control to play.
  10. Support common video streams such as h265 video stream + rtmp.
  11. Playback can be paused and resumed.
  12. Supports storing a single video file and periodically storing video files.
  13. Customize the top floating bar, send a click signal notification, and set whether to enable it.
  14. You can set the screen to stretch to fill or fill proportionally.
  15. Decoding can be set to be speed priority, quality priority, and equalization processing.
  16. Screenshots (original pictures) and screenshots can be taken of videos.
  17. Video file storage supports bare streaming and MP4 files.
  18. Audio and video are perfectly synchronized, using an external clock synchronization strategy.
  19. Support seek to locate the playback position.
  20. Support online network audio and video files such as mp4 starting with http and ending with mp3.
  21. Optional handle mode (GPU drawing), callback mode (QPainter drawing).
  22. The GPU drawing mode supports both stretched and proportional drawing.
  23. Support qsv, dxva2, d3d11va and other hard decoding.
  24. Combination of hard decoding and GPU, ultra-low CPU usage, supports 64-channel video.
  25. Support Android and embedded linux, just cross-compile.

2. Features

  1. The layered design is adopted, and the whole is divided into three levels of interfaces. The first level interface is the overall layout, the second level interface is a single function module, and the third level interface is a single control.
  2. Sub-controls include pie chart, doughnut chart, curve chart, column chart, column group chart, horizontal column chart, horizontal column group chart, pass rate control, percentage control, progress control, equipment status panel, table data, map control , video controls, etc.
  3. The secondary interface can be freely dragged and suspended, and supports minimizing and hiding, maximizing and closing, and responding to double-clicks to customize the title bar.
  4. The data source supports analog data (default), database acquisition, serial communication (to be customized), network communication (to be customized), network request, etc. The acquisition interval of each sub-interface, that is, the data refresh frequency, can be freely set.
  5. Written in pure QWidget, test any version from Qt4.6 to Qt6.2, and theoretically support other subsequent Qt versions.
  6. Super cross-platform, pro-test windows, linux, mac, domestic uos, domestic Galaxy Kirin kylin and other systems, the effect is perfect, and also supports embedded linux such as raspberry pie, orange pie, allwinner, imx6, etc.
  7. At the same time, it integrates functions such as custom controls, qchart pie charts, and echart maps.
  8. Built-in multiple sets of color matching styles (purple, blue, dark blue, black), the default purple, adaptive to any resolution.
  9. You can set the system title, target resolution, layout scheme, and start the application immediately.
  10. Various colors such as main background color, panel color, crosshair cursor color, etc. can be set.
  11. Multiple curves with different colors can be set, and multiple sets of exquisite colors can be randomly applied if no color is set.
  12. You can set the background color and text color of the title bar.
  13. You can set the background color, text color, and grid color of the curve chart.
  14. Normal color, warning color, alarm color, disabled color, and percentage progress color can be set.
  15. Various font sizes can be set separately, such as global font, software name, title bar, sub-title bar, bold labels, etc.
  16. The title bar height, header height, and row height can be set.
  17. Curves support cursors, positioning lines, hover to highlight data points, hover to display values.
  18. The histogram supports the top (top, top, middle, bottom can be set) to display data, and all adaptive calculation positions.
  19. Supports smooth curves, built-in multiple smooth curve algorithms, and also supports area graph smoothing.
  20. The area chart fill color can be selected from a variety of rules, such as single-color transparency fill, transparency gradient fill, etc.
  21. The database supports sqlite, mysql, postgresql, oracle, domestic NPC Jincang and other databases.
  22. Right-click on the main interface to switch the layout, color scheme, and close or open a secondary form.
  23. Automatically memorize the size and position of all sub-windows, and apply it immediately the next time you start it.
  24. Dynamically load the layout scheme menu, you can dynamically create new layouts, restore layouts, save layouts, save layouts, etc., users can create any layout.
  25. The secondary form, double-click to separate from the main form and float, can be freely resized. Double-click the title bar again to maximize, double-click again to restore.
  26. The sub-module can also be displayed in full screen as a large screen, so that one large screen can be extended to multiple sub-large screens, and the data details of the sub-module can be enlarged and viewed, which is suitable for multi-screen display.
  27. Each module can customize the collection speed. If it is database collection, it will be automatically queued for processing. Later, you can expand the database collection of each sub-module independently.
  28. Provides a system setting module for overall configuration parameter settings, and the effect is applied immediately.
  29. Provide beautiful and cool large-screen map modules, including static pictures, flickering effects, migration effects, world maps, regional maps, etc., you can specify the latitude and longitude coordinates of points, identify click responses, and do map jumps, etc. Each point is Can have different colors and prompt messages.
  30. In addition to providing a large-screen system, each module has an independent module example interface, each module can be learned and used independently, and the controls used in it have also been separately made a control example interface, which is convenient for learning how to use each control. .
  31. Very detailed development and use manual, including database description, module comparison diagram, control comparison diagram, project structure, code description (accurate to each class), demonstration demo, usage method, etc.

3. Experience address

  1. Experience address: https://pan.baidu.com/s/1d7TH_GEYl5nOecuNlWJJ7g Extraction code: 01jf File name: bin_bigscreen.zip.
  2. Domestic site: https://gitee.com/feiyangqingyun
  3. International site: https://github.com/feiyangqingyun
  4. Personal homepage: https://blog.csdn.net/feiyangqingyun
  5. Know the homepage: https://www.zhihu.com/people/feiyangqingyun/
  6. Online documentation: https://feiyangqingyun.gitee.io/qwidgetdemo/bigscreen/

Fourth, the effect map

insert image description here

Five, the core code

#include "frmmodulevideo.h"
#include "ui_frmmodulevideo.h"
#include "quihelper.h"

frmModuleVideo::frmModuleVideo(QWidget *parent) : QWidget(parent), ui(new Ui::frmModuleVideo)
{
    ui->setupUi(this);
    this->initForm();
}

frmModuleVideo::~frmModuleVideo()
{
    delete ui;
}

void frmModuleVideo::showEvent(QShowEvent *)
{
#ifdef videoffmpeg
    //延时处理不然布局加载后会先显示再隐藏瞬间反复来两次导致隐藏的时候无法暂停
    QTimer::singleShot(200, this, SLOT(open()));
    if (!isLoad) {
        isLoad = true;
    } else {
        videoWidget->next();
    }
#endif
}

void frmModuleVideo::hideEvent(QHideEvent *)
{
#ifdef videoffmpeg
    //界面不可见的时候暂停以节省资源
    videoWidget->pause();
#endif
}

void frmModuleVideo::initForm()
{
    isLoad = false;
    url = AppConfig::VideoUrl;

#ifdef videoffmpeg
    videoWidget = new FFmpegWidget;
    videoWidget->setBorderWidth(0);
    videoWidget->setBgText("");
    //设置拉伸填充图像
    videoWidget->setFillImage(AppConfig::VideoFillImage);
    //设置是否回调,有些嵌入式环境只能用回调
    videoWidget->setCallback(AppConfig::VideoCallback);
    //设置是否播放声音
    videoWidget->setPlayAudio(AppConfig::VideoPlayAudio);
    //设置是否重复播放
    videoWidget->setPlayRepeat(AppConfig::VideoPlayRepeat);
    //设置打开超时时间,一些推流要把时间设置大一些
    videoWidget->setCheckTime(AppConfig::VideoCheckTime * 1000);
    //设置视频流通信协议
    videoWidget->setTransport(AppConfig::VideoTransport);
    //把视频控件加到布局中
    ui->widgetMain->layout()->addWidget(videoWidget);
#endif
}

void frmModuleVideo::setUrl(const QString &url)
{
    this->url = url;
}

void frmModuleVideo::open()
{
#ifdef videoffmpeg
    if (isVisible() && !videoWidget->getIsPlaying()) {
        videoWidget->setUrl(url);
        videoWidget->open();
    }
#endif
}

Guess you like

Origin blog.csdn.net/feiyangqingyun/article/details/123811299