Optimization method for accelerating video recognition and terminal
By using fast frame extraction and frame-by-frame detection technology at preset intervals in video recognition, the problem of low video recognition efficiency is solved, resource saving and detection efficiency are improved, and it can adapt to the needs of different video stream lengths and system performance.
Patent Information
- Application Number
- CN202410825133.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-25
AI Technical Summary
In the existing video recognition process, GPU resources are expensive and limited, resulting in low video recognition efficiency. Usually only 1-2 frames per second of video can be read for analysis, which affects the efficiency of the entire video recognition.
An optimized method for accelerating video recognition is adopted to quickly detect frames in the video stream at preset intervals. If an abnormal frame is detected, it will be detected frame by frame within the preset time range before and after it, until the detection ends when the alarm rules are met. ; If no abnormal frames are found, the interval is shortened and the detection is repeated until all frames are detected.
Through fast frame extraction processing and frame-by-frame detection at preset intervals, computer resources are saved, the identification of invalid frames is reduced, and the detection efficiency of video streams is improved. The detection frequency is dynamically adjusted according to the actual situation to ensure the timely discovery of abnormal frames and the utilization of system resources. Optimize usage.
Smart Images

Figure CN118609030A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video detection, and in particular to an optimization method and a terminal for accelerating video recognition. Background Art
[0002] In the current common video recognition process, it is usually necessary to extract video frames in sequence. Usually, there are dozens of frames in one second of video, and the generated frame images need to be analyzed by the large AI model. Since the large AI model will take up a lot of GPU resources in the process of analyzing images, and GPU resources require expensive graphics cards to provide, so considering the comprehensive cost, currently only 1-2 frames of images are read for analysis and processing in each second of video, and an alarm prompt is issued when the analysis results meet certain conditions.
[0003] Due to the above reasons, most video recognition is done in seconds, with frames extracted and recognized in sequence. After extracting multiple consecutive frames, the AI large model program is called in serial or parallel mode for image recognition. In this process, the efficiency of the entire video recognition is limited to a certain extent due to the expensive and limited GPU computing resources. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide an optimization method and a terminal for accelerating video recognition, so as to solve the problem of low efficiency in the video recognition process.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0006] An optimization method for accelerating video recognition comprises the steps of:
[0007] S1, perform fast frame sampling detection on the entire video stream at a preset interval, if an abnormal frame is detected, proceed to step S2; otherwise, proceed to step S3;
[0008] S2, perform frame-by-frame detection within a preset time range before and after the abnormal frame. If the detected abnormal frame meets the alarm rule, end the detection and alarm processing; otherwise, proceed to step S3;
[0009] S3. Determine whether all frames of the video stream have been detected. If so, end the detection; if not, shorten the preset interval and return to step S1.
[0010] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0011] An optimized terminal for accelerating video recognition includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor completes the following steps when executing the computer program:
[0012] S1, perform fast frame sampling detection on the entire video stream at a preset interval, if an abnormal frame is detected, proceed to step S2; otherwise, proceed to step S3;
[0013] S2, perform frame-by-frame detection within a preset time range before and after the abnormal frame. If the detected abnormal frame meets the alarm rule, end the detection and alarm processing; otherwise, proceed to step S3;
[0014] S3. Determine whether all frames of the video stream have been detected. If so, end the detection; if not, shorten the preset interval and return to step S1.
[0015] The beneficial effects of the present invention are: providing an optimization method and terminal for accelerating video recognition, preferentially performing fast frame extraction processing on the entire video at a preset interval, that is, performing a rough inspection on the entire video stream, the preset interval can be between 1-10 seconds, and is selected as appropriate according to the length of the video stream. If an abnormal frame is detected, further frame-by-frame detection is performed near the abnormal frame until the detected abnormal frame image meets the alarm rule, then other parts are not detected, and the detection is directly terminated and the alarm processing is performed, saving computer resources, reducing the recognition of invalid frames, and improving processing efficiency; if the above-mentioned rough inspection process does not find an abnormal frame, the preset interval is shortened, and the video stream is detected again until all frames of the entire video stream are not detected abnormal, and the detection is terminated; if an abnormal frame is found after the interval is shortened, frame-by-frame detection is performed according to the above steps, thereby improving the detection efficiency of the video stream and reducing resource occupancy. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flow chart of an optimization method for accelerating video recognition in an embodiment of the present invention;
[0017] Figure 2 A schematic diagram of an optimized terminal for accelerating video recognition in an embodiment of the present invention;
[0018] Description of labels:
[0019] 1. An optimized terminal for accelerating video recognition; 2. Memory; 3. Processor. DETAILED DESCRIPTION
[0020] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0021] Please refer to Figure 1, an optimization method for accelerating video recognition, characterized in that it includes the steps of:
[0022] S1, perform fast frame sampling detection on the entire video stream at a preset interval, if an abnormal frame is detected, proceed to step S2; otherwise, proceed to step S3;
[0023] S2, perform frame-by-frame detection within a preset time range before and after the abnormal frame. If the detected abnormal frame meets the alarm rule, end the detection and alarm processing; otherwise, proceed to step S3;
[0024] S3. Determine whether all frames of the video stream have been detected. If so, end the detection; if not, shorten the preset interval and return to step S1.
[0025] From the above description, it can be seen that the beneficial effects of the present invention are: priority is given to performing fast frame extraction processing on the entire video at a preset interval, that is, a rough inspection is performed on the entire video stream. The preset interval can be between 1-10 seconds, which is selected as appropriate according to the length of the video stream. If an abnormal frame is detected, further frame-by-frame detection is performed near the abnormal frame until the detected abnormal frame image meets the alarm rule, then other parts are no longer detected, and the detection is directly ended and the alarm processing is performed, saving computer resources and improving processing efficiency; if the above rough inspection process does not find an abnormal frame, the preset interval is shortened, and the video stream is detected again until all frames of the entire video stream are not detected with abnormalities, and the detection is ended; if an abnormal frame is found after the interval is shortened, frame-by-frame detection is performed according to the above steps, thereby improving the detection efficiency of the video stream and reducing resource occupancy.
[0026] It can be understood that the warning rules are specific rules set according to actual conditions. For example, for the determination of running a red light at an intersection, if the frame image contains information of running a red light before, during and after the intersection, it is considered that the warning rules are met; or, for detecting the behavior of riding an electric bike without wearing a helmet, if the frame image shows that the driver does not wear a helmet for 3-5 seconds continuously during driving, it is considered that the warning rules are met.
[0027] In an embodiment of the present invention, the step S1 further comprises the steps of:
[0028] The video stream is sampled and collected at preset intervals, and the action of collecting each frame image is sent to the message queue. The consumer is controlled to request the AI model to detect the frame image based on the message in the consumption queue, and the detected frame image and the corresponding detection results are cached in the database.
[0029] From the above description, it can be seen that each sampled frame image and its detection results are recorded and cached, which is convenient for joint verification with other abnormal frame images in the subsequent detection process, so as to determine whether the alarm rules are met, thereby improving the versatility of the above method.
[0030] In an embodiment of the present invention, the step S2 further comprises the steps of:
[0031] The frame images within the preset time range are compared with the frame images in the database for consistency, the frame images that have been detected in the database are filtered out, and the remaining frame images are detected using the AI model.
[0032] From the above description, it can be seen that when detecting frame by frame near the abnormal frame, the frame images that have been detected before are first filtered out to reduce the repeated recognition process and improve processing efficiency.
[0033] In an embodiment of the present invention, the messages in the message queue include a unique identifier of a frame image, a frame timestamp, and a video stream identifier. The consumer requests the AI model to detect the frame image based on the message, and stores the detection result together with the unique identifier of the frame image and the frame timestamp in a database.
[0034] From the above description, we can know that the messages in the message queue include the unique ID of the frame image, the frame timestamp and the video stream ID, which can ensure the accurate positioning and management of the detection results of each frame image. Consumers request the AI model to perform detection based on the message, and store the detection results together with the unique ID and timestamp of the frame image in the database to facilitate subsequent detection result query and tracking management.
[0035] In an embodiment of the present invention, step S3 further includes the steps of:
[0036] Before shortening the preset interval, the current detection frequency and system performance are evaluated, and the preset interval is dynamically adjusted.
[0037] From the above description, it can be seen that before shortening the preset interval, the method dynamically adjusts the preset interval by evaluating the current detection frequency and system performance, so that the system can optimize the detection frequency according to the actual situation. This can ensure the timely discovery of abnormal frames and avoid excessive consumption of system resources, thereby improving the intelligence and adaptive capabilities of the system.
[0038] Please refer to Figure 2 , an optimization terminal for accelerating video recognition, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor completes the steps in an optimization method for accelerating video recognition when executing the computer program.
[0039] From the above description, it can be seen that an execution carrier of an optimization method for accelerating video recognition is provided. In the process of executing the above method, the entire video is preferentially subjected to fast frame extraction processing at a preset interval, that is, a rough inspection is performed on the entire video stream. The preset interval can be between 1 and 10 seconds, which is selected as appropriate according to the length of the video stream. If an abnormal frame is detected, further frame-by-frame detection is performed near the abnormal frame until the detected abnormal frame image meets the alarm rule, then other parts are not detected, and the detection is directly terminated and the alarm processing is performed, thereby saving computer resources and improving processing efficiency; if the above rough inspection process does not find an abnormal frame, the preset interval is shortened, and the video stream is detected again until all frames of the entire video stream are not detected to be abnormal, and the detection is terminated; if an abnormal frame is found after the interval is shortened, frame-by-frame detection is performed according to the above steps, thereby improving the detection efficiency of the video stream and reducing resource occupancy.
[0040] The present invention provides an optimization method and terminal for accelerating video recognition, which are mainly used to improve the detection efficiency of video streams. The following is a specific description with reference to an embodiment:
[0041] Please refer to Figure 1 , Embodiment 1 of the present invention is:
[0042] An optimization method for accelerating video recognition, characterized in that it includes the steps of:
[0043] S1, perform fast frame sampling detection on the entire video stream at a preset interval, if an abnormal frame is detected, proceed to step S2; otherwise, proceed to step S3;
[0044] S2, perform frame-by-frame detection within a preset time range before and after the abnormal frame. If the detected abnormal frame meets the alarm rule, end the detection and alarm processing; otherwise, proceed to step S3;
[0045] S3. Determine whether all frames of the video stream have been detected. If so, end the detection; if not, shorten the preset interval and return to step S1.
[0046] That is, in this example, the entire video is preferentially processed by fast frame extraction at a preset interval, that is, a rough inspection is performed on the entire video stream. The preset interval can be between 1 and 10 seconds, which is selected as appropriate according to the length of the video stream. If an abnormal frame is detected, further frame-by-frame detection is performed near the abnormal frame until the detected abnormal frame image meets the alarm rule, then other parts are not detected, and the detection is directly ended and the alarm processing is performed, saving computer resources and improving processing efficiency; if the above rough inspection process does not find an abnormal frame, the preset interval is shortened, and the video stream is detected again until no abnormality is detected in all frames of the entire video stream, and the detection is ended; if an abnormal frame is found after the interval is shortened, frame-by-frame detection is performed according to the above steps, which improves the detection efficiency of the video stream and reduces resource usage.
[0047] Embodiment 2 of the present invention is:
[0048] Based on the first embodiment, step S1 further includes the following steps:
[0049] The video stream is sampled and collected at preset intervals, and each frame of the collected image is sent to the message queue. The consumer is controlled to request the AI model to detect the frame image based on the message in the consumption queue, and the detected frame image and the corresponding detection results are cached in the database. Each sampled frame image and its detection results are recorded and cached to facilitate joint verification with other abnormal frame images in the subsequent detection process, so as to determine whether the alarm rules are met and improve the versatility of the above method.
[0050] Step S2 also includes the steps of:
[0051] Compare the frames within the preset time range with the frames in the database for consistency, filter out the frames that have been detected in the database, and use the AI model to detect the remaining frames. When detecting frame by frame near abnormal frames, first filter out the frames that have been detected before to reduce the repeated recognition process and improve processing efficiency.
[0052] Specifically, the messages in the message queue include the unique identifier of the frame image, the frame timestamp and the video stream identifier. The consumer requests the AI model to detect the frame image based on the message, and stores the detection results together with the unique identifier and timestamp of the frame image in the database.
[0053] Step S3 also includes the steps of:
[0054] Before shortening the preset interval, the current detection frequency and system performance are evaluated, and the preset interval is adjusted dynamically. This method dynamically adjusts the preset interval by evaluating the current detection frequency and system performance before shortening the preset interval, so that the system can optimize the detection frequency according to the actual situation. This can ensure the timely discovery of abnormal frames and avoid excessive consumption of system resources, thereby improving the intelligence and adaptability of the system.
[0055] Embodiment 3 of the present invention is:
[0056] An optimization method to accelerate video recognition is applied as follows:
[0057] 1. Initialization settings:
[0058] Set the initial frame extraction interval to 5 seconds and the video stream identifier to video_001.
[0059] 2. Frame extraction detection:
[0060] The system extracts a frame from video_001 every 5 seconds for detection.
[0061] When the first abnormal frame is detected (for example, the frame at the 30th second), the system enters the abnormal frame detection step frame by frame.
[0062] Frame-by-frame detection:
[0063] All frames within 5 seconds before and after the 30th second frame (from the 25th second to the 35th second) are detected frame by frame.
[0064] These frames are compared with the frames that have been detected in the database and the detected frames are filtered out.
[0065] 3. Use the AI model to detect the remaining frames.
[0066] The test results show that the frame at the 32nd second is also abnormal and meets the alarm rules. The system issues an alarm and ends the test.
[0067] 4. Dynamically adjust the detection frequency:
[0068] In the above process, if the sampling inspection in the video stream has not been completed, the system will evaluate according to the current detection frequency and system performance. For example, if the system load is low, the preset interval is shortened to 3 seconds. Return to step 1 and continue the frame sampling inspection.
[0069] Another application is as follows:
[0070] 1. Initialization settings:
[0071] Set the initial frame extraction interval to 10 seconds and the video stream identifier to video_001.
[0072] 2. Frame extraction detection:
[0073] The system extracts a frame from video_001 every 10 seconds for detection.
[0074] The first round of random inspections found no abnormalities;
[0075] 3. Adjust the frame interval
[0076] The frame extraction interval is adjusted to 5s, and the extracted frames are compared with the frames that have been detected in the database to filter out the detected frames.
[0077] When the first abnormal frame is detected (for example, the frame at the 15th second), the system enters the abnormal frame detection step frame by frame.
[0078] 4. Frame-by-frame detection:
[0079] All frames within 5 seconds before and after the 15th second frame (from the 10th second to the 20th second) are detected frame by frame.
[0080] These frames are compared with the frames that have been detected in the database and the detected frames are filtered out.
[0081] 5. Use the AI model to detect the remaining frames.
[0082] The detection results show that the frame at the 13th second is also abnormal and meets the alarm rules. The system issues an alarm and ends the detection.
[0083] Please refer to Figure 2 , Embodiment 4 of the present invention is:
[0084] An optimization terminal 1 for accelerating video recognition includes a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3. When the processor 3 executes the computer program, the steps in any one of the optimization methods for accelerating video recognition in embodiments 1 to 3 are completed.
[0085] In summary, the present invention provides an optimization method and terminal for accelerating video recognition, which preferentially performs fast frame extraction processing on the entire video at a preset interval, that is, performs a rough inspection on the entire video stream. The preset interval can be between 1-10 seconds, which is selected as appropriate according to the length of the video stream. If an abnormal frame is detected, further frame-by-frame detection is performed near the abnormal frame until the detected abnormal frame image meets the alarm rule, then other parts are no longer detected, and the detection is directly terminated and the alarm processing is performed, saving computer resources, reducing the recognition of invalid frames, and improving processing efficiency; if the above-mentioned rough inspection process does not find an abnormal frame, the preset interval is shortened, and the video stream is detected again until all frames of the entire video stream are not detected abnormal, and the detection is terminated; if an abnormal frame is found after the interval is shortened, frame-by-frame detection is performed according to the above steps, thereby improving the detection efficiency of the video stream and reducing resource occupancy.
[0086] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An optimization method to accelerate video recognition, Features: Includes steps: S1, perform frame sampling detection on the entire video stream at a preset interval, if an abnormal frame is detected, proceed to step S2; otherwise, proceed to step S3; S2, perform frame-by-frame detection within a preset time range before and after the abnormal frame. If the detected abnormal frame meets the alarm rule, end the detection and alarm processing; otherwise, proceed to step S3; S3. Determine whether all frames of the video stream have been detected. If so, end the detection; if not, shorten the preset interval and return to step S1.
2. The optimization method for accelerating video recognition according to claim 1, Features: The step S1 further comprises the steps of: The video stream is sampled and collected at preset intervals, and the action of collecting each frame image is sent to the message queue. The consumer is controlled to request the AI model to detect the frame image based on the message in the consumption queue, and the detected frame image and the corresponding detection results are cached in the database.
3. The optimization method for accelerating video recognition according to claim 2, Features: The step S2 further comprises the steps of: The frame images within the preset time range are compared with the frame images in the database for consistency, the frame images that have been detected in the database are filtered out, and the remaining frame images are detected using the AI model.
4. The optimization method for accelerating video recognition according to claim 2, Features: The messages in the message queue include a unique identifier of the frame image, a frame timestamp, and a video stream identifier. The consumer requests the AI model to detect the frame image based on the message, and stores the detection results together with the unique identifier of the frame image and the frame timestamp in the database.
5. The optimization method for accelerating video recognition according to claim 1, Features: The step S3 further comprises the steps of: Before shortening the preset interval, the current detection frequency and system performance are evaluated, and the preset interval is dynamically adjusted.
6. An optimized terminal for accelerating video recognition, Features: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are performed: S1, perform frame sampling detection on the entire video stream at a preset interval, if an abnormal frame is detected, proceed to step S2; otherwise, proceed to step S3; S2, perform frame-by-frame detection within a preset time range before and after the abnormal frame. If the detected abnormal frame meets the alarm rule, end the detection and alarm processing; otherwise, proceed to step S3; S3. Determine whether all frames of the video stream have been detected. If so, end the detection; if not, shorten the preset interval and return to step S1.
7. The optimized terminal for accelerating video recognition according to claim 6, Features: The step S1 further comprises the steps of: The video stream is sampled and collected at preset intervals, and the action of collecting each frame image is sent to the message queue. The consumer is controlled to request the AI model to detect the frame image based on the message in the consumption queue, and the detected frame image and the corresponding detection results are cached in the database.
8. The optimized terminal for accelerating video recognition according to claim 7, Features: The step S2 further comprises the steps of: The frame images within the preset time range are compared with the frame images in the database for consistency, the frame images that have been detected in the database are filtered out, and the remaining frame images are detected using the AI model.
9. The optimized terminal for accelerating video recognition according to claim 7, Features: The messages in the message queue include a unique identifier of the frame image, a frame timestamp, and a video stream identifier. The consumer requests the AI model to detect the frame image based on the message, and stores the detection results together with the unique identifier of the frame image and the frame timestamp in the database.
10. The optimized terminal for accelerating video recognition according to claim 6, Features: The step S3 further comprises the steps of: Before shortening the preset interval, the current detection frequency and system performance are evaluated, and the preset interval is dynamically adjusted.
Citation Information
Patent Citations
Method and apparatus for providing mobile device interoperability
CN102460564A
Telemetering data analysis method and device for transformer substation
CN112636476A
Video analysis method and device based on edge cloud collaboration, electronic equipment and medium
CN115103157A
Video frame extraction method, related equipment, abnormal scene early warning method and related equipment
CN117579766A
Method and apparatus for providing mobile device interoperability
US20100332654A1
