System and method for a scalable complex event pattern for video analysis

The system addresses inefficient complex event pattern matching in video analytics by using a query compiler and probabilistic pattern matching with adaptive event materialization to reduce costs and resource waste, enhancing throughput and accuracy in real-time video analysis.

WO2026086054A1PCT designated stage Publication Date: 2026-04-30CENT FOR PERCEPTUAL & INTERACTIVE INTELLIGENCE (CPII) LTD
View PDF 6 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
CENT FOR PERCEPTUAL & INTERACTIVE INTELLIGENCE (CPII) LTD
Filing Date
2025-02-17
Publication Date
2026-04-30

AI Technical Summary

Technical Problem

Existing video analytics systems struggle with high processing costs and resource wastage due to inefficient handling of complex event pattern matching, particularly in real-time video analysis, leading to over-localization of unnecessary events and excessive GPU usage.

Method used

A system and method utilizing a query compiler, a proxy model, and a probabilistic pattern matching module (PPAT) with adaptive event materialization (AEM) to translate queries into nondeterministic finite automata (NFA), estimate window probabilities, filter non-matching windows, and adaptively materialize events to minimize unnecessary processing.

Benefits of technology

Achieves scalable and efficient complex event processing with reduced costs and GPU resource utilization, improving throughput by 2.3× to 5.7× without accuracy loss, by early rejection and selective materialization of clips.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025077569_30042026_PF_FP_ABST
    Figure CN2025077569_30042026_PF_FP_ABST
Patent Text Reader

Abstract

A system for identifying a complex event pattern in a data input for real-time video analysis is disclosed. The system includes a query compiler, a proxy model, a first inference module, and a second inference module. A method for identifying a complex event pattern in a data input for real-time video analysis is disclosed. The method includes: translating a query into a nondeterministic finite automaton (NFA) using a query compiler; predicting proxy scores using a proxy model; estimating a probability of a window matching a query pattern; filtering out windows with a very low likelihood of matching the query pattern; adaptively materializing events within the windows until it can be determined whether a match is guaranteed or impossible; and returning windows that must contain a matc.
Need to check novelty before this filing date? Find Prior Art

Description

System and method for a scalable complex event pattern for video analysisFIELD OF THE INVENTION

[0001] The present invention relates to the field of real-time video analysis, specifically to systems and methods for identifying complex event patterns within video data. It pertains to the optimization of pattern recognition and inference processes in video streams, involving probabilistic pattern matching and sequential processing techniques.BACKGROUND OF THE INVENTION

[0002] The ability to process and analyze digital events including but not limited to video streams in real-time has become critically important, enabling rapid decision making and intelligent automation. However, despite recent efforts, existing deep video analytics systems primarily support queries about simple events, such as selecting frames that contain a red car or counting the average number of cars in a video. The temporal nature of video streams, queries that can match patterns of events could enable a wider range of use cases and applications.

[0003] For example, in transports analytics, there are many places that permit a right turn on red light, it is a traffic offense if an individual fails to come to a complete stop before making the right turn. Although such a ‘right-turn-after-rolling-stop’ behavior is not uncommon, it poses significant risks to pedestrians on the adjacent right sidewalk. Spotting such an offense requires identifying two events, ‘rolling stop’ and ‘right-turn’ and matching them against a temporal ‘happen after’ pattern.

[0004] In sports analytics during sports competitions, coaches monitor the game and adjust tactics based on the on-field situations. For instance, in basketball, ‘pick-and-roll’ is a commonly used offensive play to create scoring opportunities. It involves a player A setting a ‘screen’ by picking a defender, which creates an opportunity for either (1) a teammate B to take an open shot or (2) player A to move ( ‘roll’ ) towards the basket and receive a pass. To identify such plays, it is necessary to extract all events of ‘screen’ , ‘roll’ , ‘pass’ , and ‘shoot’ , and match them according to a specific pattern within a specific time window (e.g., 5 seconds) .

[0005] For shopping behavior analysis, the way goods are arranged in a store can greatly influence customers’ buying decisions. Therefore, it is important to analyze shopping behaviors in order to understand customer preferences and develop strategies to boost sales. For instance, if it is observed that a significant number of customers head to the checkout area after picking up beers, separating the beer section from the checkout counters could potentially increase the customers’ shopping time. Identifying such behaviors cannot be accomplished using traditional techniques that rely on mining transactional data (e.g., association rules) , as many interesting events occur before customers check out. Instead, these behaviors can be identified by composing and evaluating various pattern matching queries against a large volume of videos.

[0006] Matching complex patterns across different events in a video requires a deep understanding of the video content. Despite the achievements of recent Multi-modal Large Language Model (MLLM) such as GPT-4, Gemini, LLaMA-VID, and LLaVA, their pattern matching abilities remain rudimentary. More importantly, these models process each query by treating each frame from the video-of-interest as token (s) in the prompt. In other words, every video frame must pass through the large model with billions of parameters, resulting in exceptionally high processing costs or processing times.

[0007] Alternatively, one can rely on single-modality models and fast selection techniques such as Zeus and Probabilistic Predicate (PP) to first localize all the individual interesting events (e.g., ‘rolling stop’ , ‘right-turn’ ) . Afterward, one can utilize modern Complex Event Processing (CEP) engines as a post-processing step to match the query pattern. However, this ‘localize-all-post-CEP’ approach would over-localize many unnecessary events that end up not matching the query pattern, thereby wasting valuable GPU resources. An alternate approach is to directly train or fine-tune a single-modality binary model for each specific query pattern. However, this approach is not scalable either, especially when there are numerous potential query patterns to consider.

[0008] When it comes to scalable video analytics, the database community has been actively developing solutions that offer improved processing cost and efficiency. However, existing works in this field have not addressed the challenge of handling pattern matching queries. Instead, the primary focus of these works revolves around simpler queries such as selection, top-k, and aggregation. Most of these works accelerate processing by a cascading approach, which involves leveraging a lightweight but less accurate ‘proxy’ model to first quickly inference the data once and using those approximate inference results to guide the search or the sampling process. The more accurate but expensive ‘oracle’ model is involved only when necessary.

[0009] For example, US Patent No. 10733457 may have employed artificial intelligence and a deep learning mechanism to determine the intent of the subject based on real-time video feed. The pre-trained intent model in said patent is trained to predict a possible state action change based on probabilities of the subject’s behavior based on pre-determined parameters and their corresponding scores. However, in determining the probabilities of the subject’s behavior, the model may exhaust the GPU resources. At the same time, it has not disclosed a capacity to reduce unmatched queries and thus, reducing its effectiveness in determining the subject’s behavior.

[0010] US Patent No. 9292493 disclosed a system for detecting deception in human communication expressed in digital form with a computer based on a given text input for classification as either truthful or deceptive and performing a combination of psycho-linguistic cue analysis and statistical analysis / modeling. The said patent disclosed the steps of tokenization, stemming, pruning and no punctuation (NOP) steps that take place within the models. These are pre-processing steps that remove words that only occurred once in the data sets. However, these models may process each query by treating each frame from the video-of-interest as token (s) in the prompt, thus each video frame must pass through the large model with billions of parameters, resulting in exceptionally high processing costs or processing times.

[0011] International Patent No. WO2022183138A2 may have disclosed a method for automatically augmenting natural language content with emotio-cognition by processing circuitry. It incorporates classification model that classifies emotion, connotation or lexical frame intensity instead of probability (of a classification) offered as a proxy for intensity. While it incorporatesa pre-processing engine to transform the text data into a form necessary for matching with rules to be further analyzed by Natural Language Rules and MultiMedia Classification Engine, it may not have the capacity to be scalable with high accuracy with reduced costs.

[0012] Additionally, Chinese Patent Application No. CN112269805B may have disclosed a data processing method, a data processing device, an electronic device and a computer readable storage medium configured to perform image processing on a tag guest group data and determining target guest group data to be applied to fine marketing. It employs an algorithm with capacity to split patterns to determine minimum time windows for efficient patterns matching system. Whilst the algorithm may greatly assist to match pattern queries effectively, this approach may over-localize many unnecessary events that end up not matching the query pattern, thereby wasting valuable GPU resources.

[0013] In view of the above, there are still challenges that need to be addressed in order to handle a large pool of data for pattern matching queries with high efficiency and accuracy without wasting valuable GPU resources.SUMMARY OF THE INVENTION

[0014] It is an objective of the present invention toprovide a system and method for a scalable complex event processing including but not limited to video processing, with reduced costs or processing times.

[0015] It is also an objective of the present invention to providea system and method for a scalable complex event processing including but not limited to video processing without over-localizing unnecessary events that end up with unmatched query pattern, thereby wasting valuable GPU resources.

[0016] It is also an objective of the present invention to provide a system and method for a scalable complex event processing including but not limited to video processing with capacity to process complex queries for matching complex event patterns that involve multiple events occurring in a sequence.

[0017] Accordingly, these objectives can be achieved by following the teachings of the present invention, which relates toa system for identifying a complex event pattern in a data input for real-time video analysis, which comprises a query compiler, a proxy model, a first inferencing module, and a second inferencing module.

[0018] These objectives can also be achieved by following the teachings of a method for identifying a complex event pattern in a data input for real-time video analysis, comprising: translating a query into a nondeterministic finite automata (NFA) using a query compiler; predicting proxy scores using a proxy model; estimating probability of a window matching a query pattern; filtering the windows with a high likelihood of not matching the query pattern; materializing events adaptively within the windows until it can be determined whether a match is guaranteed or impossible; and, returning the windows that must contain a match.BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The features of the invention will be more readily understood and appreciated from the following detailed description when read in conjunction with the accompanying drawings of the preferred embodiment of the present invention, in which:

[0020] Figure 1 illustratesexamples of two different cases for a window;

[0021] Figure 2 illustrates the NFA compiled from Q1;

[0022] Figure 3 illustrates an overview of the present invention;

[0023] Figure 4 (a) illustrates an embodiment of window of five clips;

[0024] Figure 4 (b) illustrates a DFA converted from the NFA of Query Q2;

[0025] Figure 4 (c) illustrates a Non-Homogeneous Markov Chain constructed for Query Q2;

[0026] Figure 5 illustrates an embodiment of a computing equation for all possible events for a specific clip;

[0027] Figure 6 illustrates a multi-window optimization;

[0028] Figure 7 illustrates the performance of the present invention and the video processing models in terms of throughput and relative accuracy;

[0029] Figure 8 illustrates percentage of frames from the input video that are eventually materialized by the expensive oracle model for each query;

[0030] Figure 9 illustrates the processing time breakdown of the present invention for each query;

[0031] Figure 10 illustrates an average throughput and relative accuracy of the present invention when given different F1 accuracy targets for all queries;

[0032] Figure 11 illustrates the throughput and accuracy of the present invention with varied pattern length of Q4;

[0033] Figure 12 illustrates the average throughput and accuracy of the present invention with varied queried window size of all the queries from 30 clips to 300 clips; and,

[0034] Figure 13 illustrates the average throughput and accuracy of the present invention with respect to different adaptive event materialization (AEM) policies. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

[0035] For the purposes of promoting and understanding the principles of the invention, reference will now be made to the embodiments illustrated in the drawings and described in the following written specification. It is understood that the present invention includes any alterations and modifications to the illustrated embodiments and includes further applications of the principles of the invention as would normally occur to one skilled in the art to which the invention pertains.

[0036] The term ‘present invention’ is also named as ‘Bobsled’ and may be used interchangeably throughout the whole specification.

[0037] The term ‘data input’ refers to the time windows or clippings of decoded video streams of interest.

[0038] The terms ‘a first inferencing module’ refers to the probabilistic pattern matching module (PPAT) , wherein ‘a second inferencing module’ refers to an adaptive event materialization module (AEM) .

[0039] The present invention teaches a system for identifying a complex event pattern in a data input for real-time video analysis, which comprises a query compiler, a proxy model, a first inferencing module, and a second inferencing module.

[0040] In one embodiment, the query compiler is configured to automatically infer a minimum duration for all events with unspecified minimum duration in a query and transform the query into a nondeterministic finite automata (NFA) .

[0041] In one embodiment, the proxy model is configured to predict proxy scores of the data input for estimating the probability of a window matching a query pattern by the first inferencing module.

[0042] In one embodiment, the first inferencing module is a Probabilistic Pattern (PPAT) matching module configured to filter windows with a high likelihood of not matching the query pattern.

[0043] In one embodiment, the first inferencing module is a discrete-time Non-Homogenous Markov Chain (NHMC) with the capability to process non-homogenous data input.

[0044] In one embodiment, the first inferencing module filters windows with a high likelihood of not matching the query pattern by estimating the probability of the window matching the query pattern based on the NFA provided by the query compiler and the proxy scores predicted by the proxy model.

[0045] In one embodiment, the second inferencing module is an adaptive event materialization (AEM) module configured to adaptively materialize events within windows that pass the first inferencing module until it can be determined whether a match is guaranteed or impossible, and return the windows that must contain a match.

[0046] In one embodiment, the second inferencing module further comprises an event materialization policy.

[0047] In one embodiment, the proxy model is pre-trained with real-time data input.

[0048] In one embodiment, the second inferencing module sequentially selects and materializes events within windows that pass the first inferencing module.

[0049] In one embodiment, the event materialization policy includes but is not limited to a greedy policy.

[0050] In one embodiment, the greedy policy is calculated using the following formulation:

[0051] In one embodiment, the first inferencing module further caches transition matrices and reuses them to reduce computational overhead for future query matching.

[0052] In one embodiment, the data input includes but is not limited to decoded video data streams obtained from a plurality of sources.

[0053] In one embodiment, the present invention has the capacity to process the data input individually and in batches, thus accommodating scalability.

[0054] The present invention also teaches a method for identifying a complex event pattern in a data input for real-time video analysis, comprising: translating a query into a nondeterministic finite automata (NFA) using a query compiler; predicting proxy scores using a proxy model; estimating probability of a window matching a query pattern; filtering the windows with a high likelihood of not matching the query pattern; materializing events adaptively within the windows until it can be determined whether a match is guaranteed or impossible; and, returning the windows that must contain a match.

[0055] In one embodiment, the step of translating the query into the nondeterministic finite automata (NFA) using the query compilerfurther comprises: obtaining from a given validation set a measured minimum duration offline; annotating the measured minimum duration for each event; and translating the query into the NFA.

[0056] In one embodiment, the step of estimating the probability of the window matching the query patternfurther comprises: adopting a powerset construction algorithm and obtaining a deterministic finite automaton (DFA) from an initial nondeterministic finite automaton (NFA) ; constructing a first inferencing module from the DFA and the proxy scores, wherein the first inferencing module is a discrete-time Non-Homogeneous Markov Chain (NHMC) ; and using NHMC for calculating the pattern matching probability.

[0057] In one embodiment, the probability of the window matching the query pattern iscalculated using the following formulation:

[0058] In one embodiment, the step of filtering the windows with a high likelihood of not matching the query pattern further comprises deriving a rejection threshold.

[0059] In one embodiment, the step of filtering the windows with a high likelihood of not matching the query pattern further comprises prioritizing the filtration of negative windows and deferring remaining processing to a second inferencing module.

[0060] In one embodiment, the method further comprises further inferring the windows that cannot be filtered.

[0061] In one embodiment, the step of further inferring further comprises employing information entropy to unify the decision-making process across the two cases of window matching the query and window not matching the query.

[0062] In one embodiment, in the step of further inferring the windows that cannot be filtered, further comprises selecting clips sequentially and frugally materializing selected clips one at a time.

[0063] In one embodiment, in the step of further inferring the windows that cannot be filtered, further comprises: choosing the clipswith the maximal expected conditional mutual information at each step; andconsidering futurewindows in a decision-making process.

[0064] Details on the background of the present invention, along with the advantages of the present invention and the accompanying embodiments are further discussed below:

[0065] Detailed Introduction

[0066] Unlike many existing work, Bobsled does not require training or fine-tuning an oracle / proxy model for each query. Initially, it employs a lightweight pretrained single-modality model as a proxy to obtain a distribution of events for each clip in the video stream. Using this information, it derives the probability, p of a window matching the query pattern and forms a cascade. If p falls below a certain threshold, a clip within a window is discarded without further processing by the oracle.

[0067] Deriving the probability, p from probabilities of individual events within a window, however, is non-trivial. Specifically, matching a window of events against a pattern requires translating the query pattern into a nondeterministic finite automaton (NFA) and consuming the window of events to determine if the final state can be reached. However, since a pattern query can be translated into an NFA with non-mutually exclusive outgoing transitions, it cannot be directly used to form a probabilistic model like Markov chain to estimate p (as non-mutually exclusive edges would sum up probabilities to more than 1) . Bobsled utilizes Non-Homogeneous Markov Chains and develops the concept of Probabilistic Pattern (PPAT) to address this challenge.

[0068] For windows that cannot be directly pruned by PPAT, Bobsled carries out further optimization in order to minimize the inference cost. For example, consider a pattern query that searches for the following pattern on windows of size four: ‘rolling stop’ (RS) → ‘right turn’ (RT) → ‘left turn’ (LT) .

[0069] Consider two different cases for a windowshown in Figure 1. The window covers four clips c1 to c4. After scanning by the proxy, the discrete distribution of potential events for each clip is obtained. In Case 1, a smart Adaptive Event Materialization (AEM) strategy can choose to select clip c2 and pass it to the oracle first to materialize its real label. By doing so, it can reject the window early once the oracle confirms that c2 is not a ’ right turn’ . This is because a non-’ right turn’ event in the second position of the window immediately violates the query pattern. Such a smart approach enables early stopping, incurring the cost of passing only one clip to the oracle, and can then proceed to processing the next window.

[0070] In contrast, a basic strategy would be to sequentially pass the clips inside the window to the oracle, starting from c1. However, if c1 is identified as a ‘rolling stop’a ccording to the oracle, then unlike the smart strategy mentioned above, the window cannot be discarded until it also materializes c2 and finds that c2 is not a ’ right turn’ . This would incur a cost of materializing both c1 and c2 before the window can be rejected. Designing a smart materialization strategy is non-trivial because the optimal choice not only depends on the early rejection probability, but also depends on the early acceptance probability if the window contains a positive match. Consider case 2 in Figure 1. In this case, after materializing c1 and c2 as ‘rolling stop’ and ‘right turn’ , a smart strategy shall pick c3 over c4 because it can potentially allow early acceptance of the window without processing c4.

[0071] Given the complexity and probabilistic nature of the decision space, Bobsled formulates the problem as a Sequential Information Maximization (SIM) problem. This formulation enables a greedy policy, allowing Bobsled to make near-optimal choices by maximizing the mutual information among different materialization choices. To date, Bobsled is the first system that can effectively handle pattern matching queries on video streams. Bobsled accelerates the complex event processing while meeting the desired accuracy. Experiments show that Bobsled can achieve a throughput improvement of 2.3× to 5.7× without any noticeable accuracy loss.

[0072] Video event detection

[0073] The transformer model has literally transformed the world in recent years. The latest Multi-modal Language Models (MLLMs) such as GPT-4, Sora, Gemini, LLaMA-VID, and LLaVAhave the ability to manage tasks like text-to-video generation and video question answering, marking a significant step towards Artificial General Intelligence (AGI) . However, current MLLMs lack sophisticated pattern matching capabilities. Even with future advancements, the inherent need to process every frame might render MLLMs computationally expensive for database-driven video analytics. Employing the broader capabilities of MLLMs for complex event video processing could be unnecessarily resource-intensive. Furthermore, event pattern languages can precisely capture query intents, whereas achieving the same level of precision through natural language prompt engineering is almost an art. Therefore, the language modality in MLLMs is not particularly necessary for our applications but brings unnecessary overhead due to the significant proportion of model parameters allocated to language processing. For detecting individual events in a video, single-modality video recognition models are sufficient.

[0074] Bobsled supports complex video event processing using single-modality models. It is agnostic to the type of event, whether it is an action detected by a video recognition model, or an object occurrence detected by an image model. In the following, the present invention is focused on action-based events because they align better with the specific use cases.

[0075] Video recognition models take consecutive clips (sequences of frames) as input and leverage both the spatial information within each frame and the temporal information across frames for recognition. These models can be broadly categorized into two classes: convolution-based models (e.g., C3D, R (2+1) D) and transformer-based models (e.g., VideoMAE, X-CLIP) . Convolution-based models use 3D convolution instead of 2D convolution to capture temporal information in video clips. On the other hand, transformer-based models tokenize the input video and employ self-attention mechanisms to capture contextual information.

[0076] Inputs to these video recognition models are typically clips of 16, 64, or 128 consecutive frames. These models have the ability to identify multiple events occurring within a clip. For example, given a clip, they can output co-occurring events such as ‘player A is screening’ and ‘player B is dribbling’ . Furthermore, since an action may span multiple clips, a model may output an ‘eating’ label for hundreds of consecutive clips.

[0077] Deep video analytics

[0078] Optimize query processing on videos, supporting various query types including selection, limit, aggregation, and top-k. Most of these systems are based on building query-specific proxy models. For example, they train a lightweight binary classifier for a query predicate, say, COUNT (CAR) > 5, as a ‘proxy. ’ Frames with a proxy score (i.e., the probability of a frame passing the query, according to the proxy model) below a certain passing threshold are discarded, thus avoiding the need for processing by the expensive oracle model.

[0079] The training data of the proxy is obtained by sampling frames from the queried video, passing them to the oracle, and regarding the oracle outputs as the true labels. The passing threshold is calibrated based on relating the empirical recall / precision on the proxy model with respect to the oracle labels, to the desired recall / precision targets, based on different levels of accuracy guarantees.

[0080] Proxy models are not the sole method for providing proxy scores though. Systems such as TASTI and Seiden employ an alternative approach by initially processing a subset of frames using the oracle model. They then use the labels obtained from this processed subset to interpolate proxy scores for the remaining frames. These techniques can be applied to any proxy-model-based system including Bobsled. ExSample can answer LIMIT queries without relying on any proxy scores. It uses Thompson sampling to select frames from the queried video for processing by the oracle model and stops early once a sufficient number of results are found. However, for selection queries or pattern queries that aim to find all answers, determining when to stop the search early while still meeting a specific recall or precision target remains unclear, especially when no additional information, such as proxy scores, is available.

[0081] Some systems are designed to adaptively select the most appropriate model or configuration (e.g., image size, sampling rate) from a collection for inference. Their goal is to process important frames using more expensive models or configurations, while using cheaper models or configurations for irrelevant frames. For example, Zeus, which is dedicated to action localization, leverages a reinforcement learning agent to predict the configuration of the next video clip to process. Other works, such as Rekall and VOCAL, have primarily concentrated on the programming model and data labeling processing for complex event processing in videos. In contrast, our work pioneers the exploration of the efficiency aspect of pattern matching in videos.

[0082] Complex event processing

[0083] Complex Event Processing (CEP) systems are designed for pattern matching in conventional data streams. CEP queries comprise a sequence of events that occur in a specific order along with constraints on these events. Various query languages have been proposed to describe patterns, including SQL-TS, Cayuga, and SASE+. These languages support expressing event sequences, Kleene closure, complex predicates, and contiguity, thereby providing richer expressibility compared to languages for regular expression matching.

[0084] A typical CEP query contains three clauses: ‘SEQ’ , ‘WHERE’ , and ‘WITHIN’ . The ‘SEQ’ clause defines a sequence of events, along with associated quantifiers, which defines the minimum and maximum occurrences of an event. One quantifier is Kleene plus, denoted by ‘+’ , and enables definition of one or more occurrences of an event, such as ‘A+’ . A specific number of occurrences of an event can also be defined. For instance, ‘A {3, 5} ’ indicates that the event ‘A’ should occur at least three times and at most five times. The ‘WHERE’ clause specifies conditions on events, whereas the ‘WITHIN’ clause specifies the window size.

[0085] SEQ (A, B+, C)  / / Query Q1 WHERE A. condition = 'sunny' AND B. condition = 'rainy' AND C. condition = 'cloudy' WITHIN 1 hour

[0086] Q1 above is an example CEP query, capturing a sequence of weather conditions: within the past hour, the weather condition changes from ‘sunny’ to ‘rainy’ for a period of time, and finally turns to ‘cloudy’ . The Kleene plus quantifier matches one or more ‘rainy’ events. By default, the contiguity between these events is relaxed. Strict contiguity requires two events to be contiguous in the stream, which is commonly used in regular expression matching. Relaxed contiguity removes the contiguity requirements between events, where all irrelevant events are skipped until the next relevant event is found. This is particularly important in real-world scenarios where the streams contain noise events that should be ignored by the query.

[0087] During execution, a CEP query is usually compiled into a nondeterministic finite automaton (NFA) . Formally, the NFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) , where Q denotes a set of states, Σ represents a set of conditions, δ is a transition function, q0 is the start state, and F is the final state. The transition function, δ, defines the transitions of an NFA. For instance, δ (q, a) = q′refers to the transition from state q to state q′under the condition of a. The condition is a Boolean expression composed of basic operators (∧, ∨,  ) , comparison operators (e.g., >, <, =) , and variables, which evaluates to either true or false. An epsilon transition models the Kleene plus operator under relaxed contiguity, allowing the matching process to move from one state to another state without consuming any event; its condition is always evaluated to true.

[0088] Figure 2 depicts the NFA compiled from Q1. In this example, the condition ‘sunny’ must be satisfied for the matching process to transition from state ‘q1’ to ‘A’ . There is an epsilon transition from state ‘B’ to state ‘C’ , which can take place without consuming any event. Hence, at state ‘B’ , a ‘rainy’ event can either stay at state ‘B’ , or the matching process first transits to state ‘C’ via the epsilon transition and then stays at state ‘C’ after consuming the ‘rainy’ event via the  transition. This highlights the inherent nondeterminism exhibited by NFAs, where the conditions associated with two edges at a particular state can be non-mutually exclusive.

[0089] A match is found if there exist some choices of transitions that lead to the final state after consuming some events. If no match is found in the current window, the matching process slides the window to the next event. For instance, from X [ABDD] EE to XA [BDDE] E, where ‘ [’ and ‘] ’ denote the start and end of a window. When a match is found, the matching process has different options to move the window. For example, the skip-past-last-event strategy moves the window to skip past the last event that matches, from X [ABCD] EEFF to XABC [DEEF] F.

[0090] The primary focus of CEP systems is to enhance throughput, thereby facilitating the processing of high-velocity data streams. The key challenge lies in the complexity of evaluating the NFA on each window. Various work addresses this in terms of pattern matching cost and memory consumption. However, CEP on video events should have a different focus because the primary bottleneck stems from the model inference rather than the pattern matching process. For instance, a typical video recognition model like R (2+1) D-18 achieves 184 clips per second on an Nvidia GeForce RTX 3090 GPU when using 16 frames per clip. In contrast, CEP systems are capable of handling over 100,000 events per second when running on a single CPU core. Therefore, the challenge shifts towards minimizing model inferences to maximize the system’s overall throughput.

[0091] CEP in Bobsled

[0092] Bobsled aims to accelerate complex event processing on video streams. It supports events recognized by any recognition model including image classification, action recognition, object detection, and others. Currently, events that are not direct outputs of a recognition model are not supported. For instance, the event ‘more than five cars’ is not a direct output of any common object detection model, but rather an event that is post-processed by an external module based on the model’s direct output. However, if a model is fine-tuned and can directly return such a ‘more than five cars’ event, Bobsled can also support it. The reason is that Bobsled avoids any query-specific proxy models, as that approach is not scalable with the number of queries. Instead, Bobsled utilizes proxy models that perform the same tasks as the oracle models. These models are often pre-trained and provided alongside the oracle model. For example, the latest version of YOLOv10 object detector has variants: nano, small, medium, large, and extra-large. One can use the nano version as the proxy and the extra-large version as the oracle. When lightweight versions of an oracle model are unavailable, users can utilize a model quantization tool to prepare one first.

[0093] Bobsled implements a subset of the Flink CEP Pattern API and adopts it for complex event processing on video streams:

[0094] query = <component> [.<contiguity><component> ] * [.window (<window-size>) ]  / / in #of clips [.f1 (<f1-target>) ] .model (<oracle-model>, <proxy-model>) component = (<condition>) [.minDuration (<minimum-duration>) ]  / / in #of clips [.maxDuration (<maximum-duration>) ]  / / ditto contiguity = followedBy | next

[0095] Compared with Flink’s CEP API, one modification we made is introducing the ‘model’ keyword, which requires the user to specify the oracle and proxy models. Another modification is adding the ‘f1’ keyword, which enables acceleration by requiring users to specify the target F1 score, with a default value of 0.99. As an example:

[0096] ( 'rolling stop') . minDuration (1)  / / Query Q2 .next ( 'right turn') .minDuration (1) .followedBy ( 'left turn') .minDuration (1) .window (5) .f1 (0.99) .model (r (2+1) d-18, c3d-3)

[0097] Other keywords are all inherited from Flink CEP. The keywords ‘minDuration’ and ‘maxDuration’ specify the minimum and maximum duration of an event, respectively. For example, ‘minDuration (1) ’ indicates matching at least one occurrence of the event, which is equivalent to a Kleene plus quantifier. As another example, ( ‘right turn’ ) . minDuration (4) indicates that the ‘right turn’ event must consecutively appear in at least 4 clips in order to consider as a match. Regarding contiguity, strict contiguity is specified by the keyword ‘next’ , while relaxed contiguity is specified by ‘followedBy’ . The window size is determined by the ‘window’ keyword, with a default value of 30 seconds in Bobsled if not specified. In Bobsled, once a match is found, the skip-past-last-event strategy is employed to prevent the return of overlapping results, thereby ensuring diverse results.

[0098] System overview

[0099] Figure 3 illustrates a system overview of Bobsled. More specifically, the present inventioncomprises of four components: query compiler, proxy model, probabilistic pattern (PPAT) , and adaptive event materialization (AEM) . Bobsled can process multiple queries on multiple video streams. Details from the perspective of a single query on a single stream are further described below.

[0100] In addition to translating the query into NFA, the compiler also infers the minimum duration for an event in the query if the user has not specified it. This is necessary because user-perceived events in a video, such as actions, are often mapped from multiple raw model-predicted events that span across multiple clips. For instance, when using a clip size of 16 frames (equivalent to approximately 0.5 seconds) , a user-perceived ‘eating’ action in a video is often represented by several model-predicted ‘eating’ labels spanning multiple consecutive clips. Determining the precise minimum duration for different types of events can be challenging for query users (e.g., what should be the minDuration for a ‘drinking’ event or an ‘eating’ event? ) . Making an uninformed decision could compromise either accuracy (by setting the minimum duration too large) or efficiency (by setting the minimum duration to 1, resulting in reduced selectivity and unnecessary overhead due to prodigal use of the Kleene plus operator) . Therefore, in Bobsled, the compiler automatically infers the minimum duration for all events with unspecified minDuration in the query by analyzing the validation set.

[0101] The NFA, together with the proxy scores predicted by the proxy model, is used to construct a Non-Homogeneous Markov Chain (NHMC) that serves as a Probabilistic Pattern (PPAT) for estimating the probability of a window matching the query pattern. Windows with a high likelihood of not matching the query pattern are filtered early, without performing any additional processing on the clips within the window. The PPAT component determines the decision by deriving a rejection threshold from the target F1 accuracy specified in the query. In a different invention, there is an acceptance threshold, wherein windows with probabilities higher than the acceptance threshold are immediately returned without any additional processing. Accepting based on the acceptance threshold carries the potential for false positives and can impact precision. Similarly, filtering based on the rejection threshold can potentially result in false negatives and impact recall. Given that Bobsled utilizes the F1 metric, which incorporates both precision and recall, as the target accuracy; and considering that complex event queries tend to be more selective than simple event queries, PPAT only establishes the rejection threshold at this stage, prioritizing the filtration of negative windows and deferring the remaining processing to the Adaptive Event Materialization (AEM) module. Windows that cannot be filtered by PPAT are passed to AEM for further inference. AEM aims to select the minimal number of clips to be processed by the oracle model that can potentially lead to early rejection or early acceptance of the window.

[0102] For example, consider a Query Q2, which looks for windows of size five where the first event is a ‘rolling stop’ (RS) , the second event is a ‘right turn’ (RT) , followed by a ‘left turn’ (LT) event that occurs in any other position. Now, the window of events is considered and use ‘? ’ to denote a clip whose event that has not been materialized by the oracle model. Given the window in Figure 4 (a) , if c2 is first selected for oracle inference and confirmed as a ‘left turn’ event, the entire window can be rejected early without needing to materialize the other clips. Alternatively, if clips c1, c2, and c4 are chosen for oracle inference with the followingresults, the present invention can accept the window early without needing to materialize clips c3 and c5. In a nutshell, given a window, AEM aims to pick the next clip that maximize the early acceptance probability if the window eventually matches the query, and conversely, picks the one that maximize the early rejection probability if the window eventually does not match the query. However, it is unknown whether a window matches the query or not in advance. To address this, the present invention employs information entropy to unify these two cases and solve it as a Sequential Information Maximization (SIM) problem using a near-optimal solution.

[0103] Query Compiler

[0104] The query compiler in Bobsled follows the implementation in SASE+, which compiles each query into an NFA first. Notably, the present invention does not implement the match buffer in SASE+, as model inference is the primary bottleneck in Bobsled and a translation to the basic NFA is sufficient for these purposes.

[0105] Since each user perceived event is derived from multiple consecutive model-predicted events, the query compiler automatically annotates the minimum duration for each event if it is not specified in the query before translating the query to an NFA. The minimum duration of each event is obtained offline from the given validation set, which contains ground-truth labels. For each event, Bobsled measures the duration (in terms of the number of clips) for each occurrence in the validation set and records the minimum duration. For instance, if the ‘rolling stop’ event appears five times in the set with duration of 5, 6, 6, 7, and 10, then the minimum duration of ’ rolling stop’ is 5. All events whose corresponding minimum duration is unspecified in the query will have the inferred minimum duration annotated after the compilation.

[0106] Probabilistic Pattern

[0107] Given a window of known events, it is straightforward to determine whether a match exists by evaluating the query’s nondeterministic finite automaton (NFA) . The NFA returns a match if a series of transitions leads to the final state. A proxy model is employed to reduce accesses to the oracle model and to obtain the discrete distribution of each event, and use those uncertain events to build a Probabilistic Pattern (PPAT) for calculating the pattern matching probability. The PPAT is essentially a Non-Homogeneous Markov Chain (NHMC) , which is detailed as follows.

[0108] Non-HomogeneousMarkovChainasthe Probabilistic Pattern

[0109] Given a query pattern, q, a Non-Homogeneous MarkovChain (NHMC) is constructed foreachwindowWtoestimatetheprobability Pr (W|=q) thatWmatchesthepatternq.

[0110] Non-Homogeneous Markov Chain is a variant of Markov Chain. In Markov Chain, the sum of transition probabilities from any given state must equal 1. However, since the transitions from an NFA compiled from the query can be non-mutually exclusive, the NFA cannot directly serve as the state-space and transitions of any Markov Chain. To build the state-space and transitions of an NHMC, it is necessary to use an automaton that is equivalent to the query pattern (NFA) , but with mutually exclusive transitions. In this regard, a Deterministic Finite Automaton (DFA) fits the bill. While there are algorithms, such as Brzozowski Derivatives, that can directly translate the query pattern into a DFA, these methods are often complex and challenging to implement. In the present invention, the powerset construction algorithm is adopted to obtain a DFA from the initial NFA. The DFA can be represented by the 5-tuple (Q′, Σ′, δ′, q′0, F′) , where Q′is a set of states, Σ′is a set of conditions, δ′is the transition function, q′0 is the start state, and F′is the final state. For any two states Si and Sj, there is either exactly one transition fromSi to Sj with the condition σ such that δ′ (Si , σ) = Sj , or no transition at all.

[0111] Figure 4 (b) illustrates the DFA derived from the NFA compiled for example Query Q2. Transitions in this DFA are mutually exclusive. The states and transitions of the DFA can serve as the basis for the states and the transitions of the NHMC, with the transition probabilities derived from the proxy scores. However, the probabilistic pattern matching cannot be modeled by a standard Markov Chain alone, as the transition probabilities are non-homogeneous. Specifically, the transition probability from one state to the other is not static, but instead depends on the current clip-of-interest. For example, consider the DFA in Figure 4 (b) and the window in Figure 4 (a) . If clips c1 and c2 have been consumed and the current state has reached S3, then the transition probability that it stays at S3 is Pr ( left turn|c3) = 0.1 + 0.7 = 0.8. However, assuming the state remains at S3 after consuming c3, then the transition probability that it stays in S3 again should be Pr ( left turn|c4) = 0.05 instead. This explains why Non-Homogeneous Markov Chain is utilized as PPAT.

[0112] In an NHMC, the transition probabilities are represented by a set of transition matrices, each specific to a given time. Here, the discrete-time NHMC is used. Let the set of states be S = {S1, S2, ... } . Each transition matrix Pt is a square matrix with dimensions |S | × |S |, where |S | is the number of states in the NHMC. The (i, j) -th entry of the t-th transition matrix indicates the probability of transitioning from state Si to state Sj at time t. Each transition matrix Pt is constructed using the proxy scores of the clip ct. To build the transition matrix Pt, a random variable et is defined to represent the possible events in clip ct , with its distribution determined by the proxy scores. The entry (Pt) i, j is set to the probability of transitioning from state Si to state Sj given the condition σ: (Pt) i, j = Pr (σ|et ) . If there is no transition from state Si to state Sj, then (Pt) i, j is set to 0. Here, Pr (σ|q ) refers to the probability that the condition σ holds given the distribution of et . Consequently, a window of w clips forms an NHMC with wtransition matrices.

[0113] One caveat is about the final state in the DFA, as Markov Chains inherently do not have terminal states where the process ends. To address this, there is a self-transition feature added with a probability of 1 to the final state obtained from the DFA. Formally, this is achieved by setting (Pt) i, i to 1 if Si is the final state. By using this method, a valid NHMC can be formed based on the query and the proxy scores.

[0114] Figure 4 (c) illustrates the NHMC and some of its transition matrices for Query Q2 based on the window in Figure 4 (a) . For example, consider the entry (P1) 1, 2 in the transition matrix P1. This entry denotes the probability of transitioning from the initial state S1 to state S2 is 0.99 at the beginning of processing the window because the first clip c1 has a probability of 0.99 to be a ‘rolling-stop’ . Similarly, consider the entry (P5) 2, 3 in the transition matrix P5. This entry denotes the probability of transitioning from state S2 to state S3 is 0.7 after consuming c1 to c4, where c5 has a probability of 0.7 being a ‘right turn’ .

[0115] Given an NHMC, the probability that the windoww matches the query q is equivalent to the probability of transitioning from the start state (q′0 ) to the final states (F′) . In NHMC, the transition probability after w steps is calculated by multiplying the w transition matrices together. The resulting matrix indicates the probabilities of transitioning between the states at w-steps. To extract the specific transition probability from the start state to the final state, the present invention employs two indicator vectors u and  Here, u is an indicator vector corresponding to the start state q′0. Specifically, ui = 1 if Si = q′0 and all other entries are 0. Similarly, v is an indicator vector corresponding to the final state F′. Specifically, vi = 1 if Si = F′and all other entries are 0. Thus, the probability that the window W, which consists of clips ct , ct+1, ..., ct+w-1, matches the query q is given by:

[0116] Now, considering the computational aspect, the time complexity of calculating this pattern matching probability is O (w·|S|2) , where w is the window size and |S| is the number of states in the NHMC, which is the same as the number of states in the DFA. While long pattern queries would have a larger |S|, in practice |S| would typically fall within single to double-digit. Furthermore, longer pattern queries also mean they are more selective. This effectively empowers the PPAT with stronger filtering power, which can reduce the number of oracle model accesses.

[0117] The Rejection Threshold

[0118] Given a user-specified F1 target, the present invention translates it to a rejection threshold, t for PPAT. This threshold is determined using a validation set that contains both proxy scores and ground-truth labels. Since the F1 score combines both recall and precision, and the main priority in PPAT is to filter out negative windows, therefore, the precision target, Ptargetis set to 1 and focus on the recall target, Rtarget. With Ptarget = 1, the recall target can be derived from the F1 target:  To achieve the recall target, the present invention follows the approach of Probabilistic Predicate (PP) to determine the rejection threshold. PP seeks the largest threshold that meets the desired recall target based on the live data collected by the system. Specifically, with a given threshold t, recall is calculated as the ratio of windows that both probabilistically match the query (based on threshold t) and truly match the query, to the total number of windows that truly match the query. The objective is to search from a threshold value of 1 down to the threshold value, t that can result in a recall just meeting the target Rtarget. Doing so allows windows with a pattern matching probability below, t to be pruned, without filtering out positive windows. In other words, it strikes a balance between efficiency (pruning non-matching windows) and accuracy (meeting the recall target) . The present invention leaves the use of more sophisticated techniquesto derive thresholds with tighter quality bound as future work.

[0119] Adaptive Event Materialization (AEM)

[0120] In Bobsled, windows that pass PPAT are sent to AEM for further processing. The goal of AEM is to dynamically decide the next clip to be materialized by the oracle model that can potentially lead to early rejection or early acceptance of a window. In other words, it aims to make a sequence of choices online that can result in a clip materialization order that incurs minimal cost. AEM is an optimization technique designed for efficiency without impacting accuracy. In cases where a window has no early stop opportunities (e.g., consider a query ( ‘A’ ) . next ( ‘B’ ) . next ( ‘C’ ) and a window [ABC] ) , the materialization order is immaterial and AEM would materialize all the clips to uphold correctness. However, since pattern matching queries are generally selective, AEM is an effective technique that can bring substantial speedup.

[0121] AEM works by picking the next clip that maximizes the acceptance probability if the window eventually matches the query, or pick the one that maximizes the rejection probability if the window eventually does not match. The challenge is that it is unknown in advance whether the current window will ultimately match the query or not. To address this uncertainty, AEM employs information entropy to unify the decision-making process across these two possible outcomes.

[0122] Let Z be a random variable, representing whether a windowW matches the query q. Zfollows a Bernoulli distribution: Z = 1 if W matches q and Z = 0 otherwise. The uncertainty of Z can be measured by its entropy calculated from the probability that W matches q, denoted as Pr (W |= q) . Initially, when it is uncertain whether W matches q, the entropy of Zis greater than 0. Let ψ be a random variable, representing the materialized events within windowW. As more clips are materialized, the conditional entropy H (Z |ψ) decreases and eventually reaches 0. Thus, minimizing the conditional entropy is equivalent to maximizing the probability of acceptance or rejection.

[0123] Given this unified form, the objective of AEM is to minimize the conditional entropy to zero with the minimal cost. However, since the events are unknown in advance, AEM selects the clips sequentially, frugally materializing them one at a time. Furthermore, to minimize the number of materialized clips, AEM aims to minimize H (Z|ψ) as fast as possible. This is equivalent to maximizing the mutual information between Z and ψ, which measures the amount of information that Z contains about ψ. According to information theory, the present invention now has I (Z; ψ) = H (Z) -H (Z |ψ) , where denotes the mutual information between Z andψ. Since the entropy of Z is a constant, maximizing would lead to minimizing H (Z|ψ) . Therefore, the problem is essentially a Sequential Information Maximization (SIM) problem.

[0124] In SIM, the present invention has random variables Z, Y1, Y2, ..., Ym, where Zdepends deterministically on Y1, Y2, ..., Ym via a function i.e.,  The random variables Y1, Y2, ..., Ym are observable, while Z is not directly observable. To gain the information about Z, a test can be performed on each Yi, which will reveal its outcome yi. Each test incurs a unit of cost. Given a fixed budget of b tests, the goal is to sequentially choose tests that are maximally informative about Z. This sequence of choices is encoded as a policy π: = {π1, π2, ..., πb } , where πi specifies the test at the i-th step. For example, at the first step, a test is performed on Yπ1 and the outcome yπ1 is observed. The outcomes collected through π are denoted as ψπ: = { (Yπ1 , yπ1 ) , (Yπ2 , yπ2 ) , ..., (Yπk , yπk) ) } .

[0125] The optimal policy π* maximizes mutual information between Z andψπ :  Finding the optimal policy π*, however, is an NP-hard problem. Instead, a greedy policy is widely used, which chooses the test with the maximal expected conditional mutual information at each step:  where I = {1, 2, ..., m} and ψπ refers to the materialized events in the previous h steps. This approach is simple and has been proved to be near-optimal. In fact, SIM bears resemblance to multiarm bandit and reinforcement learning (RL) , where the reward can be defined as the reduction of uncertainty. However, in RL, the environment and the inherent uncertainties are unknown, necessitating that RL solutions explore and exploit the environment. In contrast, in SIM, the probability distribution of each Yi is alreadyknown through the proxy scores. As a result, SIM solutions can focus on leveraging this known information to yield near-optimal results, without the need for extensive exploration.

[0126] Now, consider a query q and a windowW of w clips [ct , ct+1, ..., ct+w] . The present invention defines random variables Z, Yt , Yt+1, ..., Yt+wwhere Z represents whetherWmatches the query q, and Yi represents the possible events at clip ci. By adopting the greedy policy of the SIM problem (with a budget of w tests, since a window has a maximum of wclips to materialize) , the present invention materializes the clip with the maximal expected conditional mutual information at each step. Note that the conditional mutual information is calculated by Since is constant for all clips, maximizing the expected conditional mutual information becomes a dual of minimizing the an expected conditional entropy Consequently, for the (h + 1) -th step, the present invention excludes the ones that have already been materialized and pick:

[0127] Efficient computation of expected conditional entropy

[0128] Equation 2 requires computing the expected conditional entropy, i.e.,  times. Each expected conditional entropy is calculated by:

[0129] The conditional entropy is calculated by:

[0130] where Z follows the Bernoulli distribution: Pr (Z= 1 |ψπ, Yi= yi) = Pr (W |=q|ψπ, Yi= yi)      (5) Pr (Z= 0 |ψπ, Yi= yi) =1-Pr (W |=q|ψπ, Yi= yi)      (6)

[0131] According to Equation 1, the pattern matching probability is calculated by constructing w transition matrices from a window withw clips. Therefore, to compute the pattern matching probabilityconditioned on ψπ and Yi= yi, wherein:

[0132] where u and  are indicator vectors as defined in Equation 1. Here, P′i is the transition matrix conditioned on Yi = yi , i.e., it is derived based on conditioning the current clip-of-interest ci , assuming a label yi . P′j and P′k are the transition matrices derived based on having some clips with certain labels (i.e., already after materialization) and some clips remain uncertain. For example, consider the windowW in Figure 5, π = {c2, c4} has already been materialized. Among the uncertain ones, W \ψπ = {c1, c3, c5} , Equation 2 aims to pick the one with the minimum expected conditional entropy. Computing the expected conditional entropy of, say, c3, according to Equation 3, requires considering the entire event space of Y3, i.e., { ‘RS’ , ‘FS’ , ‘RT’ , ‘LT’ } . P′j in Equation 7 refers to the transition matrices constructed by c1 and c2. Similarly, P′k in Equation 7 refers to the transition matrices constructed by c4 and c5. P′i in Equation 7 refers to the transition matrix constructed by c3, conditioning on Y3 equals to ‘RS’ , ‘FS’ , ‘RT’ , or ‘LT’ .

[0133] Computing Equation 3 requires enumerating all possible eventsfor a specific clip. Equation 7 has a complexity of where |S| is dimension of square transition matrix. Denote the size of the event space as |Y|, the complexity of calculating Equation 3 is  Consequently, a naive implementation of Equation 2 requires  While |S| is generally very small, w can be a large number. Note that when computing Equation 3 for Yi of a specific clip ci, the transition matrices of P′j and P′k remain constant during the enumeration of the event space for Yi. Hence, in computing Equation 3, the two terms  in Equation 7 are only calculated once per window, amortizing the complexity of Equation 7 to be As a result, the overall complexity of calculating Equation 3 is reduced to making the computation of Equation 2 linear to the window size.

[0134] Multi-window optimization

[0135] The greedy policy materializes clips within a window in a near-optimal order, and early stops whenever possible. However, the near-optimality is only specific to the current window-of-interest W. In fact, materializing a certain clip withinW would also affect the early acceptance / rejection of all future windows as well. For example, consider the following query: ( 'rolling stop') . minDuration (2)  / / Query Q3 .next ( 'right turn') . minDuration (2) .window (5) .f1 (0.99) .model (r (2 + 1) d -18 , c3d -3)

[0136] In this query, the first event is ‘rolling stop’ (RS) and the second event is ‘right turn’ (RT) , both required to appear in at least two clips to form a match.

[0137] Now consider the video stream in Figure 6, whose oracle labels are shown. None of the first five overlapping windows, W1 toW5 can find a match on the query pattern. When considering window W1 alone, materializing clip c2 first or c4 first can also early reject the window at the same cost of inferencing one clip. However, materializing c4 can actually early reject windows, W2, W3, andW4 as well. In contrast, materializing c2 can only early reject Win addition toW1. In fact, the materialization choice of the current windowW can influence all future windows, including the ones that do not overlap withW. This is because a window that overlaps withW (e.g., W5) would in turn overlap with some other windows (e.g., W9) that are even more further apart.

[0138] To account for this, the present invention enhances the original greedy policy by also considering the benefits to future windows when selecting the next clip to materialize. However, in a streaming context, future events (e.g., events of clips c6, c7, ...) are not visible at the time of decision-making. Therefore, the inventors only considered the best-effort and account for the potential impact on ‘partial windows’ , which are sub-windows that overlap with the current window but include only the events are currently visible. For example, when processing windowW1, the partial windows of interest areW′2 , W′3 , W′4 , andW′5 . The decision of which clip to materialize next would then consider the potential benefits to not only W1, but also to W′2 through W′5.

[0139] To consider the partial windows in the decision-making process, the present invention can derive its corresponding entropy Z′i , where each Z′i indicates whether the partial windowW′i matches the query q. However, the present invention does not need to compute each Z′i individually. Instead, it can be rewritten the query q as q*, which allows the pattern in q to start matching at any position withinWi. For example, for Query Q3, it can be rewritten as: ( 'true') . minDuration (0)  / / Query Q3* .next ( 'rollingstop') . minDuration (2) .next ( 'right turn') . minDuration (2) .window (5) .f1 (0.99) .model (r (2+1) d-18 , c3d -3)

[0140] The rewritten query essentially captures the semantic of matching against the original window and all its corresponding partial windows. Note that the consideration of partial windows is a heuristic, but empirical results have demonstrated that it always brings some improvement in practice.

[0141] Discussion, implementation and optimizations

[0142] In one embodiment, the present invention is implemented in both C++ and Python. Decordis used for video decoding, PyTorch for model training and inference, and NumPy for matrix computation.

[0143] Cross-window Transition Matrix Sharing

[0144] The computation of pattern matching probability is achieved by constructing a Non-Homogeneous Markov Chain (NHMC) . For a window of size w, W transition matrices are constructed to form an NHMC. The construction of these transition matrices becomes computationally expensive when the window size is large. However, since the sliding windows overlap, Bobsled caches and reuses a transition matrix whenever possible. The idea here is similar to the one in ‘Efficient computation of expected conditional entropy’ , but applying it across windows. This approach avoids theduplicate computation of transition matrices for different windows, thereby reducing overhead.

[0145] Batch inference

[0146] In AEM, the greedy policy deliberately selects only one clip to process at each step, which avoids over-materializing any unnecessary ones. However, that would in turn under-utilize the GPU. In Bobsled, batch inference is employed. At each inference, the clips are batched and selected by AEM from concurrent streams video and process them together by the GPU. Clips required by multiple queries on the same video streams would be shared.

[0147] Cold Start and Data Drift

[0148] Bobsled begins with PPAT initially disabled. It gathers proxy scores and oracle labels from the video streams being processed and then enables PPAT after a sufficient number of labels are acquired. During the cold start period, the system operates using AEM only. If there is any stringent latency constraint, the present invention can allocate additional computational resources if needed. Whenever a significant shift in data distribution is detected, Bobsled will recompute the threshold to adapt to the new distribution.

[0149] In video stream analytics, it is observed that interesting patterns (e.g., ‘right-turn-after-rolling-stop’ ) often span short windows in the order of seconds to minutes, instead of long ones in the order of hours. Whilst Bobsled derives the rejection threshold based on a validation set, it is possible that a given query pattern may not have any matches in the validation set, preventing the corresponding threshold from being determined. In such cases, the present invention currently assumes a rejection threshold of 0 and relies on Adaptive Event Materialization (AEM) . In view of action models being under active research and sometimes may not reach satisfactory quality, however, Bobsled can consistently yield considerable speedup regardless of the model accuracy.

[0150] Further embodiments of the present invention are disclosed by way of working examples illustrated below:

[0151] Evaluation

[0152] Evaluations of Bobsled are evaluated based on four real datasets. The experiments were conducted on an Intel Xeon W-2123 server with 80 GB RAM and one NVIDIA GeForce RTX 3090 GPU.

[0153] Dataset

[0154] Table 1 (left side) shows the details of the four real datasets. The BDD100K dataset is a collection of dash-cam footage, with each video being approximately 40 seconds long. Previous researchers have manually labeled 200 videos with five distinct action labels for that dataset, and those 200 videos are concatenated into a single video stream. The MERL dataset is a collection of 106 videos recorded using a fixed overhead camera, capturing peopleshopping in a grocery store setting. Each video is approximately 2 minutes long, and they are concatenated into a single video stream. This dataset also has built-in action labels. Additionally, two more video streams are collected from YouTube: Cooking, and DailyLife. These videos do not have manually labeled action labels. For these datasets, ten action labels are used to be identified by the oracle as the true labels in the experiments. Table 1

[0155] Model

[0156] Table 1 (right) provides details on the oracle and proxy models used in the experiments. All models are pre-trained. For the first two datasets, R (2+1) D-18 model is used as the oracle and the C3D-3 as the proxy. The R (2+1) D-18 model has 18 layers, while the C3D-3 has 3 layers. The first and second datasets have its own specific model pre-trained using their respective training data. The table also lists the accuracy and processing speed (in frames per second) of the models. For the YouTube datasets, the pre-trained X-CLIP-B / 14 is used as the oracle and X-CLIP-B / 32 as the proxy because those videos do not have their own domain-specific pre-trained models available. Since X-CLIP are general zero-shot models, they are also more computationally expensive in terms of processing speed (frames per second) . As there is no ground truth label available for the YouTube videos, the accuracy of X-CLIP-B / 14 and X-CLIP-B / 32 listed in the table are extracted from the results on Kinetics-400 in X-CLIP paper.

[0157] Query

[0158] Table 2 lists the queries used in the evaluation. The queries were constructed to ensure meaningful results could be returned. Each dataset has two benchmark queries, and the pattern length of these queries varies from two to five events. The table also includes the selectivity of the queries.

[0159] Baseline

[0160] Four baselines are constructed to evaluate the system against: ● Localize-all-by-Oracle (All-Oracle) . In this baseline the oracle model is used  to localize all events and then apply Flink’s CEP engine to match the pattern. ● Localize-all-by-Proxy (All-Proxy) . Same as the above, except using the proxy  in place of the oracle model. ● Localize-interested-by-Zeus (Zeus) . Here, the state-of-the-art action  localization system, Zeus is used to first localize only the events specified by the query, and then use Flink’s CEP engine to match the query pattern. Zeus can also accept as input a target F1-score to balance between the speedup and accuracy. ● Query-specific Model-based Filtering (QMF) . Lastly, a model-driven  approach is considered to train a query-specific model for each query. This model takes a window of frames as input and outputs the probability that the window matches the specific query pattern. Windows with probabilities lower than a rejection threshold are discarded. The model is trained in a similar manner the proxy in Bobsled is trained. Additionally, the rejection threshold is calibrated using the same methodology as was used in PPAT. All the frames in the remaining windows are further processed by the oracle model, and the matches are identified using Flink’s CEP engine. The model has a backbone based on the proxy model (i.e., C3D-3 and X-CLIP-B / 32) , but there are two more layersadded and fine-tuned using the query-specific training data.

[0161] Both Zeus and QMF require offline training for their query-specific models. During training, the ratioto split the data for training, validation, and testing for the BDD100K and MERL datasets suggested by previous studies was employed. For the YouTube data, the data is split into training, validation, and testing sets.

[0162] Evaluation metrics

[0163] The system’s performance in terms of throughput (frames processed per second) and accuracy (F1-score) are provided in this section. Given the significant variation in F1-scores across different datasets and queries and express the system’s accuracy using the F1-score relative to the All-Oracle baseline. For calculating the F1-score, we follow the method used in Zeus, which employs Intersection over Union (IoU) as the criterion for a true positive. IoU is a widely used metric for evaluating the alignment between predicted and ground truth intervals in temporal action localization. A match is regarded as a true positive when it has an IoU greater than 0.5 compared to a match found by the All-Oracle baseline. Consequently, a relative accuracy of 1 indicates that the system’s results are identical to those of the All-Oracle within the given IoU range.

[0164] Default configuration

[0165] By default, 16 frames are regarded as one clip, which is approximately half a second. The batch size is set to 8 to fully utilize the GPU. The default window size and F1 target for the queries are 60 clips and 0.99, respectively.

[0166] End-to-end comparison

[0167] Figure 7 presents the performance of Bobsled and the others in terms of throughput and relative accuracy. As a baseline, All-Oracle has an accuracy of 1 but its throughput is also the lowest. In contrast, All-Proxy always has the highest throughput but theworst accuracy. Table 1 (right) clearly tells the reason –a pre-trained proxy model can often process frames an order of magnitude more than its corresponding oracle model, but this comes at the cost of various degrees of accuracy loss. Corroborating with all major results from previous studies, any solution based solely on using the proxy model has unacceptable accuracy. Since All-Proxy has a relative accuracy close to 0, therefore it is excluded from further discussion from now on.

[0168] QMF as a query-specific solution has good relative accuracy for some queries (Q1, Q2, Q3, Q5, Q8) . However, it also has a noticeable accuracy loss in others (Q4, Q6) . Furthermore, its accuracy is simply unacceptable on query Q7. Despite all these, QMF actually shows no significant performance improvement over All-Oracle except on queries with more accuracy loss (i.e., Q6 and Q7) . The reason for this is that the query-specific model struggles to differentiate between the window that matches the query and the one that does not because of its lightweight architecture and the limited number of positive samples (matches) in the training set. Therefore, building a query-specific model to serve as an early filter does not appear to be an effective approach.

[0169] Zeus behaves almost as the opposite of QMF. It has a noticeable performance improvement over All-Oracle, but it also has a significant accuracy loss. This discrepancy arises due to a fundamental difference in the F1 targets. Specifically, Zeus’s F1 target is designed for individual action events, whereas in the setting, the F1 target is aimed at the overall query pattern.

[0170] In contrast, Bobsled consistently maintains high accuracy close to All-Oracle across all queries. In fact, all queries run by Bobsled have a relative accuracy of 100%. Bobsled also achieves 2.3×–5.7× higher throughput than All-Oracle, and a 2.1×–5.7× increase in throughput compared to QMF. When compared to Zeus, Bobsled achieves 1.2×–4.0× higher throughput, except for Q4, where Zeus performs slightly faster than Bobsled but with an unacceptable accuracy loss.

[0171] Ablation study

[0172] An ablation study was carried out to examine the effectiveness of the individual techniques within Bobsled. Figure 8 shows thepercentage of frames from the input video that have eventually materialized by the expensive oracle model for each query.

[0173] As a reference, the inventor includes (a) the materialization ratio of All-Oracle as it is always 1 (i.e., materialize all frames using the oracle) . Then, the inventorreports: (b) the percentage of frames remaining after filtering using PPAT, with AEM disabled. (c) the percentage of frames required to be materialized by the oracle based on AEM, with PPAT disabled. (d) the percentage of frames required to be materialized by the oracle with both PPAT and AEM enabled.

[0174] From the figure, it can be observed that the pruning effectiveness of PPAT varies across datasets and queries. For some queries and datasets (e.g., Q3, Q7) , PPAT can early discard 10–39%of frames. Queries Q5 and Q8 are exceptional cases, as there are no matches for these queries in the validation set. Consequently, Bobsled assumes a rejection threshold of 0 and relies solely on Adaptive Event Materialization (AEM) for these cases. For query Q4, the PPAT is less effective because the proxy model does not perform well on the ‘inspect shelf’ action specified in the query. This results in a low rejection threshold, which limits the ability to filter out many video windows. Nonetheless, it is acceptable for PPAT to have limited pruning power in some cases, as long as it has a low overhead, because Bobsled is designed to have AEM for further pruning. The pruning effectiveness of AEM is independent of PPAT. In all queries, AEM alone can reduce 59–86%of frames to be materialized. When using with PPAT together, PPAT+AEM (i.e., Bobsled) materialize only 8.8% (Q3) to 31.3% (Q1) of frames of the video.

[0175] The pruning power of PPAT and AEM do not come for free. In light of this, Figure 9 shows the processing time breakdownof Bobsled for each query. It can be seen that the stronger pruning power of AEM indeed requires more computation than that of PPAT. Nonetheless, their computation overhead overall is veryworthwhile because they together only consume a minor fraction of the overall processing time but can significantly reduce the number of frames to be processed by the oracle.

[0176] Impact of F1 target

[0177] Figure 10 shows the average throughput and relative accuracy of Bobsled when given different F1 accuracy targets for all queries. As expected, Bobsled’s accuracy increases with a more stringent accuracy requirement, at a cost of lower throughput. More importantly, when the F1 target is above 0.9 (where most users prefer) , the accuracy and performance gain of Bobsled remains higher and stable.

[0178] Impact of pattern length

[0179] Figure 11 shows the throughput and accuracy of Bobsled when the pattern length of Q4 is varied. Q4is chosen because it is the query with the longest pattern of length five in the query set such that the pattern length can be controlled by removing the queried event (s) in it. From the figure, the throughput of Bobsled increases with the pattern length, while maintaining an almost 100%accuracy. As the pattern length of a query increases, it becomes more selective, giving Bobsled’s PPAT and AEM more opportunities to prune a window early, thus improving the throughput.

[0180] Impact ofwindow size

[0181] Figure 12 shows the average throughput and accuracy of Bobsled when the queried window size of all the queries varied from30 clips to 300 clips. As expected, the throughput decreases when a larger window size is used because a larger window has more clips needed to be processed. Nonetheless, we can see that Bobsled remains effective as its throughput drops less than 50%when the window size is increased 10× from 30 clips to 300 clips.

[0182] Impact of materialization policy

[0183] Figure 13 shows the average throughput and accuracy of Bobsled with respect to different adaptive event materialization (AEM) policies. The experiments tested: (i) Sequential, which processes each clip within a window sequentially from the beginning; (ii) Random, which randomly picks a clip within a window every time; (iii) Interval, which selects the ik-th clip at each step i, where k is the pattern length. This ensures that if the materialization of the ik-th clip does not match any event specified in the query pattern, it can potentially reject the window-of-interest with minimal cost and advance the maximum number of windows. (iv) Greedy, which is Bobsled’s greedy policy without multi-window optimization (MWO) ; (v) Greedy+MWO, which is Bobsled’s greedy policy with MWO. From the figure, it can be seen that the greedy policy is more effective that the other basic policies, and the multi-window optimization can further improve the pruning power. Note that the materialization policy does not influence accuracy. Hence, the relative accuracy is not reported here.

[0184] Conclusions

[0185] In conclusion, the present invention provides a novel video stream processing system designed to efficiently support complex event queries. Bobsled employs probabilistic pattern matching and adaptive event materialization to avoid processing unnecessary video clips. Experimental results demonstrate that Bobsled can achieve a significant improvement in processing rate without any noticeable loss in accuracy.

[0186] The present invention explained above is not limited to the aforementioned embodiment and drawings, and it will be obvious to those having an ordinary skill in the art of the present invention that various replacements, deformations, and changes may be made without departing from the scope of the invention.

Claims

1.A system for identifyinga complex event patternin adata input for a real-time video analysis, the system comprises:a query compiler;a proxy model;a first inferencing module; and,a second inferencing module.2.The system according to claim 1, wherein the query compiler is configured to automatically infer a minimum duration for all events with unspecified minimum duration in a query and transform the query into a nondeterministic finite automata (NFA) .3.The system according to claim 1, wherein the proxy model is configured to predict proxy scores of the data input for estimating probability of a window matching a query pattern by the first inferencing module.4.The system according to claim 1, wherein the first inferencing module is a Probabilistic Pattern (PPAT) matching module configured to filter windows with a high likelihood of not matching the query pattern.5.The system according to claim 1 or 4, wherein the first inferencing module is a discrete-time Non-Homogenous Markov Chain (NHMC) with capability to process non-homogenous data input.6.The system according to claim 4, wherein the first inferencing modulefilters windows with the high likelihood of not matching the query patternby estimating the probability of the window matching the query patternbased onthe NFAprovided by the query compiler and the proxy scores predicted by the proxy model.7.The system according to claim 1, wherein the second inferencing module is an adaptive event materialization (AEM) module configured to adaptively materialize events within windows that pass the first inferencing module until it can be determined whether a match is guaranteed or impossible, and return the windows that must contain a match.8.The system according to claim 1 or 7, wherein the second inferencing module further comprises an event materialization policy.9.The system according to claim 8, wherein the second inferencing module sequentially selects and materializesevents within windows that pass the first inferencing module.10.The system according to claim 8, wherein the event materialization policy includes but is not limited to a greedy policy.11.The system according to claim 10, wherein the greedy policy is calculated using the following formulation: 12.The system according to claim 1 or 9, wherein the first inferencing module further caches transition matrices and reuses them to reduce computational overhead for future query matching.13.The system according to claim1, wherein the data input includes but is not limited to decoded video data streams obtained from a plurality of sources.14.The system according to claim 1, wherein the proxy model is pre-trained with real-time data input.15.The system according to any of the precedent claims, wherein the system has a capacity to process the data input individually and in batches, thus accommodating the capacity to be scalable.16.A method for identifying a complex event pattern in a data input for a real-time video analysis, comprising:translating a query into a nondeterministic finite automata (NFA) using a query compiler;predicting scores using a proxy model;estimating probability of a window matching a query pattern;filtering the windows with a high likelihood of not matching the query pattern;materializing events adaptively within the windows until it can be determined whether a match is guaranteed or impossible; andreturning the windows that must contain a match.17.The method according to claim 16, whereinthe step of translating the query into the nondeterministic finite automata (NFA) using the query compiler further comprises:obtaining from a given validation set a measured minimum duration offline;annotating the measured minimum; andtranslating the query into the NFA.18.The method according to claim 16, wherein the step of estimating the probability of the window matching thequery pattern further comprises:adopting the powerset construction algorithm and obtaining a deterministic finite automaton (DFA) from an initial nondeterministic finite automaton (NFA) ;constructing a first inferencing module from the DFA and the proxy scores, wherein the first inferencing module is a discrete-timeNon-Homogeneous Markov Chain (NHMC) ; andusing NHMC for calculating the pattern matching probability.19.The method according to claim 18, wherein the probability of the window matching the query pattern iscalculated using the following formulation: 20.The method according to claim 16, wherein the step of filtering the windows with the high likelihoodof not matching the query pattern further comprisesderiving a rejection threshold.21.The method according to claim 16 or20, wherein the step of filtering the windows with the high likelihood of not matching the query pattern further comprises prioritizing a filtration of negative windows and deferring remaining processing to a second inferencing module.22.The method according to claim 21, wherein the method further comprises the stepoffurther inferring the windows that cannot be filtered.23.The method according to claim 22, wherein the step of further inferring, further comprisesemploying an information entropy to unify decision-making processacross the two cases of window matching the query and window not matching the query.24.The method according to claim 22, whereinthe step of further inferring the windows that cannot be filtered further comprisesselecting clips sequentially and frugally materializing selected clips one at a time.25.The method according to claim 22, whereinthe step of further inferring the windows that cannot be filtered further comprises:choosing the clipswith the maximal expected conditional mutual information ateach step; andconsidering futurewindows in a decision-making process.

Citation Information

Patent Citations

  • Complex event identification method based on ontology model and probability reasoning

    CN110197281A

  • Multi-modal reasoning method and system for video and natural language

    CN113609259A

  • Picture enhanced decoding method for real-time video analysis

    CN115834922A

  • Complex event processing method, electronic equipment, storage medium and vehicle

    CN116450381A

  • Method for identifying illegal fishing boat fishing based on multi-model fusion and multi-parameter combination

    CN116758480A