One, foreword
Yu Dabing electronic kanban system, was the inspiration for this effect in many systems especially on the screen, but when the user is not in operation, it is don’t want to see that the mouse arrow, is only displayed when the user action, this requires a timer timing calculation last time for users, and compared to the current time, If the mouse cursor has not been hidden for longer, hide the mouse, in Qt provides the method qApp->setOverrideCursor(Qt::BlankCursor); If you want to restore the mouse, call qApp->restoreOverrideCursor(); How to trigger the recovery of the mouse pointer? Whether have a bool to store the current mouse hide, set to true, when the mouse hidden intercept mouse events, once found in a hidden state before the mouse, the pointer state immediately, will mark a change to the false at the same time, otherwise the frequent recovery pointer is meaningless, only need to recover when the pointer is hidden again.
Two, functional characteristics
Software modules
- Video monitoring module, various docking small window sub-module, including device list, graphic warning, window information, panyt control, preset position, cruise setting, device control, floating 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 logs, device logs, etc.
- System setting module, including system Settings (basic Settings, video parameters, database Settings, map configuration, serial port configuration, etc.), VIDEO recorder management, camera management, polling configuration, user management, etc.
Basis function
- Support various video streams (RTSP, RTMP, HTTP, etc.), video files (MP4, RMVB, AVI, etc.), local USB camera playback.
- Support multi-screen switching, including 1, 4, 6, 8, 9, 13, 16, 25, 36, 64 screen switching.
- Supports full-screen switching, including the right mouse button, toolbar button, and shortcut keys (Alt + Enter full-screen, esc exit full-screen).
- Supports video polling, including 1, 4, 9, and 16 screen polling. You can set polling group (polling plan), polling interval, and bit stream type.
- Supports the OnVIF protocol, including device search, pte control, device control (picture parameters, check time, system restart, capture pictures, etc.).
- Different users can have different module permissions, such as deleting logs and shutting down the system.
- Support a variety of databases, including sqlite, mysql, sqlserver, postgresql, oracle, rendajincang and so on.
- You can set resolution and frame rate for a local USB camera.
- All docking modules automatically generate corresponding menus to control the display and hide, in the title bar right click can pop up.
- Display all modules, hide all modules, reset the common layout, and reset the full-screen layout.
- Double-click the device to pop up real-time preview video, supporting picture map, online map, offline map, etc.
- The camera node can be dragged to the corresponding window to play the video, and the local file can be dragged to play the video.
- You can delete a video by right-clicking the mouse button, closing the floating bar, or dragging it outside the video surveillance panel.
- The device button on the picture map can be dragged freely to automatically save the location information. You can click the mouse to obtain the longitude and latitude information on the Baidu map to update the location of the device.
- Any channel in the video surveillance panel form supports drag exchange, instant response.
- Encapsulated Baidu map, view switch, movement track, equipment point, mouse click to obtain latitude and longitude.
- Double-click the node, drag the node, drag the window to switch positions and other operations, will automatically update and save the last playing address, the next software open automatic application.
- Volume bar control in the lower right corner, automatically hide when losing focus, volume strip mute icon.
- You can specify a screenshot for a single channel or all channels. The screenshot button is also available on the bottom toolbar.
- The mouse pointer can be automatically hidden when timeout expires and the mouse pointer can be automatically displayed in full screen.
- Support onVIF PTZ control, can move PTZ camera up, down, left and right, including reset and focal length adjustment.
- Support any ONVIF camera, including but not limited to Hikang, Dahua, Yushi, Weiye, Huawei, etc.
- Can save video, can select the time storage or single file storage, optional storage interval time.
- Video stream communication mode can be set TCP + UDP, video decoding can be set speed first, quality first, balance, etc.
- You can set the software name, English name, and LOGO icon.
- You can export stored video files to specific directories or upload them to servers in batches.
features
- The main interface adopts the mode of docked form, various components in the form of small modules, can be customized to join any module.
- Docking module can drag any position embedded and suspended, support maximum full screen, support multi-screen.
- Dual layout file storage mechanism, normal mode and full-screen mode are corresponding to different layout schemes, automatic switching and saving, for example, full-screen mode can highlight several modules transparent display in the specified position, more science fiction sense of modernization.
- Original onVIF protocol mechanism, using the underlying protocol resolution (UDP broadcast search + HTTP request execution command) more lightweight easy to understand learning expansion, does not rely on any third-party components such as GSOAP.
- Original data import and export mechanism, cross-platform independent of any components, instant data export.
- Built in multiple original components, the universe super value super awesome, 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 component, video monitoring component, file multithreading transceiver component, onVIF communication component, universal browser kernel component, etc.
- Customize information box + error box + query box + lower right prompt box (including various formats).
- Exquisite skin change, up to 17 sets of skin styles can be changed at will, all styles are unified, including menu, etc.
- Multiple buttons can be added to the video control hover 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 the video, double click the node to automatically add the video, it will automatically jump to the next, double click the parent node to automatically add all the videos under the node. Primary stream and sub-stream are optional.
- You can add, delete, and modify the import and export printed information, and immediately apply the new device information to generate a tree list without restarting.
- Optional a variety of kernel free switch, FFMPEG, VLC, MPV, etc., can be set in pro. Ffmpeg is recommended. It is most cross-platform and provides libraries compiled on Linux and MAC platforms by default.
- Supports hard decoding and can be set to hard decoding type (QSV, DXVA2, d3D11VA, etc.).
- The default opengL rendering video, ultra-low CPU resource consumption, support YUYV and NV12 two formats to draw, very awesome.
- Highly customizable, users can easily derive their own functions on this basis, such as adding custom modules, operation mode, robot monitoring, UAV monitoring, excavator monitoring, procuratorate trial monitoring, etc.
- Support XP, Win7, Win10, Linux, MAC, a variety of domestic systems (UOS, kyrin, Galaxy Kyrin, etc.), embedded Linux and other systems.
- Complete annotation, clear project structure, super detailed complete use of the development manual, accurate to the function description of each code file, continuous iteration version.
3. Experience address
- Experience address: pan.baidu.com/s/1d7TH_GEY… Extraction code: 01Jf File name: bin_video_system.zip
- Domestic site: gitee.com/feiyangqing…
- International site: github.com/feiyangqing…
- Profile: blog.csdn.net/feiyangqing…
- Zhihu homepage: www.zhihu.com/people/feiy…
Four, effect drawing
Five, core code
#include "appinit.h" #include "quiwidget.h" #include "dbhelper.h" QScopedPointer<AppInit> AppInit::self; AppInit *AppInit::Instance() { if (self.isNull()) { static QMutex mutex; QMutexLocker locker(&mutex); if (self.isNull()) { self.reset(new AppInit); } } return self.data(); } AppInit::AppInit(QObject *parent) : QObject(parent) { } bool AppInit::eventFilter(QObject *watched, If (event->type() == QEvent::KeyPress) {QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); int keyValue = keyEvent->key(); if (keyValue == Qt::Key_Escape) { emit keyPressed("esc"); return true; } else if (keyEvent->modifiers() & Qt::AltModifier) { if (keyValue == Qt::Key_Enter || keyValue == Qt::Key_Return) { emit keyPressed("alt+enter"); return true; }} if (event->type() == QEvent::MouseMove) {if (event->type() == QEvent::MouseMove) QDateTime::currentDateTime(); if (cursorHide) { cursorHide = false; qApp->restoreOverrideCursor(); }} // The following code handles an unframed form that can be dragged QWidget *w = (QWidget *)watched; if (! w->property("canMove").toBool()) { return QObject::eventFilter(watched, event); } static QPoint mousePoint; static bool mousePressed = false; QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); if (event->type() == QEvent::MouseButtonPress) { if (mouseEvent->button() == Qt::LeftButton) { mousePressed = true; mousePoint = mouseEvent->globalPos() - w->pos(); return true; } } else if (event->type() == QEvent::MouseButtonRelease) { mousePressed = false; return true; } else if (event->type() == QEvent::MouseMove) { if (mousePressed && (mouseEvent->buttons() && Qt::LeftButton)) { w->move(mouseEvent->globalPos() - mousePoint); return true; } } return QObject::eventFilter(watched, event); } void AppInit::checkCursor() {// Hide cursor if (! cursorHide) { QDateTime now = QDateTime::currentDateTime(); if (lastTime.secsTo(now) > App::CursorHideTime) { cursorHide = true; qApp->setOverrideCursor(Qt::BlankCursor); } } } void AppInit::start() { qApp->installEventFilter(this); // Set left + Maximize + Minimize + Close icon QUIConfig::IconMain = 0xf108; QUIConfig::IconMax = 0xf2d2; QUIConfig::IconNormal = 0xf2d0; // Set the global font QUIConfig::FontSize = 12; QFont font; font.setFamily(QUIConfig::FontName); font.setPixelSize(QUIConfig::FontSize); qApp->setFont(font); // Set the code QUIHelper::setCode(); // Set the translation file QUIHelper::setTranslator(); QUIHelper::setTranslator(":/image/widgets.qm"); // Initialize random number seed QUIHelper::initRand(); // Generate folder QUIHelper::newDir("config"); QUIHelper::newDir("snap"); QUIHelper::newDir("db"); // Load the configuration file App::ConfigFile = QString("%1/config/%2.ini").arg(QUIHelper::appPath()).arg("video_system"); App::readConfig(); DBData: : NvrTypes < < "hai kang" < < < < "dahua" "yu see" < < "widespread" < < "other"; DBData: : IpcTypes < < "hai kang" < < < < "dahua" "yu see" < < "tai jie" < < "other"; QString dbName = QString("%1/db/%2.db").arg(QUIHelper::appPath()).arg("video_system"); QFile dbFile(dbName); if (! DbFile. The exists () | | dbFile. The size () = = 0) {QUIHelper: : showMessageBoxError (" database file does not exist!" ); } // After the program starts, open the database connection, and call the database QSqlDatabase dbConn wherever the form needs; dbConn = QSqlDatabase::addDatabase("QSQLITE"); dbConn.setDatabaseName(dbName); dbConn.open(); // Load default data DBHelper::loadUserInfo(); DBHelper::loadNvrInfo(); DBHelper::loadIpcInfo(); // Start timer to calculate how long the user has not operated the mouse cursorHide = false; lastTime = QDateTime::currentDateTime(); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(checkCursor())); timer->start(1000); }Copy the code