1, Foreword
The graphic report corresponds to the previous text report. After the previous log query, it needs to be printed or exported. It is a line by line text record. Recently, it needs to be printed and exported. Therefore, it takes the opportunity to completely import and export the previous data (xls/pdf) and completely transform and rewrite the printing component, which is also a component that needs to be reconstructed, 60% of redundant codes are deleted, the parameters for storing and exporting print data are added, and a general static function is made for export and printing, which is very convenient. At the same time, it also expands the data export and printing support of graphic alarm, supports the incoming picture path, customize the main title and sub title, etc. In the whole process of transformation, several small experiences are summarized.
- If a function has a return value, it must actively return the return value. Some compilers can compile normally without a return value, but there will be problems when running, and the desired results will not be obtained, because there is no value corresponding to return.
- It is a good habit to actively give an initial value to a defined local variable. Otherwise, the initial value given by the compiler may not be what you want. For example, the default value of int variable is 0. Sometimes it randomly becomes a large value. The initial value of bool variable is different from that of the compiler. Some are true and some are false. It is more reliable to actively give an initial value.
- Some function parameters are many, and may be modified and added later, which leads to the modification of the associated signal slot after the source modification. The parameter type and location must be completely consistent, and the processing of the corresponding slot function must be modified. The workload of modification is very large and very unfriendly. Therefore, for functions with non fixed parameters, it is recommended to use structures, In this way, it is very easy to add other parameters without modifying the signal slot Association and signal slot function definition. For example, the student information table and commodity information table are transmitted as parameters. The best scheme is the structure.
Functional features of graphic report
- The original data export mechanism does not rely on any third-party libraries such as office components or operating systems, especially embedded linux.
- 100000 rows of data and 9 fields only take 2 seconds to complete.
- It only takes four steps to quickly export a large amount of data to Excel.
- At the same time, it provides direct write data interface and multi-threaded write data interface without card main interface.
- You can set the title, subtitle and table name.
- Field name and column width can be set.
- You can set whether to enable verification filtering data, verification columns, verification rules, verification values, and special color display that meets the rules.
- You can set the random background color and the column set that needs the random background color.
- It supports grouping and outputting data, such as grouping and outputting data according to equipment, which is convenient for viewing.
- You can customize the line content separator.
- Data can be written in the form of additional data. It is recommended that less than 10000 pieces of data be added each time.
- Super flexible, you can freely change the source code, set the alignment, text color, background color, etc.
- Support any excel software, including but not limited to excel 2003 / 2007 / 2010 / 2013 / 2017 / WPS / OpenOffice, etc.
- In addition to exporting to Excel, it also provides classes for exporting to Pdf files and printing data.
- The annotation is perfect, the detailed and complete use demo supports three data sources: QTableWidget, QTableView and database.
- Written in pure Qt, it supports any Qt version + any compiler + any system.
2, Functional features
(1) Software module
- Video monitoring module, various docking small window sub modules, including equipment list, graphic alarm, window information, PTZ control, preset position, cruise setting, equipment control, suspension map, web browsing, etc.
- Video playback module, including local playback, remote playback, device playback, picture playback, video upload, etc.
- Electronic map module, including picture map, online map, offline map, path planning, etc.
- Log query module, including local log, device log, etc.
- System setting module, including system setting (basic setting, video parameters, database setting, map configuration, serial port configuration, etc.), VCR management, camera management, polling configuration, user management, etc.
(2) Basic functions
- It supports various video streams (rtsp, rtmp, http, etc.), video files (mp4, rmvb, avi, etc.) and local USB camera playback.
- Support multi screen switching, including 1, 4, 6, 8, 9, 13, 16, 25, 36 and 64 screen switching.
- Full screen switching is supported, including right-click menu, toolbar button and shortcut key (alt+enter full screen, esc exit full screen).
- Support video polling, including 1, 4, 9 and 16 picture polling, and set polling packet (polling plan), polling interval, code stream type, etc.
- Support onvif protocol, including device search, PTZ control and device control (picture parameters, proofreading time, system restart, capturing pictures, etc.).
- Permission management is supported. Different users can correspond to different module permissions, such as deleting logs, shutting down the system, etc.
- The database supports a variety of, including sqlite, mysql, sqlserver, postgresql, oracle, NPC gold warehouse, etc.
- The local USB camera supports setting parameters such as resolution and frame rate.
- All docking modules automatically generate corresponding menus to control display and hiding. Right click in the title bar to pop up.
- It supports displaying all modules, hiding all modules, resetting normal layout and resetting full screen layout.
- Double click the device to pop up the real-time preview video, which supports picture map, online map, offline map, etc.
- Drag the camera node to the corresponding window to play video, and drag local files to play directly.
- To delete a video, you can right-click to delete it, close the hoverbar to delete it, and drag it outside the video monitoring panel to delete it.
- The device button on the picture map can be dragged freely to automatically save the location information. Baidu map can click to obtain longitude and latitude information to update the device location.
- Any channel in the video monitoring panel form supports drag switching and instant response.
- It encapsulates Baidu map, view switching, motion track, equipment point position, mouse click to obtain longitude and latitude, etc.
- Double click the node, drag the node, drag the window to exchange positions and other operations will automatically update and save the last playback address, and the software will open the automatic application next time.
- The volume bar control in the lower right corner is automatically hidden when the focus is lost, and the volume bar has a mute icon.
- Support video screenshots. You can specify a single or all channel screenshots. There is also a screenshot button on the bottom small toolbar.
- Support timeout automatic hiding of mouse pointer and automatic full screen mechanism.
- It supports onvif PTZ control and can move PTZ cameras up, down, left and right, including reset and focal length adjustment.
- Support any onvif camera, including but not limited to Haikang, Dahua, Yushi, Tiandi Weiye, Huawei, etc.
- Video can be saved, with options of regular storage or single file storage, and optional storage interval.
- The video stream communication mode tcp+udp can be set, and the video decoding modes such as speed priority, quality priority and equalization can be set.
- The Chinese name, English name, LOGO icon, etc. of the software can be set.
- The stored video files can be exported to the specified directory and uploaded to the server in batches.
(3) Characteristic function
- The main interface adopts docked form mode, and various components are added in the form of small modules, which can be added by any module.
- The docking module can drag any position to embed and suspend, and supports maximizing the full screen and multi screen.
- Dual layout file storage mechanism. The normal mode and full screen mode correspond to different layout schemes and are automatically switched and saved. For example, the full screen mode can highlight several modules and display them transparently in the specified position, which is more sci-fi and modern.
- The original onvif protocol mechanism adopts the underlying protocol parsing (udp broadcast search + http request execution command), which is lighter, easy to understand, easy to learn and expand, and does not rely on any third-party components, such as gsoap.
- The original data import and export mechanism can export data instantly without relying on any components across platforms.
- Built in multiple original components, the universe is super valuable, including data import and export components (export to xls, pdf, printing), database components (database management thread, automatic data cleaning thread, universal paging, data request, etc.), map components, video monitoring components, file multithreading transceiver components, onvif communication components, general browser kernel components, etc.
- User defined information box + error box + query box + prompt box in the lower right corner (including multiple formats), etc.
- Exquisite skin change, up to 17 sets of skin styles can be changed at will, and all styles are unified, including menu, etc.
- Multiple buttons can be added to the video control suspension bar, and buttons can also be added to the small toolbar at the bottom of the monitoring interface.
- Double click the camera node to automatically play videos. Double click the node to automatically add videos one by one. You will automatically skip to the next node. Double click the parent node to automatically add all videos under the node. Main code stream and sub code stream can be selected.
- For video recorder management and camera management, you can add, delete, modify, import and export printing information, and immediately apply the new equipment information to generate a tree list without restarting.
- A variety of cores can be freely switched. ffmpeg, vlc, mpv, etc. can be set in pro. ffmpeg is recommended, with the most cross platforms. The libraries compiled on linux and mac platforms are provided by default.
- Hard decoding is supported, and hard decoding types (qsv, dxva2, d3d11va, etc.) can be set.
- opengl is used to draw video by default, with ultra-low CPU resource occupation. It supports yuyv and nv12 formats, which is very awesome.
- Highly customizable, users can easily derive their own functions on this basis, such as adding custom modules, adding operation modes, robot monitoring, UAV monitoring, excavator monitoring, etc.
- Support xp, win7, win10, linux, mac, various domestic systems (UOS, bid winning Kirin, Galaxy Kirin, etc.), embedded linux and other systems.
- Complete notes, clear project structure, super detailed and complete use and development manual, accurate to the functional description of each code file, and continuously iterative versions.
3, Experience address
- Experience address: https://pan.baidu.com/s/1d7TH_GEYl5nOecuNlWJJ7g Extraction code: 01jf file name: bin_video_system.zip.
- Domestic sites: https://gitee.com/feiyangqingyun
- International sites: https://github.com/feiyangqingyun
- Personal homepage: https://blog.csdn.net/feiyangqingyun
- Zhihu homepage: https://www.zhihu.com/people/feiyangqingyun/
- Online documentation: https://feiyangqingyun.gitee.io/qwidgetdemo/video_system/
4, Renderings
5, Core code
#include "datacreat.h" void DataCreat::creatUavsReportHead(QStringList &list, const UavsReportData &reportData) { //Table start list << "<table border='0.0' cellspacing='0' cellpadding='6'>"; //title list << "<tr>"; list << QString("<td width='100%' align='center' style='font-size:22px;font-weight:bold;' colspan='%1'>%2</td>").arg(2).arg(reportData.title); list << "</tr>"; //Horizontal line or line feed list << "<hr>"; //list << "<br>"; //Current module common style QString style = "style='font-size:18px;'"; //Equipment name QString name = QString("Equipment name: %1").arg(reportData.name); list << "<tr>"; list << QString("<td colspan='%1' %2>%3</td>").arg(2).arg(style).arg(name); list << "</tr>"; //Longitude and latitude QString lng = QString("Equipment longitude: %1").arg(reportData.lng); QString lat = QString("Equipment latitude: %1").arg(reportData.lat); list << "<tr>"; list << QString("<td %1>%2</td>").arg(style).arg(lng); list << QString("<td %1>%2</td>").arg(style).arg(lat); list << "</tr>"; //Alarm date + report time QString timeAlarm = QString("Alarm date: %1").arg(reportData.timeAlarm); QString timeReport = QString("Report time: %1").arg(reportData.timeReport); list << "<tr>"; list << QString("<td %1>%2</td>").arg(style).arg(timeAlarm); list << QString("<td %1>%2</td>").arg(style).arg(timeReport); list << "</tr>"; //End of form list << "</table>"; } void DataCreat::creatUavsReportBody(QStringList &list, const UavsReportData &reportData, int imageWidth) { //Line feed list << "<br><br>"; //Table start list << "<table border='0.5' cellspacing='0' cellpadding='5'>"; //title list << "<tr>"; list << QString("<td width='100%' align='center' style='font-size:20px;font-weight:bold;' colspan='%1'>%2</td>").arg(2).arg(reportData.subTitle); list << "</tr>"; //Current module common style QString style = "style='font-size:18px;'"; //Alarm Type QString type = QString("Alarm Type : %1").arg(reportData.type); list << "<tr>"; list << QString("<td width='100%' colspan='%1' %2>%3</td>").arg(2).arg(style).arg(type); list << "</tr>"; //Target quantity + threat level QString textCount = QString("Target quantity: %1").arg(reportData.textCount); QString textLevel = QString("Threat level: %1").arg(reportData.textLevel); list << "<tr>"; list << QString("<td %1>%2</td>").arg(style).arg(textCount); list << QString("<td %1>%2</td>").arg(style).arg(textLevel); list << "</tr>"; //Image queue QStringList listImage = reportData.images; int count = listImage.count(); //Alarm image QString text = QString("Alarm image ( common %1 Zhang )").arg(count); list << "<tr>"; list << QString("<td width='100%' align='center' style='font-size:20px;font-weight:bold;' colspan='%1'>%2</td>").arg(2).arg(text); list << "</tr>"; //To calculate the size of the drawing area, first scale the image to an appropriate size and save it locally QString path = qApp->applicationDirPath() + "/snap/"; for (int i = 0; i < count; ++i) { QImage image(listImage.at(i)); if (image.width() > imageWidth) { QString name = path + QString("%1.jpg").arg(i + 1); image = image.scaled(imageWidth, image.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); image.save(name, "jpg"); listImage[i] = name; } } //qDebug() << listImage; //Vertical center style = "style='vertical-align:middle;'"; for (int i = 0; i < count; i = i + 2) { list << "<tr>"; list << QString("<td align='center' %1><img src='%2'></td>").arg(style).arg(listImage.at(i)); //If you need to filter and judge, it is likely that the odd number will exceed the next one if (i < count - 1) { list << QString("<td align='center' %1><img src='%2'></td>").arg(style).arg(listImage.at(i + 1)); } list << "</tr>"; } //End of form list << "</table>"; }