An alarm method based on computer vision target detection
Patent Information
- Application Number
- CN202310774466.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-28
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2043-06-28
Smart Images

Figure CN116824452B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an alarm method based on computer vision target detection. Background Art
[0002] Computer vision-based object detection technology is currently widely used in real-world production scenarios. This technology analyzes each frame of a video to determine whether it contains the desired object. For example, in real-world scenarios, the system might generate an alert if a helmet is detected.
[0003] Due to the inherent characteristics of computer vision technology, it's impossible to guarantee that every target detection result will match reality. Simply outputting an alarm message based on the target detection results for each frame wouldn't meet the requirements of real-world scenarios. Therefore, an alarm method that meets these requirements is urgently needed. Summary of the Invention
[0004] This application provides an alarm method based on computer vision target detection, the technical purpose of which is to adjust the alarm method according to different scenarios to improve the scenario applicability of computer vision-based target detection results.
[0005] The above technical objectives of this application are achieved through the following technical solutions:
[0006] An alarm method based on computer vision target detection, comprising:
[0007] S1: Traverse the detection areas in the video frame, including: determining whether the number of alarms for the tracking ID in the current detection area is less than the alarm limit. If so, proceed to step S2; otherwise, stop analyzing the current detection area and start determining the number of alarms for the tracking ID in the next detection area. The tracking ID corresponds to the target, and the same target has the same tracking ID in different video frames.
[0008] S2: Determine whether the difference between the current time and the last alarm time of the target is less than the alarm detection interval. If so, no alarm is required, and the analysis of the current detection area is stopped. The process goes to step S1 to analyze the next detection area. Otherwise, the process goes to step S3.
[0009] S3: Determine whether the target in the current detection area meets the detection requirements. If yes, it means the target is detected and the process goes to step S4. If no, it means the target is not detected and the process goes to step S6.
[0010] S4: Determine whether there is a record marked as 1 in the current video frame detection result queue. If so, go directly to step S5. If not, record the current time as the alarm analysis timing start time. The current time is the time when the target is first detected, and then go to step S5. Among them, the record marked as 1 indicates that the target is detected in the current video frame detection result queue.
[0011] S5: Record the result of the current target detection into the current video frame detection result queue, mark it as 1, and record the photo and other structured data information of the replacement event, and then go to step S7;
[0012] S6: Determine whether there is a target detection record marked as 1 in the current video frame detection result queue. If so, record the result of no target detection in the current video frame detection result queue and mark it as 0, and then go to step S7; if not, stop analyzing the current detection area and go to step S1 to analyze the next detection area; wherein, the record marked as 0 indicates that there is no target detection record in the current video frame detection result queue;
[0013] S7: Determine whether the current time is not less than a preset threshold. If so, proceed to step S8; otherwise, stop analyzing the current detection area and proceed to step S1 to analyze the next detection area of the current frame. The preset threshold is the sum of the alarm analysis timing start time and the detection area time threshold.
[0014] S8: Determine whether the sensitivity of the detection area is not less than a threshold. If so, store the alarm data in the database and issue an alarm, then go to step S9. Otherwise, go directly to step S9. The sensitivity of the detection area is the ratio of the number of times the target is detected in the current video frame detection result queue to the total number of detections.
[0015] S9: Record the alarm time, and then go to step S1 to analyze the next detection area.
[0016] Furthermore, in step S3, the detection requirements include position and size requirements, that is, whether the target is within the detection area and whether the size of the target meets the standard.
[0017] The beneficial effects of this application are as follows: the alarm method based on computer vision target detection described in this application adds alarm constraints based on computer vision analysis of video frames, including alarm number limits, alarm detection intervals, detection area time thresholds, and detection area sensitivity. By configuring the constraints, the generation of alarms is restricted. For different scenarios, different alarm requirements can be achieved by adjusting the corresponding parameters, thereby improving the scenario applicability of the computer vision-based target detection results. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is the overall flow chart of computer vision-based target detection;
[0019] Figure 2 This is a flow chart of the alarm method based on computer vision target detection described in this application. DETAILED DESCRIPTION
[0020] The technical solution of this application will be described in detail below with reference to the accompanying drawings.
[0021] Figure 1 This is a flowchart of the overall computer vision-based object detection process. The process includes: the object detection alarm system begins executing its task, obtaining an RTSP stream from the camera and decoding it to obtain video frames. It then extracts each video frame from the video frame queue for analysis, converts the YUV image into a BGR image, and feeds the BGR image into the algorithm SDK for detection. For example, the algorithm SDK for detecting a person without a helmet takes a video frame as input and outputs a detection result, which includes the location and tracking ID of the detected object. The algorithm SDK checks whether the detection result is empty. If so, the detection is invalid. The next frame is analyzed. If the detection result is not empty, the detection is valid. Finally, the detection area is traversed and the alarm rule is determined.
[0022] The warning method based on computer vision target detection described in this application is as follows Figure 2 As shown, specifically including:
[0023] S1: Traverse the detection area in the video frame, including: judging whether the number of alarms of the tracking ID in the current detection area is less than the alarm limit. If so, go to step S2; otherwise, stop analyzing the current detection area and start judging the number of alarms of the tracking ID in the next detection area; wherein, the tracking ID corresponds to the target, and the tracking ID of the same target is the same in different video frames.
[0024] Specifically, if the number of alarms for the tracking ID is not less than the alarm limit, it means that the number of alarms for this tracking ID has reached the alarm limit, and this tracking ID does not need to generate an alarm anymore. The analysis of this detection area can be stopped and the analysis of the next detection area can be continued.
[0025] For example, if you only want to generate one alarm for the same detection target, you can set the alarm limit to 1.
[0026] S2: Determine whether the difference between the current time and the last alarm time of the target is less than the alarm detection interval. If so (the alarm detection interval has not arrived), there is no need to generate an alarm, stop analyzing the current detection area, and go to step S1 to analyze the next detection area. Otherwise, go to step S3.
[0027] For example, for the same video stream, if the interval between alarms of the same type is greater than 3 seconds, the alarm detection interval can be set to 3 seconds. In addition, in the same video stream, the same type of alarm requires an alarm detection interval, but different types of alarms are not subject to the alarm detection interval restriction. For example, if an alarm for not wearing a helmet is generated at the 5th second, there is no need to consider generating an alarm for not wearing a helmet within the next 3 seconds starting from the 5th second. However, if smoking occurs within the 3 seconds starting from the 5th second, and the time between the smoking occurrence and the last smoking alarm exceeds 3 seconds, the smoking alarm needs to be further detected to determine whether a smoking alarm should be issued.
[0028] S3: Determine whether the target in the current detection area meets the detection requirements. If so, it means the target is detected and go to step S4. If not, it means the target is not detected and go to step S6.
[0029] Specifically, the detection requirements include position and size requirements, that is, whether the target is within the detection area and whether the size of the target meets the standards.
[0030] S4: Determine whether there is a record marked as 1 in the current video frame detection result queue. If so, go directly to step S5. If not, record the current time as the start time of the alarm analysis timing. The current time is the time when the target is first detected, and then go to step S5; wherein, the record marked as 1 indicates that the target is detected in the current video frame detection result queue.
[0031] S5: Record the result of the current target detection into the current video frame detection result queue, mark it as 1, and record the photo and other structured data information of the replacement event, and then go to step S7.
[0032] After the target is detected, regardless of whether there is a record marked as 1 in the current video frame detection result queue, the result of the current target detection is recorded in the current video frame detection result queue and marked as 1.
[0033] S6: Determine whether there is a target detection record marked as 1 in the current video frame detection result queue. If so, record the result of no target detection in the current video frame detection result queue and mark it as 0, and then go to step S7; otherwise, stop analyzing the current detection area and go to step S1 to analyze the next detection area; wherein, marked as 0 indicates that there is no record of target detection in the current video frame detection result queue.
[0034] S7: Determine whether the current time is not less than the preset threshold. If so, go to step S8; otherwise, stop analyzing the current detection area and go to step S1 to analyze the next detection area of the current frame; wherein the preset threshold is the sum of the alarm analysis timing start time and the detection area time threshold.
[0035] Specifically, when the current time is less than the preset threshold, it means that the time threshold of the detection area has not been reached, and the analysis of this detection area can be stopped, and it is necessary to wait for the analysis of the next frame.
[0036] S8: Determine whether the sensitivity of the detection area is not less than the threshold. If so, store the alarm data in the database and issue an alarm, and then go to step S9. Otherwise, go directly to step S9; wherein, the sensitivity of the detection area is the ratio of the number of times the target is detected in the current video frame detection result queue to the total number of detections.
[0037] In a specific embodiment, if the scenario has a high sensitivity requirement and would rather generate false alarms than miss any possible alarms, the sensitivity can be adjusted higher. If the scenario has a low sensitivity requirement and cannot generate false alarms but can miss alarms, the sensitivity can be adjusted lower.
[0038] S9: Record the alarm time, and then go to step S1 to analyze the next detection area.
[0039] This cycle completes the analysis of each detection area, and then this cycle completes the analysis of each video frame.
[0040] The above are exemplary embodiments of the present application, and the protection scope of the present application is defined by the claims and their equivalents.
Claims
1. An alarm method based on computer vision target detection, characterized in that: include: S1: Traverse the detection areas in the video frame, including: determining whether the number of alarms for the tracking ID in the current detection area is less than the alarm limit. If so, proceed to step S2; otherwise, stop analyzing the current detection area and start determining the number of alarms for the tracking ID in the next detection area. The tracking ID corresponds to the target, and the same target has the same tracking ID in different video frames. S2: Determine whether the difference between the current time and the last alarm time of the target is less than the alarm detection interval. If so, no alarm is required, and the analysis of the current detection area is stopped. The process goes to step S1 to analyze the next detection area. Otherwise, the process goes to step S3. S3: Determine whether the target in the current detection area meets the detection requirements. If yes, it means the target is detected and the process goes to step S4. If no, it means the target is not detected and the process goes to step S6. S4: Determine whether there is a record marked as 1 in the current video frame detection result queue. If so, go directly to step S5. If not, record the current time as the alarm analysis timing start time. The current time is the time when the target is first detected, and then go to step S5. Among them, the record marked as 1 indicates that the target is detected in the current video frame detection result queue. S5: Record the result of the current target detection into the current video frame detection result queue, mark it as 1, and record the photo and other structured data information of the replacement event, and then go to step S7; S6: Determine whether there is a target detection record marked as 1 in the current video frame detection result queue. If so, record the result of no target detection in the current video frame detection result queue and mark it as 0, and then go to step S7; if not, stop analyzing the current detection area and go to step S1 to analyze the next detection area; wherein, the record marked as 0 indicates that there is no target detection record in the current video frame detection result queue; S7: Determine whether the current time is not less than a preset threshold. If so, proceed to step S8; otherwise, stop analyzing the current detection area and proceed to step S1 to analyze the next detection area of the current frame. The preset threshold is the sum of the alarm analysis timing start time and the detection area time threshold. S8: Determine whether the sensitivity of the detection area is not less than a threshold. If so, store the alarm data in the database and issue an alarm, then go to step S9. Otherwise, go directly to step S9. The sensitivity of the detection area is the ratio of the number of times the target is detected in the current video frame detection result queue to the total number of detections. S9: Record the alarm time, and then go to step S1 to analyze the next detection area.
2. The method according to claim 1, wherein In step S3, the detection requirements include position and size requirements, that is, whether the target is within the detection area and whether the size of the target meets the standard.
Citation Information
Patent Citations
Video monitoring method based on local computing
CN105046682A
Personnel state analysis method based on target detection
CN112883906A