A method for alarm video composition

By employing a time-segmented and phased video synthesis method, utilizing the CLIP model and event tracking model, key frames are extracted and supplemented during idle nighttime hours. This solves the resource shortage problem caused by concurrent alarms from multiple cameras in water conservancy projects, and improves the real-time performance and completeness of alarm videos.

CN120281992BActive Publication Date: 2025-11-21NANJING NARI WATER RESOURCES & HYDROPOWER TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510756896.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-11-21
Estimated Expiration
2045-06-09

AI Technical Summary

Technical Problem

In the intelligent management of water conservancy projects, the insufficient video data processing and transmission resources caused by concurrent alarms from multiple cameras lead to a decline in system performance, network congestion, high latency and packet loss rate, affecting the real-time performance of alarms and decision-making efficiency.

Method used

A time-segmented and phased video synthesis strategy is adopted. Keyframes are extracted and synthesized into alarm videos through CLIP model and event tracking model. Idle resources at night are used for supplementation and optimization to generate efficient and complete alarm videos.

Benefits of technology

It improves the usability and completeness of alarm videos, ensures efficient system operation, reduces network bandwidth requirements, reduces packet loss rate, and ensures the real-time performance and quality of alarm videos.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120281992B_ABST
    Figure CN120281992B_ABST
Patent Text Reader

Abstract

The application provides a kind of warning video synthesis method, it is related to computer technology field, comprising: S1: original video data acquisition;S2: response alarm instruction, start the synthesis process of warning video;S3: determine alarm instruction in daytime, synthesis preliminary warning video;Obtain key period picture, select key frame in every second video picture of key period picture, carry out event tracking processing to the image of key frame, obtain the synthesized picture after identification, synthesis preliminary warning video;S4: in the night or idle period;Re-identification processing and integration of key period picture are carried out to frame and are integrated, synthesis warning video.The application is through the video synthesis strategy of time-sharing, stage-by-stage, guarantees the efficient operation of system, improves the practicability and integrity of warning video, the efficiency and reliability of system are high.Avoid network congestion, transmission speed is high, real-time is strong, avoids lag collapse;Give consideration to system performance and the quality of final warning video.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method for synthesizing alarm videos. Background Technology

[0002] In the field of intelligent management of water conservancy projects, the combination of video surveillance and artificial intelligence (AI) analysis technology has become a key means to improve project safety and management efficiency, especially in scenarios such as water diversion projects, sluice gate and pumping station management, and slope monitoring. AI algorithm platforms are deployed at the edge of county and township-level water conservancy facilities (such as pumping stations, sluice gates, and slope monitoring points), undertaking the core tasks of real-time monitoring and risk warning. However, in actual deployment and application, especially when dealing with complex and changeable natural environments and sudden events (such as rainstorms and floods), multiple cameras (e.g., 10 cameras) are prone to concurrent alarms, instantly generating a large amount of video data to be processed and transmitted. This video data typically needs to be processed into alarm videos 10 seconds before and after the alarm event and transmitted back to the central control center of the main station via network channels for review and decision-making. At this point, the following technical problems arise:

[0003] 1. When generating alarm videos, the system needs to process a large amount of video data and alarm events. Video encoding and processing consume a lot of computing resources, which leads to a decrease in system performance and may even cause lag or crashes.

[0004] 2. The transmission of video data requires a large amount of network bandwidth, which can lead to network congestion, increase video transmission latency, and affect the real-time performance of alarms.

[0005] 3. County and township water conservancy stations are often deployed in remote areas or areas with weak network infrastructure. The hardware resources of these substations and the bandwidth for transmission to the main station are limited. The instantaneous bandwidth demand for alarm video feedback generated by multiple concurrent alarms far exceeds the available bandwidth, leading to a surge in packet loss rates, further exacerbating transmission delays, creating a vicious cycle, and increasing the risk of decision-making delays. Therefore, resolving the issues of concurrent processing and transmission timeliness caused by insufficient resources is an urgent technical problem to be solved. Summary of the Invention

[0006] The purpose of this invention is to address the shortcomings of existing technologies by proposing a method for synthesizing alarm videos.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] A method for synthesizing alarm videos includes the following steps:

[0009] S1: Raw video data acquisition;

[0010] During daily operation, video stream data is collected through cameras and stored in the database to form raw video data;

[0011] S2: Respond to the alarm command and start the alarm video synthesis process;

[0012] Set the duration of the alarm video, respond to the alarm command, and obtain the key time period footage from the raw video data; the key time period footage covers half the duration of the alarm video before and after the alarm occurs;

[0013] The alarm command includes the alarm command time and the alarm source; the alarm command time is the time when the alarm command is triggered, and the alarm source is the raw video data collected by the camera that triggered the alarm;

[0014] S3: Determine if the alarm command occurred during the day, and synthesize a preliminary alarm video;

[0015] Based on the alarm command time, determine whether the alarm command is from daytime or nighttime. If the alarm command time is determined to be from daytime, select only one representative frame from each second of the video footage during the key period. Use these key frames to quickly stitch together video segments and synthesize a preliminary alarm video.

[0016] S31: Determine if the alarm command occurred during the day;

[0017] Set the daytime and nighttime time periods, compare the alarm command time with the daytime and nighttime time periods, and determine whether the alarm command is in the daytime time period. If it is in the daytime time period, it is determined that the alarm command is in the daytime, and then proceed to step S32; otherwise, the alarm command is in the nighttime. If the alarm command is in the nighttime, then proceed directly to step S4.

[0018] S32: Select keyframes from each second of video footage within the critical time period;

[0019] S33: Process keyframes and quickly stitch them together in chronological order to form a video segment of the duration of an alarm video.

[0020] The event tracking model is pre-trained using training data. The key frame images are pre-processed and input into the corresponding event tracking model to output the recognition result, which is a set of coordinates. The coordinates of the recognition result are colored to obtain the recognized composite image. The composite image is then stitched together according to the time sequence of each frame to form a video of the alarm video duration.

[0021] S4: During the night or off-peak hours, reprocess and integrate the footage from key periods to synthesize a complete alarm video;

[0022] During the evening or off-peak hours, the remaining video frames within the alarm period are supplemented. By reprocessing and integrating the footage from the critical period, a complete alarm video with normal frame rate and smooth playback is synthesized.

[0023] Furthermore, step S1 includes the following steps:

[0024] The area is planned, and multiple cameras are set up in each area as needed to monitor different events. Each camera has an identification code, and the collected video stream data is stored as raw video data according to the camera's identification code.

[0025] Construct a mapping table between cameras and monitoring events, including camera identification code, monitoring event, and camera location area;

[0026] The monitored events include water accumulation, floating objects, intrusion by personnel, and water level.

[0027] Furthermore, step S32 includes: S321: Dividing the key time period footage into multiple second-by-second video segments;

[0028] S322: The CLIP model encodes video frames and generates feature vectors;

[0029] First, each frame in the video is preprocessed, including resizing, normalizing, and converting to Tensor format;

[0030] Next, load the pre-trained CLIP model and use the transformers library or OpenAI's CLIP image encoder; input the pre-processed Tensor format video per second into the CLIP image encoder to generate fixed-dimensional feature vectors;

[0031] Finally, iterate through all frames in the 2-second video and store the feature vectors of all frames in the same list.

[0032] S323: Calculate similarity and output keyframes;

[0033] Initialize an empty list as a keyframe list to store keyframes. Take the first frame of the 1-second video as the initial keyframe and store its feature vector in the keyframe list. Iterate through the feature vectors of subsequent frames, calculate the cosine similarity between the feature vectors of the current frame and the previous keyframe, store the calculated cosine similarity, compare the magnitudes of all cosine similarities, and add the feature vector of the current frame with the smallest cosine similarity to the keyframe list. Output the current frame as a keyframe and store it as an image format. Record the frame number and timestamp of the keyframe.

[0034] S324: Traverse all the second-second videos, repeat steps S322 and S322 to output the keyframes of each second-second video segment, and store them as image formats.

[0035] Furthermore, step S33 includes:

[0036] S331: Training the event tracking model;

[0037] The event tracking model is trained using deep neural network algorithms, YOLO algorithms, or OCR algorithms; a model library is installed, and the model is trained using training data to obtain the bounding box coordinates of the identified targets; the training data includes videos or images of various events, including water accumulation, floating objects, intrusion, and water levels; different event tracking models are trained according to different events and stored on the server;

[0038] S332: Preprocessing of the keyframe image;

[0039] S333: Input the preprocessed image into the corresponding event tracking model to obtain the recognition result;

[0040] Based on the alarm source, obtain the identification code of the surveillance camera. Based on the correspondence table of surveillance events, obtain the surveillance event corresponding to the camera identification code. Call the same event tracking model as the surveillance event. Input the preprocessed image into the event tracking model to obtain the recognition result. The recognition result is the bounding box coordinates of the recognized target.

[0041] S334: Colorize the recognition result to obtain a composite image;

[0042] OpenCV is used to draw bounding boxes on keyframe images based on bounding box coordinates, and color is filled within the bounding box regions; finally, the images are stored as composite images.

[0043] S335: The composite images are stitched together in chronological order of each frame to form a preliminary alarm video;

[0044] Based on the order of timestamps, the composite images are stored in a preliminary composite list. A video writer is created, the display time of each composite image is set, all composite images in the composite list are traversed, and the composite images are written to the video frame by frame in chronological order to form a preliminary alarm video. Finally, the preliminary alarm video is transmitted to the monitor for display.

[0045] Furthermore, step S4 includes:

[0046] S41: Video Frame Completion: Reacquire all video frames of the key time period and remove key frames with recorded frame numbers;

[0047] S42: Video frame processing: After preprocessing the images of the video frames, input them into the event tracking model. After recognition processing, colorize the recognition results to generate a composite image of the video frame; traverse and process all video frames to obtain the composite image of the video frame and store it in the composite video list.

[0048] S43: Video Encoding and Processing: Obtain composite images from the initial composite list, insert them into the composite video list in timestamp order, and complete the video frames in the composite video list; use an encoder to re-encode and process the completed video frames;

[0049] S44: Video Composition: Combine the processed video frames in chronological order to generate the final alarm video;

[0050] S45: Quality Inspection and Optimization: Perform a quality inspection on the synthesized alarm video to ensure that the video's clarity, smoothness, and other indicators meet the requirements; if there are any issues with the video quality, further optimization will be performed.

[0051] S46: Video storage and transmission: Transmit the synthesized final alarm video and store it in the database.

[0052] Furthermore, step S31 also includes: detecting server resources, determining whether the server is idle based on the occupancy of each resource, and if it is idle, proceeding directly to step S4; otherwise, proceeding to step S32.

[0053] Server resources include bandwidth, memory, and graphics card; resource utilization refers to the usage of various resources on the server, expressed as utilization rate; set judgment thresholds for each resource, with bandwidth at 60%, memory at 70%, and graphics card at 60%; compare the utilization rate of each resource with the corresponding judgment threshold; if the resource utilization rate is less than the judgment threshold, it is judged as idle, otherwise it is judged as high load, and step S32 is executed.

[0054] Furthermore, in step S2, the duration of the alarm video is set to 10 seconds. Based on the alarm command time, 5 seconds of video before the alarm command time and 5 seconds of video after the alarm command time are extracted from the original video data of the alarm source.

[0055] Furthermore, the fill colors include green and red; adjust the color transparency to 50%-60%.

[0056] Further optimization processes include removing redundant frames, setting an appropriate frame rate, optimizing video encoding, enhancing image quality, and reducing noise.

[0057] Through the above methods and steps, the system can make full use of computing resources and network bandwidth during off-peak hours at night to improve the initial alarm video, thereby enhancing the practicality and completeness of the alarm video.

[0058] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) The present invention, through a time-segmented and phased video synthesis strategy, ensures efficient system operation while maximizing the practicality and completeness of alarm videos, which helps to improve the efficiency and reliability of the entire video surveillance and alarm system. (2) The alarm video synthesis method of the present invention takes into account both the system performance during peak business hours in the daytime and ensures the quality of the final alarm video. (3) Although the frame rate of the initially synthesized video is low, it is sufficient to present the general situation of the alarm event in the first time and meet the initial alarm requirements. The number of video frames processed is small, which reduces the number of events processed in the video, ensuring the real-time nature of the initial alarm. The low frame rate of the initial alarm video ensures the size of the video, avoids occupying a large amount of network bandwidth during transmission, avoids network congestion, improves transmission speed, and reduces the probability of packet loss, thus ensuring the real-time nature of the alarm video. (4) The present invention processes the data in time periods and stages to ensure that when multiple tasks are processed concurrently and server resources are occupied at high levels, a preliminary alarm video can be obtained by processing a small number of key frames. The processing computation occupies less computing resources, ensuring running performance and avoiding resource overload and lag / crash. Attached Figure Description

[0059] Figure 1 This is a flowchart illustrating the steps of an alarm video synthesis method according to the present invention. Detailed Implementation

[0060] To provide a further understanding of the purpose, structure, features, and functions of the present invention, detailed descriptions are provided below with reference to specific embodiments.

[0061] A method for synthesizing alarm videos includes the following steps:

[0062] S1: Raw video data acquisition;

[0063] During daily operation, video stream data is collected through cameras and stored in a database to form raw video data for retrieval and use.

[0064] During deployment, areas are planned, and cameras are set up in each area as needed. Multiple cameras can be set up to monitor different events. Each camera has a unique identification code, which serves as its identity. The collected video stream data is stored as raw video data according to the camera's identification code.

[0065] Construct a mapping table between cameras and monitoring events, including camera identification code, monitoring event, and camera location;

[0066] The monitored events include water accumulation, floating objects, intrusion, and water levels.

[0067] S2: Respond to the alarm command and start the alarm video synthesis process;

[0068] The alarm video duration is set to 10 seconds. In response to the alarm command, key time period footage is obtained from the raw video data. The key time period footage includes 5 seconds before the alarm occurs and 5 seconds after the alarm occurs. This covers the entire event process. By editing out the key time period footage, the amount of video processing is reduced, processing time is saved, and the real-time nature of alarm video synthesis is ensured.

[0069] An alarm command includes the alarm command time and the alarm source. The alarm command time is the time when the alarm command is triggered.

[0070] The alarm source is the raw video data collected by the camera that triggered the alarm. Based on the alarm command time, the video of 5 seconds before the alarm command time and 5 seconds after the alarm command time is extracted from the raw video data of the alarm source.

[0071] S3: Determine if the alarm command occurred during the day, and synthesize a preliminary alarm video;

[0072] Based on the alarm command time, determine whether the alarm command is from daytime or nighttime. If the alarm command time is determined to be from daytime, select only one representative frame from each second of the video footage during the key period. Quickly stitch these key frames together to form a 10-second video clip and perform preliminary video synthesis.

[0073] Includes the following steps:

[0074] S31: Determine if the alarm command occurred during the day;

[0075] The daytime period is defined as 9:00 to 18:00, and the nighttime period is defined as 18:00 to 24:00 and 0:00 to 9:00. The alarm command time is compared with the daytime period and the nighttime period to determine whether the alarm command is in the daytime period. If it is in the daytime period, the alarm command is determined to be in the daytime period, and step S32 is executed; otherwise, the alarm command is in the nighttime period. If the alarm command is in the nighttime period, step S4 is executed directly.

[0076] Furthermore, the server resources are checked, and the server is determined to be idle based on the usage of each resource. If the server is idle, step S4 is executed directly; otherwise, step S32 is executed.

[0077] Server resources include bandwidth, memory, and graphics cards; the utilization of each resource represents its usage on the server, expressed as utilization rate. Set judgment thresholds for each resource, such as 60% for bandwidth, 70% for memory, and 60% for graphics cards. Compare the utilization rate of each resource with its corresponding judgment threshold. If the resource utilization rate is less than the judgment threshold, it is judged as idle; otherwise, it is judged as high load, and step S32 is executed. Reasonably plan computing resources, optimize computing resource utilization, ensure operational stability, and avoid lag and crashes.

[0078] S32: Select keyframes from each second of video footage within the critical time period;

[0079] S321: Divide the footage of key time periods into multiple second-level videos;

[0080] S322: The CLIP model encodes video frames and generates feature vectors.

[0081] First, each frame in the video is preprocessed, including resizing, normalizing, and converting to Tensor format;

[0082] Next, load the pre-trained CLIP model, which can be done using the transformers library or OpenAI's CLIP image encoder; input the pre-processed tensor-formatted second-by-second video into the CLIP image encoder to generate fixed-dimensional feature vectors, which can be stored as 512 dimensions. The CLIP model can capture the semantic information of the image and generate high-dimensional feature vectors. The generated feature vectors have semantic consistency and are suitable for cross-frame comparison.

[0083] Finally, all frames in the 1-second video are processed, and the feature vectors of all frames in the 1-second video are stored in the same list for easy comparison of video frames.

[0084] S323: Calculate similarity and output keyframes;

[0085] Initialize an empty list as the keyframe list to store keyframes. Use the first frame of the 1-second video as the initial keyframe and store its feature vector in the keyframe list. Iterate through the feature vectors of subsequent frames, calculating the cosine similarity between the feature vectors of the current frame and the previous keyframe, using the formula: Cosine Similarity = ... Where A and B are the feature vectors of the current frame and the previous keyframe, respectively. and It is the modulus of feature vectors A and B. The calculated cosine similarity is stored, and all cosine similarities are compared. The feature vector of the current frame with the smallest cosine similarity is added to the keyframe list, and the current frame is output as a keyframe and stored as an image. The frame number and timestamp of the keyframe are recorded. Using cosine similarity effectively measures the similarity of high-dimensional vectors. The calculation is simple and efficient, meeting the needs of large-scale frame processing, and the processing speed is fast. By extracting keyframes, the differences between keyframes are ensured, redundancy is avoided, and important changes in the video are preserved. The extracted keyframes are more representative, ensuring that the approximate situation of alarm time is presented in actual use.

[0086] A video frame number is a unique identifier for each frame in a video sequence, used to identify each frame in the video stream during video encoding. A timestamp is a time stamp corresponding to each frame of video data.

[0087] S324: Traverse all the second-second videos, repeat steps S322 and S322 to output the keyframes of each second-second video segment, and store them as image formats.

[0088] S33: Process keyframes and quickly stitch them together into a 10-second video clip in chronological order;

[0089] An event tracking model is pre-trained using training data. The keyframe images are pre-processed and input into the corresponding event tracking model to output recognition results, which are a set of coordinates. The coordinates of the recognition results are colored to obtain a synthesized image. The synthesized image is then stitched together into a 10-second video according to the time sequence of each frame.

[0090] Although this initial synthesized video has a low frame rate, it is sufficient to present the general situation of the alarm event in a timely manner, meeting the initial alarm requirements. The small number of video frames processed ensures the real-time nature of the initial alarm, while the low frame rate limits the video size, avoiding excessive network bandwidth consumption during transmission, preventing network congestion, improving transmission speed, and ensuring the real-time performance of the alarm video.

[0091] S331: Training the event tracking model;

[0092] The event tracking model is trained using deep neural network algorithms, YOLO algorithms, or OCR algorithms. A model library is installed, and the model is trained using training data to obtain the bounding box coordinates of the identified targets. The training data includes videos or images of various events, similar to those monitored, including water accumulation, floating objects, intrusion, and water levels. Different event tracking models are trained for different events and stored on a server. This ensures the ability to track and recognize images and text. The training of the tracking model is prior art in this field and is not an inventive solution of this application; therefore, it will not be elaborated upon here.

[0093] S332: Preprocessing of the keyframe image;

[0094] This includes image resizing, normalization, binarization, and noise reduction for keyframes;

[0095] S333: Input the preprocessed image into the corresponding event tracking model to obtain the recognition result;

[0096] Based on the alarm source, the identification code of the surveillance camera is obtained. According to the mapping table of monitoring events, the monitoring event corresponding to the camera identification code is obtained. The same event tracking model as the monitoring event is called. The pre-processed image is input into the event tracking model to obtain the recognition result, which is the bounding box coordinates of the identified target. The alarm source determines the event tracking model to use. By using multiple models, different events can be processed and identified separately, achieving concurrent processing, accurate event processing, optimized resource utilization, and reduced resource waste. By training different recognition models, high recognition accuracy is achieved, avoiding false or missed identifications.

[0097] S334: Colorize the recognition result to obtain a composite image;

[0098] Using OpenCV, bounding boxes are drawn on keyframe images based on their coordinates. The bounding box areas are then filled with color (such as green or red), with the opacity adjusted to 50%-60%. Finally, the images are saved as composite images. This color shading ensures that the process of triggering events is clearly displayed during video playback, resulting in good visual effects, facilitating analysis, and offering ease of use.

[0099] S335: Stitch the composite images together into a 10-second video according to the time sequence of each frame;

[0100] Based on the order of timestamps, the composite images are stored in the preliminary composite list. A video writer is created, and the display time of each composite image is set (1 second per image). All composite images in the composite list are traversed, and the composite images are written frame by frame into the video in chronological order to form a 10-second preliminary alarm video. Finally, the preliminary alarm video is transmitted to the monitor for display.

[0101] S4: During the night or off-peak hours, reprocess and integrate the footage from key periods to synthesize a complete alarm video;

[0102] During the evening or off-peak hours, the remaining video frames within the alarm period are supplemented. By reprocessing and integrating the footage from the critical period, a complete 10-second alarm video with normal frame rate and smooth playback is synthesized.

[0103] S41: Video Frame Completion: Reacquire all video frames from the critical time period, remove the key frames with the recorded frame numbers, and the remaining video frames are those not selected during the initial synthesis. The purpose of this step is to ensure the integrity and smoothness of the alarm video.

[0104] S42: Video frame processing: The processing method is the same as S33. After preprocessing the video frame image, it is input into the event tracking model. After recognition processing, the recognition result is colored to generate a composite image of the video frame. All video frames are traversed and processed to obtain the composite image of the video frame and stored in the composite video list.

[0105] S43: Video Encoding and Processing: Obtain composite images from the initial composite list, insert them into the composite video list in timestamp order, and complete the video frames in the composite video list; use an encoder to re-encode and process the completed video frames to ensure that the video quality and frame rate meet the standards.

[0106] S44: Video Composition: Combine the processed video frames in chronological order to generate a complete 10-second alarm video with normal frame rate and smooth playback.

[0107] S45: Quality Check and Optimization: Perform a quality check on the synthesized alarm video to ensure that the video's clarity, smoothness, and other indicators meet the requirements. If video quality issues are found, further optimization can be performed, including removing redundant frames, setting an appropriate frame rate, optimizing video encoding, enhancing image quality, and reducing noise. This ensures high-quality final alarm video, guaranteeing both smoothness and clarity.

[0108] S46: Video storage and transmission: Transmit and store the synthesized 10-second alarm video to the database.

[0109] Through the above methods and steps, the system can make full use of computing resources and network bandwidth during off-peak hours at night to improve the initial alarm video, thereby enhancing the practicality and completeness of the alarm video.

[0110] The present invention has been described in the above-described embodiments; however, these embodiments are merely examples for implementing the present invention. It must be noted that the disclosed embodiments do not limit the scope of the present invention. Conversely, any modifications and refinements made without departing from the spirit and scope of the present invention are within the scope of patent protection of the present invention.

Claims

1. A method of alarm video composition, characterized by: Comprise the following steps: S1: original video data acquisition; In the process of daily operation, video stream data is collected through the camera, and the collected video stream data is stored in the database to form the original video data; S2: in response to the alarm instruction, start the synthesis process of the alarm video; Set the duration of the alarm video, and obtain the key period pictures from the original video data in response to the alarm instruction; The key period pictures cover the video pictures of the half duration of the alarm video before and after the alarm occurs; The alarm instruction contains the alarm instruction time and the alarm source; The alarm instruction time is the time when the alarm instruction is triggered, and the alarm source is the original video data collected by the camera that triggers the alarm; S3: judge the alarm instruction in the daytime, and synthesize the preliminary alarm video; According to the alarm instruction time, it is judged whether the alarm instruction is in the daytime or at night. If it is judged that the alarm instruction time is in the daytime, only one representative frame is selected in each second of the video picture in the key period picture, and the video segment is quickly spliced through these key frames to synthesize the preliminary alarm video; S31: judge whether the alarm instruction is in the daytime; Set the time period of the daytime and the time period of the night, set the daytime as the time period of 9:00 to 18:00, the night as the time period of 18:00 to 24:00, 0:00 to 9:00; Compare the alarm instruction time with the time period of the daytime and the time period of the night, judge whether the alarm instruction is in the daytime, if it is in the daytime, determine that the alarm instruction is in the daytime, then execute step S32; Otherwise, the alarm instruction is at night, if the alarm instruction is at night, directly proceed to step S4; S32: select key frames in each second of the video picture in the key period picture; S33: process the key frames, and quickly splice the key frames into a video segment with the duration of the alarm video according to the time sequence; Pre-train the event tracking model, train the model using training data, obtain the event tracking model, input the image of the key frame into the corresponding event tracking model after preprocessing, output the recognition result, the recognition result is a group of coordinates; The coordinates of the recognition result are colored using color to obtain the synthesized picture after recognition, and the synthesized picture is spliced into a video with the duration of the alarm video according to the time sequence of each frame; S4: reprocess and integrate the key period pictures in the night or idle period to synthesize a complete alarm video; If there is a preliminary alarm video synthesized in step S3, in the night or idle period, the remaining video frames in the alarm time period of the preliminary alarm video are filled, and a complete alarm video with normal frame rate and smooth picture is synthesized through reprocessing and integration of the key period pictures; If the alarm instruction is at night, the key period pictures obtained are processed in the night or idle period, and a complete alarm video with normal frame rate and smooth picture is synthesized.

2. The method of alarm video composition of claim 1, wherein: Step S1 comprises the following steps: Plan the area, set the camera in each area as needed, the camera is multiple, respectively monitor different events; Each camera has an identification code, and the video stream data collected is stored as original video data according to the identification code of the camera; A correspondence table of the camera and the monitoring event is constructed, including a camera identification code, a monitoring event, and a region where the camera is located. The monitoring event includes water accumulation, floating objects, personnel intrusion, and water level.

3. The method of alarm video composition of claim 2, wherein: Step S32 includes: S321: dividing the key period picture into multiple second videos by seconds; S322: encoding the video frames by the CLIP model to generate feature vectors; First, each frame in the second video is preprocessed, including resizing, normalization, and conversion to Tensor format; Next, the pre-trained CLIP model is loaded, using the transformers library or the CLIP image encoder of OpenAI; the preprocessed second video in Tensor format is input into the CLIP image encoder to generate feature vectors of fixed dimensions; Finally, all frames in the second video are processed, and the feature vectors of all frames in the second video are stored in the same list; S323: calculating the similarity and outputting the key frame; An empty list is initialized as a key frame list for storing key frames, the first frame of the second video is taken as the initial key frame, and the feature vector of the first frame is stored in the key frame list; the feature vectors of the subsequent frames are traversed, the cosine similarity between the current frame and the feature vector of the previous key frame is calculated, the calculated cosine similarity is stored, and the sizes of all cosine similarities are compared to obtain the feature vector of the current frame with the smallest cosine similarity, which is added to the key frame list, and the current frame is output as a key frame and stored in image format; the frame number and timestamp of the key frame are recorded; 4. The method of alarm video composition of claim 3, wherein: S324: traversing all second videos, repeating steps S322 and S322 to output the key frames of each second video and store them in image format. Step S33 includes: S331: training the event tracking model; Using deep neural network algorithms, YOLO algorithms, or OCR algorithms to train the event tracking model; installing the model library, training the model using training data to obtain the bounding box coordinates of the identified target; the training data contains videos or images of various events, including water accumulation, floating objects, personnel intrusion, and water level; different event tracking models are trained according to different events and stored in the server; S332: preprocessing of the image of the key frame; S333: inputting the preprocessed image into the corresponding event tracking model to obtain the recognition result; According to the alarm source, the identification code of the monitoring camera is obtained, the corresponding monitoring event of the camera identification code is obtained according to the correspondence table of the monitoring event, the same event tracking model as the monitoring event is called, the preprocessed image is input into the event tracking model, and the recognition result is obtained, which is the bounding box coordinates of the identified target; S334: coloring the recognition result to obtain a composite picture; Using OpenCV to draw a bounding box on the key frame image according to the bounding box coordinates and fill the color in the bounding box area; finally, the picture is stored as a composite picture; S335: splicing the composite picture into a preliminary alarm video according to the time sequence of each frame; According to the time stamp of the synthetic picture stored in the preliminary synthesis list in the order, a video writer is created, the display time of each synthetic picture is set, all synthetic pictures in the synthesis list are traversed, and the synthetic pictures are written into the video frame by frame according to the time sequence to form a preliminary alarm video, and finally the preliminary alarm video is transmitted to the display for display.

5. The method of alarm video composition of claim 4, wherein: Step S4 comprises: S41: Video frame completion: reacquire all video frames of the key period picture, and eliminate the recorded key frame of the frame number; S42: Video frame processing: input the image of the video frame into the event tracking model after pretreatment, generate the synthetic picture of the video frame by coloring the recognition result after identification processing; all video frames are processed to obtain the synthetic picture of the video frame and stored in the synthesis video list; S43: Video encoding and processing: obtain the synthetic picture from the preliminary synthesis list, insert it into the synthesis video list according to the time stamp order, and complete the video frames in the synthesis video list; the completed video frames are re-encoded and processed using an encoder; S44: Video synthesis: the processed video frames are synthesized according to the time sequence to generate the final alarm video; S45: Quality inspection and optimization: the synthesized alarm video is subjected to quality inspection to ensure that the definition and smoothness of the video meet the requirements; if there is a problem with the video quality, further optimization processing is performed; S46: Video storage and transmission: the synthesized final alarm video is transmitted and stored in the database.

6. The method of alarm video composition of claim 1, wherein: In step S2, the time length of the alarm video is set to 10 seconds, and according to the alarm instruction time, 5 seconds of video before the alarm instruction time and 5 seconds of video after the alarm instruction time are intercepted from the original video data of the alarm source.

7. The method of alarm video composition of claim 4, wherein: The filling color includes green and red, and the transparency of the color is adjusted to 50%-60%.

8. The method of alarm video composition of claim 5, wherein: The optimization processing includes removing redundant frames, setting a suitable frame rate, video encoding optimization, image quality enhancement, and noise reduction processing.

Citation Information

Patent Citations

  • Video information acquisition method and device

    CN112419639A

  • Distributed PLC edge computing system and data processing method thereof

    CN116540619A