1, Foreword
The preset position is indispensable in the video monitoring system. The premise of responding to the preset position function is to use the cloud billiard machine with the preset position. Some ordinary cloud billiards machines actually do not have the preset position. Check it clearly. If the hardware does not support this function, you will not respond at all. In the process of using the video surveillance system, many users will ask this question. Why can't they answer when they click the PTZ? The premise is that they need hardware support.
The preset position is a way to connect the monitored key area with the operation status of the ball machine. When the user monitors the target through the monitoring PTZ of the control equipment operation terminal, the operator can set the current monitoring target to a preset position, such as a moving point PTZ, which can rotate 365 or 360 degrees for monitoring; Operators can set a window, counter, desk, entrance and exit, parking place and other places that need to be monitored as preset positions; The preset bit set can save the current position on the decoder of the terminal monitoring PTZ through the software operation of the control equipment. When the user needs to quickly monitor a monitoring target; The position to be monitored can be called out by calling the command of the control device. This is the meaning of the preset bit function.
The related processing of preset bit includes obtaining preset bit (a collection of preset bit information, generally 1-255 preset bit number with preset bit name), calling preset bit (equivalent to actively triggering a preset bit to make the ball machine actively move to the position of the preset bit) Add preset bit (you can pass in preset bit number and name, add preset bit, or replace the position information of existing preset bit), delete preset bit (delete the position information of existing preset bit) Set the starting position (the ball machine generally has a HOME position as the starting position, or manually switch the ball machine to move to a suitable position, and then set it to the starting position, so that after the movement changes, it can return to the starting position first), call the starting position (take the position information corresponding to the current screen as the starting position). The preset bit number is generally 1-255, and some ball machines may be 1000. The preset bit name is also equivalent to an alias, which can be Chinese for easy identification and memory.
Main functions of onvif
- Search for equipment and obtain equipment information, such as manufacturer, model, etc.
- Get multiple profile information of the device.
- Obtain the video stream address rtsp, resolution and other parameters of the corresponding configuration file.
- Pan tilt control, moving up, down, left and right, zoom in and out, relative and absolute movement.
- Obtain the preset bit information and trigger the preset bit.
- Subscribe to events and receive various messages from the device, especially alarm events, such as the alarm of IO port.
- Capture the current picture of the device.
- Obtain, create and delete user information.
- Obtain device and network configuration information, such as IP address, etc.
- Gets and sets NTP time synchronization.
- Gets and sets the device time.
- Restart the device.
Processing flow of onvif
- Bind multicast IP (239.255.255.250) and port (3702) to send data search equipment in fixed xml format.
- Parse the received data in xml format to get the Onvif address of the device.
- Send the corresponding data to the Onvif address, and take out the corresponding node data after receiving the data.
- Request the Onvif address to obtain the Media address and Ptz address. The Media address is used to obtain the detailed configuration file, and the Ptz address is used for Ptz control.
- PTZ control is to send corresponding data to PTZ address.
- If user authentication is set, the user token information needs to be sent together, and authentication processing needs to be performed every time.
- The received data is not standard xml data and cannot be processed according to normal node parsing. It can only be done with QXmlQuery.
- The data returned by the equipment of each manufacturer may not be completely consistent, but they are basically inconsistent. It is necessary to fuzzy search the node value.
- The underlying protocol resolution is specially adopted, because soap is too bulky, the function name is too alternative, and it is deliberately lightweight.
- Two necessary tools, Onvif Device Manager and Onvif Device Test Tool.
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
- Support 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 small toolbar at the bottom.
- 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.
- Custom 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.html
4, Renderings
5, Core code
#include "onvifptz.h" OnvifPtz::OnvifPtz(QObject *parent) : QObject(parent) { device = 0; } void OnvifPtz::setDevice(OnvifDevice *device) { this->device = device; } bool OnvifPtz::ptzControl(quint8 type, const QString &profileToken, double x, double y, double z) { QString name = "PtzStop"; QString flag = "PTZ stops moving"; if (type == 1) { name = "PtzAbsoluteMove"; flag = "Pan tilt absolute movement"; } else if (type == 2) { //xy=0 means to control the zoom of focal length at this time if (x == 0.0 && y == 0.0) { name = "PtzRelativeMoveZoom"; flag = "Relative focal length of PTZ"; } else { name = "PtzRelativeMove"; flag = "Relative movement of PTZ"; } } else if (type == 3) { //xy=0 means to control the zoom of focal length at this time if (x == 0.0 && y == 0.0) { name = "PtzContinuousMoveZoom"; flag = "PTZ continuous focal length"; } else { name = "PtzContinuousMove"; flag = "PTZ continuous movement"; } } QString file = OnvifHelper::getFile(QString(":/onvifsend/%1.xml").arg(name)); QString userToken = device->getUserToken(); if (type == 1) { file = file.arg(userToken).arg(profileToken).arg(x).arg(y).arg(z); } else if (type == 2 || type == 3) { if (name.endsWith("Zoom")) { file = file.arg(userToken).arg(profileToken).arg(z); } else { file = file.arg(userToken).arg(profileToken).arg(x).arg(y); } } else { file = file.arg(userToken).arg(profileToken); } QByteArray dataSend = file.toUtf8(); QNetworkReply *reply = device->request->post(device->ptzUrl, dataSend); QByteArray dataReceive; bool ok = device->checkData(reply, dataReceive, flag); return ok; } bool OnvifPtz::ptzPreset(quint8 type, const QString &profileToken, const QString &presetToken, const QString &presetName) { QString name = "PtzGotoPreset"; QString flag = "Call preset bit"; if (type == 1) { name = "PtzSetPreset"; flag = "Add preset bit"; } else if (type == 2) { name = "PtzRemovePreset"; flag = "Delete preset bit"; } else if (type == 3) { name = "PtzGotoHomePosition"; flag = "Call start bit"; } else if (type == 4) { name = "PtzSetHomePosition"; flag = "Set start bit"; } QString file = OnvifHelper::getFile(QString(":/onvifsend/%1.xml").arg(name)); if (type == 1) { file = file.arg(device->getUserToken()).arg(profileToken).arg(presetToken).arg(presetName); } else if (type == 0 || type == 2) { file = file.arg(device->getUserToken()).arg(profileToken).arg(presetToken); } else if (type == 3 || type == 4) { file = file.arg(device->getUserToken()).arg(profileToken); } QByteArray dataSend = file.toUtf8(); QNetworkReply *reply = device->request->post(device->ptzUrl, dataSend); QByteArray dataReceive; bool ok = device->checkData(reply, dataReceive, flag); return ok; } QList<OnvifPresetInfo> OnvifPtz::getPresets(const QString &profileToken) { QList<OnvifPresetInfo> presets; if (device->mediaUrl.isEmpty()) { return presets; } QString file = OnvifHelper::getFile(":/onvifsend/PtzGetPresets.xml"); file = file.arg(device->getUserToken()).arg(profileToken); QByteArray dataSend = file.toUtf8(); QNetworkReply *reply = device->request->post(device->mediaUrl, dataSend); QByteArray dataReceive; bool ok = device->checkData(reply, dataReceive, "Get preset bit"); if (ok) { //Parsing preset bit information OnvifQuery query; if (query.setData(dataReceive)) { presets = query.getPresets(); } } return presets; }