CN-121979747-A - Multi-mode screen monitoring alarm method and system based on pixel difference detection
Abstract
The invention discloses a multi-mode screen monitoring alarm method and a system based on pixel difference detection, wherein a full-screen transparent top window is used for collecting the coordinates of a monitoring area selected by a user through mouse dragging, and monitoring, alarm and automatic parameter configuration are received; after configuration verification is completed, an independent monitoring thread is started, screen images of a monitoring area are periodically intercepted, a front frame image and a rear frame image are converted into NumPy matrixes, a quantized value of pixel change between frames is calculated through vectorization operation, an alarm triggering condition is judged by combining a preset threshold value, when an alarm event is detected, a unified interface is called to trigger multi-mode alarms such as sound, popup window and mail, an independent thread is synchronously started to keep an alarm screenshot, when no effective pixel change is detected within a preset duration, a timeout alarm is triggered, a shutdown countdown thread is started, and system shutdown is executed after the countdown is finished and no change is caused. The invention synchronously realizes the accuracy, the instantaneity, the reliability and the functional integrity of monitoring on the premise of low system resource occupation.
Inventors
- ZHAO ZIQI
- LIU ZHENYU
Assignees
- 深圳市致趣科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260408
Claims (10)
- 1. A multi-mode screen monitoring alarm method based on pixel difference detection is characterized by comprising the following steps: S1, configuring a monitoring area, namely generating a full-screen transparent top-set coverage window, acquiring the coordinates of the monitoring area selected by a user through mouse dragging, and receiving monitoring, alarming and automatic parameters configured by the user; S2, monitoring initialization, namely checking configuration validity, creating a log and screenshot storage catalog, initializing a monitoring state mark and starting an independent monitoring thread; s3, monitoring and detecting in real time, wherein a monitoring thread periodically intercepts screen images of a monitoring area, converts front and rear frame images into NumPy matrixes, calculates a quantized value of pixel change between frames through vectorization matrix operation, and judges whether an alarm event is triggered or not by combining a preset threshold value; S4, multi-mode alarming, namely calling a unified alarming interface when an alarming event is detected, triggering one or more alarming actions of sound, popup window and mail according to user configuration, and synchronously starting an independent screenshot thread to store alarming screenshots; and S5, unmanned automatic processing, namely triggering overtime alarm when detecting that no effective pixel changes exist in the preset duration, starting an independent shutdown countdown thread, continuously detecting screen changes in a countdown period, and executing system shutdown when no effective changes exist after the countdown is finished.
- 2. The method according to claim 1, wherein in the step S3, the method for calculating the inter-frame pixel difference is to convert the two previous and subsequent frames of images in the pil.image format into a NumPy matrix of the type int16, calculate the absolute difference between the two matrices, sum all elements of the difference matrix to obtain a quantized value of the pixel variation, and filter false alarm caused by small pixel jitter by a preset threshold.
- 3. The method according to claim 1, wherein in the step S5, the execution logic of the shutdown countdown thread is configured to save a reference screenshot when the shutdown is started, periodically intercept a comparison between a current screen image and the reference screenshot, cancel the shutdown and resume regular monitoring if a pixel change exceeding a threshold is detected, and execute a system shutdown command if no valid change is detected after the countdown is completed.
- 4. The method according to claim 1, wherein the mail alarming action of step S4 is implemented with an anti-repetition sending mechanism, and by constructing a unique identifier containing the recipient and the mail subject, whether the same type of alarming mail is sent is judged, and if so, the sending operation is skipped; The method further comprises a configuration persistence step of serializing all parameters configured by a user into a JSON format character string and storing the JSON format character string into a local file, and automatically reading and analyzing the configuration file when a program is started to restore the historical configuration of the user.
- 5. A multi-modal screen monitor alarm system based on pixel difference detection implementing the method of claim 1, comprising a screen capture unit and an alarm notification unit, further comprising: the user interaction module is used for generating a full-screen transparent top-set coverage window, realizing visual selection and coordinate acquisition of a monitoring area through mouse dragging, and simultaneously providing a parameter configuration interface and an operation state display interface; The multithread management and control module is respectively in communication connection with other modules and units and is used for independently running a monitoring thread, a screenshot saving thread and a shutdown countdown thread, wherein the monitoring thread is used for periodically executing screen sampling and pixel change detection, the screenshot saving thread is used for automatically storing the screenshot when the alarm is triggered, and the shutdown countdown thread is used for automatically managing and controlling the shutdown in a non-change overtime scene; The pixel change detection unit is used for converting the intercepted screen frame image into NumPy matrixes, calculating the sum of absolute differences of pixels between frames through vectorization matrix operation to obtain a pixel change quantized value, and judging whether to trigger an alarm or not by combining a preset sensitivity threshold value; The multi-mode alarm management module is internally provided with a unified alarm triggering interface, is in communication connection with the pixel change detection unit and is used for triggering multi-mode alarm actions of sound, popup window and mail according to one or synchronous configuration of a user; And the persistence storage module is respectively in communication connection with other modules and units and is used for storing user configuration in a JSON format in a persistence manner, running logs in a text format and alarm screenshots in a timestamp naming format.
- 6. The system of claim 5, wherein a full screen transparent set top overlay window of the user interaction module is constructed based on QWidget of PyQt5, a borderless, always set top attribute is set, and window transparency is 30%; and the full-screen transparent top-set cover window records initial coordinates through the pressing of an event by a mouse, draws red rectangular frames of the selected area in real time through a dragging event, calculates and outputs coordinates of the selected area through a releasing event, and completes the selection of the monitoring area.
- 7. The system according to claim 5, wherein when the pixel variation detecting unit calculates the pixel variation between frames, the pixel variation detecting unit converts the frame image in the pil.image format into a NumPy matrix of the int16 type, calculates the absolute difference between the two frame matrices, and sums the difference matrices to obtain the pixel variation quantized value.
- 8. The system of claim 5, wherein the monitoring thread of the multithreading management and control module is configured with a dual monitoring mode including a pixel change monitoring mode and a no change timeout monitoring mode; The pixel change monitoring mode is used for triggering an alarm when the quantized value of the pixel change exceeds a preset threshold value; the non-change overtime monitoring mode is used for triggering overtime alarm and starting a shutdown countdown thread when the pixel change quantized value is continuously lower than a threshold value within a preset time length; And after the shutdown countdown thread is started, periodically intercepting a screen image to compare pixel difference with a reference screenshot, if the pixel change exceeding the threshold value is detected before the countdown is finished, canceling shutdown and recovering conventional monitoring, and if the countdown is finished, the effective pixel change is not detected yet, executing a system shutdown command.
- 9. The system of claim 5, wherein the unified alarm interface of the multi-mode alarm management module is send_notification (title), and the interface executes the corresponding alarm action according to the user configuration, and the method comprises: A sound reminding action, wherein a user-defined audio file is played preferentially, and if the user-defined audio file is invalid, a default prompt tone of the system is played; A popup window reminding action, wherein an alarm dialog box is displayed through QMessageBox, and a bubble notification is synchronously displayed on a system tray; And E, mail reminding action, namely sending alarm mails through an SMTP protocol, wherein a built-in anti-repetition sending mechanism is used for avoiding repeated parts of the same alarm event.
- 10. The system of claim 5, wherein the configuration management logic of the persistent storage module is configured to automatically load a JSON format configuration file when a program is started, block a UI control signal trigger when the program is loaded, restore signal connection after the loading is completed, and automatically sequence the configuration into the JSON format for storage after the user modifies the configuration, so as to ensure that the configuration can be restored after the restarting.
Description
Multi-mode screen monitoring alarm method and system based on pixel difference detection Technical Field The invention relates to the technical field of computer image processing and screen monitoring, in particular to a multi-mode screen monitoring alarm method and system based on pixel difference detection. Background Along with the wide popularization of scenes such as industrial upper computer monitoring, financial market real-time monitoring, automatic program operation and maintenance, unattended task progress tracking and the like, the industry brings urgent demands for full-time accurate monitoring of a specified area of a screen, real-time alarm of abnormal events and automatic treatment, and the detection precision, operation efficiency, alarm reliability and functional integrity of a screen monitoring alarm technology directly determine the landing effect of a monitored scene. The current mainstream screen monitoring scheme has a plurality of technical defects. The traditional manual on-duty monitoring mode has high labor cost, long-time monitoring is easy to cause missed detection and misjudgment due to visual fatigue, unmanned scenes such as night, holidays and the like cannot be adapted, and the system has no standardized event recording and backtracking mechanism and has poor traceability. The conventional screenshot and recording tool can only realize post-preservation of screen content, does not have the capability of real-time intelligent change detection and alarm, still needs manual review comparison, has high system resource occupation in a full-screen recording mode, cannot realize accurate monitoring of a designated area, is easy to generate a large amount of invalid data, and meanwhile lacks a matched automatic treatment function, so that the core requirement of an unattended scene cannot be met. The existing simple monitoring program based on pixel comparison realizes basic automatic change detection, but has obvious shortboards that firstly, the monitoring area has insufficient selection flexibility, the operation threshold is high due to the fact that coordinates are needed to be input manually, a visual drag selection function is not needed, secondly, the pixel detection algorithm has inherent defects, the pixel value calculation overflow problem is not processed, a scientific threshold filtering mechanism is lacked, the false alarm rate is high, the detection efficiency is low, thirdly, the alarm mode is single, only a local popup window and a sound reminding function are supported, reliable remote notification capability is not available, the alarm touch rate is insufficient, thirdly, unmanned automatic handling functions such as non-change overtime detection and automatic shutdown are lacked, thirdly, a single-thread architecture is adopted, the monitoring logic is coupled with the operation of a UI interface, interface clamping is easy to be caused, a perfect configuration persistence and log tracing mechanism is not needed, and scene suitability is poor. In addition, the professional screen monitoring system of the industrial scene needs to be matched with special hardware acquisition equipment, has high deployment and use cost and poor universality, can only adapt to specific industrial equipment and scenes, and cannot meet the light-weight monitoring requirements of common offices and individual users. To sum up, all kinds of screen control technical schemes in the prior art can not simultaneously consider detection precision, operation efficiency, resource occupation, functional integrity and operation convenience, and core pain points such as high false alarm rate, single alarm mode, poor unattended adaptation, weak traceability and the like are commonly existed, so that the screen control alarm requirements under all kinds of scenes are difficult to fully meet. Disclosure of Invention The present invention aims to solve at least one of the technical problems in the prior art described above. Therefore, the invention provides a multi-mode screen monitoring alarm method and system based on pixel difference detection, which are used for solving the core technical pain points of insufficient monitoring precision, high false alarm rate, single alarm mode, poor unattended operation suitability, weak system operation stability, and insufficient operation convenience and scene universality which are commonly existed in the prior art, and synchronously realizing the accuracy, instantaneity, reliability and functional integrity of monitoring on the premise of low system resource occupation so as to adapt to the screen monitoring alarm requirements of various scenes, especially unattended scenes. In order to solve the problems, the technical scheme adopted by the invention is as follows: a multi-mode screen monitoring alarm method based on pixel difference detection comprises the following steps: S1, configuring a monitoring area, namely generating a full-screen transparent top-se