Highway event detection method and device based on long video semantic analysis
Through sliding window comparison and chain thinking methods based on long video semantic analysis, the problem of real-time identification of abnormal events in highway monitoring systems in complex scenarios has been solved, and accurate identification and monitoring of abnormal events on highways have been achieved, improving monitoring System real-time and accuracy.
Patent Information
- Application Number
- CN202411098951.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-08-12
AI Technical Summary
The existing highway monitoring system has insufficient real-time monitoring and abnormal event identification capabilities in complex scenes and dynamic environments. The automated algorithm is greatly affected by lighting and weather, lacks deep semantic understanding, and cannot effectively identify abnormal events.
Using a method based on long video semantic analysis, through sliding window comparison and chain thinking, a highway event retrieval database is constructed, and the key frame information of the video to be detected is matched with the database to enhance the accuracy of abnormal event detection.
It realizes real-time abnormal event identification in complex scenes and dynamic environments, improves the accuracy and efficiency of the monitoring system, and can effectively identify various abnormal events on the highway.
Smart Images

Figure CN118628965B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision, and in particular to a method and device for detecting highway events based on long video semantic analysis. Background Art
[0002] With the rapid development of the global economy, highways, as important transportation infrastructure, are growing in scale and frequency of use. The efficient operation of highways is not only related to people's travel efficiency, but also to the safety of life and property. Traffic accidents, congestion, wrong-way traffic and other incidents on highways will not only cause casualties and property losses, but may also cause traffic paralysis, causing serious social impact and economic losses. Therefore, it is crucial to achieve real-time and efficient monitoring of highways and timely discover and handle various abnormal events to ensure the safe operation of highways.
[0003] However, the complexity and dynamics of highways pose great challenges to real-time monitoring and management. Traditional monitoring methods mainly rely on manual inspections and simple automated systems. These methods have obvious shortcomings when dealing with large-scale, high-real-time and highly complex monitoring tasks. Traditional highway monitoring systems mainly rely on fixed cameras for video acquisition and use manual or simple automated algorithms for video processing. However, existing automated algorithms have the following limitations:
[0004] 1. The real-time performance of automated algorithms is insufficient in complex scenarios, and manual monitoring cannot achieve real-time monitoring of all road sections.
[0005] 2. Due to the complex lighting and weather conditions on highways, the automatic recognition algorithm will be affected by the lighting and weather when making judgments, resulting in inaccurate recognition.
[0006] 3. Most existing algorithms can only collect videos and identify targets, but lack the ability to analyze the deep semantic understanding of videos, so they cannot identify specific abnormal events.
[0007] Therefore, there is an urgent need for a method that can identify various abnormal events occurring on highways in real time under complex scenarios and working environments. Summary of the invention
[0008] The embodiment of the present application provides a highway event detection method and device based on long video semantic analysis, which compares the key frame information of the video to be detected with the highway event retrieval library through a sliding window method, and adopts a chain thinking method during the comparison, thereby enhancing the ability to detect abnormal events.
[0009] In a first aspect, an embodiment of the present application provides a highway event detection method based on long video semantic analysis, the method comprising:
[0010] Acquire a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors;
[0011] The video of the highway to be detected is acquired in real time, and the video of the highway to be detected is input into the constructed highway event detection model, wherein the video of the highway to be detected is input into the semantic conversion module of the highway event detection model to output a feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the highway video to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain abnormal events corresponding to the key frame set.
[0012] In a second aspect, an embodiment of the present application provides a highway event detection device based on long video semantic analysis, comprising:
[0013] An acquisition module, used for acquiring a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors;
[0014] The detection module obtains the highway video to be detected in real time, and inputs the highway video to be detected into the constructed highway event detection model, wherein the highway video to be detected is input into the semantic conversion module of the highway event detection model to output the feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the highway video to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain the abnormal event corresponding to the key frame set.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute a highway event detection method based on long video semantic analysis.
[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, in which a computer program is stored. The computer program includes a program code for controlling a process to execute a process, and the process includes a highway event detection method based on long video semantic analysis.
[0017] The main contributions and innovations of the present invention are as follows:
[0018] The embodiment of the present application extracts abnormal highway videos covering all abnormal events as long document representations to obtain a highway event retrieval library containing all abnormal events, and compares and analyzes the highway videos obtained in real time with the highway event detection library in real time to determine whether there are abnormal events; in the comparison process, a sliding window is set for sequential matching, and a chain idea is used to fuse and filter the matching history with the vectors in the window, thereby enhancing the accuracy of abnormal event detection.
[0019] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 is a flow chart of a highway event detection method based on long video semantic analysis according to an embodiment of the present application;
[0022] Figure 2 It is a structural block diagram of a highway event detection device based on long video semantic analysis according to an embodiment of the present application;
[0023] Figure 3 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0025] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0026] Embodiment 1
[0027] The embodiment of the present application provides a highway event detection method based on long video semantic analysis, which constructs a highway event retrieval library by covering all abnormal highway videos of abnormal events, and compares the real-time highway video to be detected with the highway event retrieval library to extract key frames effective for event detection, and then judges the vector similarity between the key frames and the highway event retrieval library by constructing a sequence through a sliding window to determine whether an abnormal event has occurred. Specifically, reference Figure 1 as well as Figure 2 , the method comprising:
[0028] Acquire a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors;
[0029] The video of the highway to be detected is acquired in real time, and the video of the highway to be detected is input into the constructed highway event detection model, wherein the video of the highway to be detected is input into the semantic conversion module of the highway event detection model to output a feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the highway video to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain abnormal events corresponding to the key frame set.
[0030] In this scheme, a short text description is generated for each video frame in each abnormal high-speed video to form a long document sequence, and each long document sequence is average pooled and aggregated, and then vector extraction is performed to obtain the corresponding text vector.
[0031] In some embodiments, in order to achieve better detection results when acquiring abnormal highway videos, try to acquire videos covering various lighting conditions such as evening, early morning, rainy and snowy weather, as well as various highway scenes such as main lines, interchanges, ramps, and viaducts.
[0032] Specifically, LLaVA-NeXT is used to generate short text descriptions for each video frame in each abnormal highway video to form a long document sequence , where T is the total number of video frames, A short text description of the Tth frame.
[0033] In some specific embodiments, the embedding model of Open AI is used For the long document sequence Perform average pooling aggregation to obtain a single vector containing video content and features. , the formula is as follows:
[0034]
[0035] in, is a long document sequence, T is the total number of video frames, is a short text description of the Tth frame, is the embedding model.
[0036] Specifically, multiple text vectors corresponding to abnormal highway videos form a highway event retrieval library, which is expressed as follows:
[0037]
[0038] in, is a high-speed event detection library, and N is the number of retrieval vectors.
[0039] In this solution, the highway event detection model includes a semantic conversion module, a document retrieval module and a chain analysis module, wherein the semantic conversion module converts the highway video to be detected into a feature vector.
[0040] In the document detection module, the feature vector is matched with the text vector in the highway event retrieval library by cosine similarity, and the video frames corresponding to the multiple feature vectors with cosine similarity from high to low are retained as a key frame set.
[0041] Specifically, the formula for performing cosine similarity matching between the feature vector and the text vector in the highway event retrieval library is as follows:
[0042]
[0043] in, For highway event detection library, represents a feature vector.
[0044] Specifically, this solution retains the first number of video frames with cosine similarity from high to low as a key frame set, and the formula is as follows:
[0045]
[0046] in, is a set of key frames, is the cosine similarity between the feature vector and the text vector in the highway event retrieval database, To obtain The value of the first number of high cosine similarities in the t-th video frame is set according to the application situation.
[0047] The chain analysis module sets a sliding window in the key frame set, compares the vector similarity of all feature vectors contained in the current sliding window with each text vector in the highway event detection library, and returns the abnormal event corresponding to the text vector whose vector similarity is greater than a set threshold as the abnormal event of the key frame set. If there is no text vector whose comparison result is greater than the set threshold, the text vector with the highest vector similarity is obtained and retained in the matching history, and all feature vectors contained in the next sliding window are obtained. After all feature vectors contained in the next sliding window are fused with the matching history, the vector similarity is compared with each text vector in the highway event detection library again, and the abnormal event corresponding to the text vector whose vector similarity is greater than the set threshold is returned as the abnormal event of the key frame set. If there is no text vector whose comparison result is greater than the set threshold, the text vector with the highest vector similarity is obtained and retained in the matching history. If no text vector whose vector similarity is greater than the set threshold is found after traversing all key frame sets using the sliding window, there is no abnormal event in the highway video to be detected.
[0048] In some specific embodiments, the formula for comparing the vector similarity between all feature vectors included in the current sliding window and each text vector in the highway event detection library is expressed as follows:
[0049]
[0050] in, Represents the comparison of vector similarity, represents the video frame in the sliding window with sequence number i, For high-speed event detection libraries, and When the similarity of any text vector in is greater than or equal to the set threshold, r=1, indicating a successful match, and the abnormal event corresponding to the text vector is output. and If the similarity of any text vector in the sliding window is less than the set threshold, r = 0, indicating that the match fails, and the R value is returned. The R value content is the text vector with the highest similarity to the video frame vector in the current sliding window, and the R value content is saved in the matching history. middle.
[0051] That is, the matching history is updated based on the sliding of the sliding window. Assuming that the number of directional sliding of the sliding window in a time-advancing manner is N, the formula for updating the matching history is expressed as follows:
[0052]
[0053] in, Represents the matching history of the current sliding window, is the matching history of the previous window, R is the text vector with the highest similarity to the video frame sequence vector in the current sliding window, represents sum, and the preceding window is a sliding window of the previous time node.
[0054] In the step of "fusing all feature vectors and matching history contained in the next sliding window and then performing vector similarity comparison with each text vector in the highway event detection library", all feature vectors and matching history contained in the next sliding window are fused and screened to obtain a new current frame feature vector, and the new current frame feature vector is used to perform vector similarity comparison with each text vector in the highway event detection library. The formula is as follows:
[0055]
[0056] in, represents all feature vectors contained in the next sliding window, Represents the matching history, Indicates fusion, Indicates filtering.
[0057] In some specific embodiments, the number of cycles is determined according to the set sliding window size, and the formula is expressed as follows:
[0058]
[0059] Where N is the number of cycles, P represents When P=1, it means that the match is successful in the Nth cycle, and the corresponding abnormal event is returned. If P=0, it means that no abnormal event occurs in the video to be detected.
[0060] At the same time, the confidence of the match is calculated based on the consistency and support of the reasoning steps ,
[0061]
[0062] The confidence level is expressed in percentage to show the matching degree between the current successfully matched event and the event in the sample library.
[0063] Embodiment 2
[0064] Based on the same idea, refer to Figure 2 , the present application also proposes a highway event detection device based on long video semantic analysis, comprising:
[0065] An acquisition module, used for acquiring a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors;
[0066] The detection module obtains the highway video to be detected in real time, and inputs the highway video to be detected into the constructed highway event detection model, wherein the highway video to be detected is input into the semantic conversion module of the highway event detection model to output the feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the highway video to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain the abnormal event corresponding to the key frame set.
[0067] Embodiment 3
[0068] This embodiment also provides an electronic device, referring to Figure 3 , comprises a memory 404 and a processor 402, wherein the memory 404 stores a computer program, and the processor 402 is configured to run the computer program to execute the steps in any of the above method embodiments.
[0069] Specifically, the processor 402 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0070] Among them, the memory 404 may include a large capacity memory 404 for data or instructions. For example, but not limitation, the memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In appropriate cases, the memory 404 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 404 may be inside or outside the data processing device. In a specific embodiment, the memory 404 is a non-volatile memory. In a specific embodiment, the memory 404 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. In appropriate circumstances, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM may be a fast page mode dynamic random access memory 404 (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0071] The memory 404 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 402 .
[0072] The processor 402 reads and executes the computer program instructions stored in the memory 404 to implement any one of the highway event detection methods based on long video semantic analysis in the above embodiments.
[0073] Optionally, the electronic device may further include a transmission device 406 and an input / output device 408 , wherein the transmission device 406 is connected to the processor 402 , and the input / output device 408 is connected to the processor 402 .
[0074] The transmission device 406 can be used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired or wireless network provided by a communication provider of the electronic device. In one example, the transmission device includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 406 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0075] The input and output device 408 is used to input or output information. In this embodiment, the input information may be abnormal highway video, to-be-detected highway video, etc., and the output information may be an abnormal event that has occurred.
[0076] Optionally, in this embodiment, the processor 402 may be configured to perform the following steps through a computer program:
[0077] Acquire a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors;
[0078] The video of the highway to be detected is acquired in real time, and the video of the highway to be detected is input into the constructed highway event detection model, wherein the video of the highway to be detected is input into the semantic conversion module of the highway event detection model to output a feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the highway video to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain abnormal events corresponding to the key frame set.
[0079] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0080] In general, various embodiments may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that, as non-limiting examples, the boxes, devices, systems, techniques, or methods described herein may be implemented in hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.
[0081] Embodiments of the present invention may be implemented by computer software that is executable by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets and / or macros may be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. A computer program product may include one or more computer executable components configured to perform an embodiment when the program is run. One or more computer executable components may be at least one software code or a portion thereof. In addition, at this point, it should be noted that, for example, Figure 3 Any block of the logic flow in the program may represent program steps, or interconnected logic circuits, blocks and functions, or a combination of program steps and logic circuits, blocks and functions. The software may be stored on physical media such as memory chips or storage blocks implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs, etc. Physical media are non-transitory media.
[0082] Those skilled in the art should understand that the technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0083] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A highway event detection method based on long video semantic analysis, characterized in that: The following steps are involved: Acquire a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors; The video of the highway to be detected is acquired in real time, and the video of the highway to be detected is input into the constructed highway event detection model, wherein the video of the highway to be detected is input into the semantic conversion module of the highway event detection model to output the feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the video of the highway to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain abnormal events corresponding to the key frame set, and the chain analysis module sets a sliding window in the key frame set, and performs vector similarity analysis on all feature vectors contained in the current sliding window and each text vector in the highway event detection library. The abnormal events corresponding to the text vectors whose vector similarity is greater than the set threshold are returned as the abnormal events of the key frame set. If there is no text vector whose comparison result is greater than the set threshold, the text vector with the highest vector similarity is obtained and retained in the matching history. When there is no text vector whose comparison result is greater than the set threshold, all feature vectors contained in the next sliding window are obtained, and all feature vectors contained in the next sliding window are fused with the matching history, and then the vector similarity is compared with each text vector in the highway event detection library again. The abnormal events corresponding to the text vectors whose vector similarity is greater than the set threshold are returned as the abnormal events of the key frame set. If there is no text vector whose comparison result is greater than the set threshold, the text vector with the highest vector similarity is obtained and retained in the matching history.
2. A highway event detection method based on long video semantic analysis according to claim 1, characterized in that: A short text description is generated for each video frame in each abnormal high-speed video to form a long document sequence, and each long document sequence is average pooled and aggregated, and then vector extraction is performed to obtain the corresponding text vector.
3. The highway event detection method based on long video semantic analysis according to claim 1 is characterized in that: In the document retrieval module, the feature vector is matched with the text vector in the highway event retrieval library by cosine similarity, and the video frames corresponding to the multiple feature vectors with cosine similarity from high to low are retained as a key frame set.
4. The highway event detection method based on long video semantic analysis according to claim 1 is characterized in that: If no text vector whose vector similarity is greater than a set threshold is found after traversing all key frame sets using a sliding window, then there is no abnormal event in the highway video to be detected.
5. The highway event detection method based on long video semantic analysis according to claim 1 is characterized in that: In the step of "fusing all feature vectors and matching histories contained in the next sliding window and performing vector similarity comparison with each text vector in the highway event detection library again", all feature vectors and matching histories contained in the next sliding window are fused and screened to obtain a new current frame feature vector, and the new current frame feature vector is used to perform vector similarity comparison with each text vector in the highway event detection library.
6. A highway event detection device based on long video semantic analysis, characterized in that: include: An acquisition module, used for acquiring a highway event retrieval library, wherein the highway event retrieval library includes abnormal high-speed videos corresponding to abnormal events represented by text vectors; The detection module obtains the highway video to be detected in real time, and inputs the highway video to be detected into the constructed highway event detection model, wherein the highway video to be detected is input into the semantic conversion module of the highway event detection model to output the feature vector corresponding to the current highway video to be detected; the feature vector is input into the document retrieval module of the highway event detection model to match with the highway event retrieval library to obtain the key frames of the highway video to be detected to form a key frame set, and the key frame set is input into the chain information analysis module of the highway event detection model to obtain the abnormal event corresponding to the key frame set, and the chain analysis module sets a sliding window in the key frame set, compares all the feature vectors contained in the current sliding window with each text vector in the highway event detection library, and compares the feature vectors contained in the current sliding window with each text vector in the highway event detection library. The similarity is compared, and the abnormal events corresponding to the text vectors whose vector similarity is greater than the set threshold are returned as the abnormal events of the key frame set. If there is no text vector whose comparison result is greater than the set threshold, the text vector with the highest vector similarity is obtained and retained in the matching history. When there is no text vector whose comparison result is greater than the set threshold, all feature vectors contained in the next sliding window are obtained, and all feature vectors contained in the next sliding window are fused with the matching history, and then the vector similarity is compared with each text vector in the highway event detection library again, and the abnormal events corresponding to the text vectors whose vector similarity is greater than the set threshold are returned as the abnormal events of the key frame set. If there is no text vector whose comparison result is greater than the set threshold, the text vector with the highest vector similarity is obtained and retained in the matching history.
7. An electronic device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute a highway event detection method based on long video semantic analysis as described in any one of claims 1-5.
8. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which includes a program code for controlling a process to execute a process, and the process includes a highway event detection method based on long video semantic analysis as described in any one of claims 1-5.
