Track anomaly detection method based on track similarity
Through the detection method based on trajectory similarity, the potential anomaly matrix and concurrent noise matrix are used to identify the abnormal trajectory, which solves the problems of high cost and poor reliability of trajectory anomaly detection in the prior art, and realizes efficient identification of unknown anomaly.
Patent Information
- Application Number
- CN202411751688.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-12-02
AI Technical Summary
Existing trajectory anomaly detection algorithms are costly and have poor reliability, especially when dealing with unseen abnormal patterns, and relying on large amounts of labeled data, it is difficult to meet the requirements of privacy regulations and data collection costs.
Using a detection method based on trajectory similarity, by acquiring multiple target trajectories and applying enhanced operations, the structural and spatial characteristics of trajectory points are calculated, the potential anomaly matrix and concurrent noise matrix are constructed, and the abnormal trajectory is identified, which reduces the dependence on labeled data. , suitable for unknown exception detection.
No need to pre-label trajectories, which reduces data collection and processing costs, improves the reliability and accuracy of trajectory anomaly detection, and is suitable for unknown anomaly detection scenarios.
Smart Images

Figure CN119226988A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of trajectory anomaly detection, and in particular to a trajectory anomaly detection method based on trajectory similarity. Background Art
[0002] Trajectory analysis is a key technology for identifying and predicting traffic patterns in modern traffic monitoring systems. Existing trajectory analysis methods typically rely on supervised learning, which requires large amounts of labeled data to train the models. However, acquiring this data is not only costly but may also be subject to privacy regulations. Furthermore, supervised methods often perform poorly when dealing with unseen anomalous patterns due to their lack of generalization capabilities. Consequently, existing trajectory anomaly detection algorithms suffer from high cost and poor reliability. Summary of the Invention
[0003] The present application provides a trajectory anomaly detection method based on trajectory similarity, which can solve the problems of high cost and poor reliability of trajectory anomaly detection.
[0004] In a first aspect, an embodiment of the present application provides a trajectory anomaly detection method based on trajectory similarity, the trajectory anomaly detection method comprising: Acquire multiple target trajectories and apply an enhancement operation to each target trajectory to obtain a first trajectory and a second trajectory of each target trajectory; For each first trajectory, respectively, calculate a first structural feature and a first spatial feature of each trajectory point in the first trajectory, and calculate a first trajectory feature of the first trajectory based on all the first structural features and the first spatial features; For each second trajectory, calculating a second structural feature and a second spatial feature for each trajectory point in the second trajectory, and calculating a second trajectory feature of the second trajectory based on all the second structural features and the second spatial features; Calculate the similarity between each two target trajectories based on all first trajectory features and all second trajectory features, and construct a potential anomaly matrix based on all similarities; the potential anomaly matrix is used to describe the potential abnormality of each target trajectory; Each target trajectory is divided into multiple trajectory segments according to multiple time periods. The detection error of each target trajectory is obtained using all trajectory segments, and a concurrent noise matrix is constructed based on all detection errors. The concurrent noise matrix is used to describe the false anomaly conditions of each target trajectory. Abnormal trajectories are identified from all target trajectories based on the potential anomaly matrix and the concurrent noise reconstruction matrix.
[0005] Optionally, calculating a first structural feature and a first spatial feature of each trajectory point in the first trajectory includes: By formula: Calculate the The first structural feature of the trajectory point ; in, represents the weight matrix, Indicates the first track Track points, represents the bias term, , represents the number of trajectory points in the first trajectory; By formula: Calculate the The first spatial feature of the trajectory point ; in, represents the weight matrix, represents the bias term.
[0006] Optionally, calculating a first trajectory feature of the first trajectory based on all the first structural features and the first spatial features includes: calculating a structural attention score based on all first structural features and calculating a spatial attention score based on all first spatial features; Performing self-attention encoding on the first trajectory to obtain a trajectory encoding of the first trajectory, and obtaining a contrast enhancement feature of the first trajectory according to the trajectory encoding; The first track feature of the first track is calculated using the structural attention score, spatial attention score, and contrast enhancement feature.
[0007] Optionally, a structural attention score is calculated based on all first structural features, including: By formula: Calculating structural attention score ; in, Represents the structure query vector, represents the structure bond vector, represents a structure value vector, Represents dimension, represents all first structural features, 、 、 Both represent weight matrices; The spatial attention score is calculated based on all first spatial features, including: By formula: Calculating spatial attention score ; in, represents the spatial query vector, represents the spatial key vector, represents a space-valued vector, Represents dimension, represents all first space features, 、 、 Both represent weight matrices; Obtaining contrast enhancement features of the first trajectory according to the trajectory encoding, including: By formula: Computing contrast enhancement features ; in, represents the weight coefficient, represents the trajectory encoding, Indicates the Trajectory encoding of negative sample trajectories, , Indicates the number of negative sample trajectories; The first track features of the first track are calculated using the structural attention score, spatial attention score, and contrast enhancement features, including: By formula: Calculate the first trajectory feature of the first trajectory .
[0008] Optionally, calculating the similarity between every two target trajectories based on all first trajectory features and all second trajectory features includes: By formula: Calculate the The target trajectory and The similarity between target trajectories ; in, Represents similarity calculation, Indicates the The first trajectory feature or the second trajectory feature corresponding to the target trajectory, Indicates the The first trajectory feature or the second trajectory feature corresponding to the target trajectory, , , Indicates the number of target trajectories.
[0009] Optionally, construct a potential anomaly matrix based on all similarities, including: Calculate the anomaly score of each target trajectory based on all similarities; Build a potential anomaly matrix based on all anomaly scores.
[0010] Optionally, calculate an anomaly score for each target track based on all similarities, including: By formula: Calculate the Anomaly score of target trajectories ; Build a potential anomaly matrix based on all anomaly scores, including: By formula: Calculate the elements in the potential anomaly matrix ; in, Indicates the The anomaly score of the target trajectory, represents the anomaly score threshold, when When target trajectory and the target trajectories are marked as potential anomalies.
[0011] Optionally, use all trajectory segments to obtain the detection error of each target trajectory, including: For each trajectory segment, calculate the segment similarity between each other trajectory segment with the same time period as the trajectory segment; Obtain the original features of each trajectory segment, and update the original features of each trajectory segment using the similarity of all segments to obtain the updated features of each trajectory segment; All updated features are used to perform feature reconstruction to obtain multiple reconstructed features; The detection error of each object track is calculated based on all reconstructed features and all original features.
[0012] Optionally, calculate the segment similarity between each other trajectory segment with the same number as the target trajectory and the trajectory segment, including: By formula: Calculate the The target trajectory The trajectory segment and The target trajectory The segment similarity between trajectory segments ; in, Indicates the The target trajectory Track segments, Indicates the The target trajectory Track segments, , , represents the number of target trajectories, , Indicates the number of time periods; All updated features are used to perform feature reconstruction to obtain multiple reconstructed features, including: By formula: Calculate the The target trajectory Reconstructed features of trajectory segments ; in, Indicates the The target trajectory The updated features of the trajectory segments, Indicates the The target trajectory There is a set of target trajectories corresponding to the trajectory segments with segment similarity between the trajectory segments, Represents the weight coefficient: in, Indicates the The initial detection error of the target trajectory is Indicates the The target trajectory and The similarity between target trajectories, Indicates the The anomaly score of each target trajectory; The detection error of each target track is calculated based on all reconstructed features and all original features, including: By formula: Calculate the The detection error of target trajectory ; in, Indicates the The set of original features of all trajectory segments of a target trajectory, Indicates the The set of reconstructed features of all trajectory segments of a target trajectory, represents the L2 norm; Construct a concurrent noise matrix based on all detection errors, including: By formula: Compute elements in the concurrent noise matrix ; in, Indicates the The detection error of the target trajectory is Represents the detection error threshold. When target trajectory and the target tracks are marked as false anomalies.
[0013] Optionally, abnormal trajectories are determined from all target trajectories based on the potential anomaly matrix and the concurrent noise reconstruction matrix, including: By formula: Calculate the target trajectory and the Abnormal value of target trajectory ; in, Represents the first target trajectory and the The elements corresponding to the target trajectory, represents the first target trajectory and the The elements corresponding to the target trajectory, , , represents the number of target trajectories; For each target trajectory, if there is an abnormal condition value of 1 among all abnormal condition values corresponding to the target trajectory, the target trajectory is marked as an abnormal trajectory.
[0014] In a second aspect, an embodiment of the present application provides a trajectory anomaly detection device based on trajectory similarity, comprising: an enhancement module, acquiring a plurality of target trajectories and applying an enhancement operation to each target trajectory to obtain a first trajectory and a second trajectory of each target trajectory; a first calculation module, calculating, for each first trajectory, a first structural feature and a first spatial feature of each trajectory point in the first trajectory, and calculating a first trajectory feature of the first trajectory based on all the first structural features and the first spatial features; a second calculation module, calculating, for each second trajectory, a second structural feature and a second spatial feature of each trajectory point in the second trajectory, and calculating a second trajectory feature of the second trajectory based on all the second structural features and the second spatial features; A first construction module calculates the similarity between each two target trajectories based on all first trajectory features and all second trajectory features, and constructs a potential anomaly matrix based on all similarities; the potential anomaly matrix is used to describe the potential abnormality of each target trajectory; The second construction module divides each target trajectory into multiple trajectory segments according to multiple time periods, uses all trajectory segments to obtain the detection error of each target trajectory, and constructs a concurrent noise matrix based on all detection errors; the concurrent noise matrix is used to describe the false anomaly conditions of each target trajectory; The determination module determines the abnormal trajectories from all target trajectories based on the potential anomaly matrix and the concurrent noise reconstruction matrix.
[0015] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for detecting anomalies of a trajectory based on trajectory similarity is implemented.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned trajectory anomaly detection method based on trajectory similarity.
[0017] The above solution of the present application has the following beneficial effects: In an embodiment of the present application, a plurality of target trajectories are obtained, and an enhancement operation is applied to each target trajectory to obtain a first trajectory and a second trajectory of each target trajectory. Then, for each first trajectory, the first structural feature and the first spatial feature of each trajectory point in the first trajectory are calculated, and the first trajectory feature of the first trajectory is calculated based on all the first structural features and the first spatial features. Then, for each second trajectory, the second structural feature and the second spatial feature of each trajectory point in the second trajectory are calculated, and the second trajectory feature of the second trajectory is calculated based on all the second structural features and the second spatial features. Then, the similarity between each two target trajectories is calculated based on all the first trajectory features and all the second trajectory features, and a potential anomaly matrix is constructed based on all the similarities. Then, each target trajectory is divided into multiple trajectory segments according to multiple time periods, and the detection error of each target trajectory is obtained using all the trajectory segments, and a concurrent noise matrix is constructed based on all the detection errors. Finally, an abnormal trajectory is determined from all target trajectories based on the potential anomaly matrix and the concurrent noise reconstruction matrix. Among them, the similarity between trajectories is used to identify trajectory anomalies, without the need to mark the trajectories in advance, which reduces the cost of data collection and processing. It is also suitable for anomaly detection in unknown anomalies and improves the reliability of trajectory anomaly detection. In addition, the abnormal trajectory is determined based on the potential anomaly matrix and the concurrent noise reconstruction matrix, which improves the accuracy of trajectory anomaly detection.
[0018] Other beneficial effects of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 A flowchart of a trajectory anomaly detection method based on trajectory similarity provided in one embodiment of the present application; Figure 2 A schematic diagram of the structure of a trajectory anomaly detection device based on trajectory similarity provided in one embodiment of the present application; Figure 3 A schematic diagram of the structure of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0022] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0023] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0024] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0025] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0026] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0027] To address the high cost and poor reliability of existing trajectory anomaly detection algorithms, an embodiment of the present application provides a trajectory anomaly detection method based on trajectory similarity. The trajectory anomaly detection method obtains multiple target trajectories and applies an enhancement operation to each target trajectory to obtain a first trajectory and a second trajectory for each target trajectory. Then, for each first trajectory, the first structural feature and the first spatial feature of each trajectory point in the first trajectory are calculated, and the first trajectory feature of the first trajectory is calculated based on all the first structural features and the first spatial features. Then, for each second trajectory, the second structural feature and the second spatial feature of each trajectory point in the second trajectory are calculated, and the second trajectory feature of the second trajectory is calculated based on all the second structural features and the second spatial features. Then, the similarity between each two target trajectories is calculated based on all the first trajectory features and all the second trajectory features, and a potential anomaly matrix is constructed based on all the similarities. Then, each target trajectory is divided into multiple trajectory segments according to multiple time periods, and the detection error of each target trajectory is obtained using all the trajectory segments. A concurrent noise matrix is constructed based on all the detection errors. Finally, an abnormal trajectory is determined from all target trajectories based on the potential anomaly matrix and the concurrent noise reconstruction matrix. Among them, the similarity between trajectories is used to identify trajectory anomalies, without the need to mark the trajectories in advance, which reduces the cost of data collection and processing. It is also suitable for anomaly detection in unknown anomalies and improves the reliability of trajectory anomaly detection. In addition, the abnormal trajectory is determined based on the potential anomaly matrix and the concurrent noise reconstruction matrix, which improves the accuracy of trajectory anomaly detection.
[0028] Next, the trajectory anomaly detection method based on trajectory similarity provided by this application is exemplified.
[0029] like Figure 1 As shown, the trajectory anomaly detection method based on trajectory similarity provided by this application includes the following steps: Step 11: Acquire multiple target trajectories, and apply an enhancement operation to each target trajectory to obtain a first trajectory and a second trajectory of each target trajectory.
[0030] The target trajectory is a trajectory that needs to be detected for trajectory anomaly, such as a vehicle driving trajectory, etc. The target trajectory includes multiple trajectory points.
[0031] In some embodiments of the present application, the above-mentioned enhancement operation can be a point displacement operation, that is, randomly moving the position of the point; a point masking operation, that is, randomly masking certain points and replacing the masked points with placeholders; a trajectory truncation operation, that is, randomly truncating the end part of the trajectory and retaining only the front end, etc., using different enhancement operations to obtain the first trajectory and the second trajectory with different target trajectories.
[0032] For example, after obtaining the target trajectory, normalization and other processing can be performed on it to standardize all target trajectories. The expression is: in, is the target trajectory The mean of is the standard deviation, is the target trajectory obtained after normalization.
[0033] Step 12: Calculate the first structural feature and the first spatial feature of each trajectory point in each first trajectory respectively, and calculate the first trajectory feature of the first trajectory based on all the first structural features and the first spatial features.
[0034] The first structural feature is used to describe the structural information of the trajectory point, such as the shape of the trajectory and the connectivity of the points, and the first spatial feature is used to describe the spatial information of the trajectory point, such as the position of the trajectory point.
[0035] In some embodiments of the present application, the steps of calculating the first structural feature and the first spatial feature of each trajectory point in the first trajectory, and calculating the first trajectory feature of the first trajectory based on all the first structural features and the first spatial features are specifically as follows: In the first step, the first structural feature and the first spatial feature of each trajectory point in the first trajectory are calculated.
[0036] Specifically, through the formula: Calculate the The first structural feature of the trajectory point ; in, represents the weight matrix, Indicates the first track Track points, represents the bias term, , Indicates the number of trajectory points in the first trajectory.
[0037] By formula: Calculate the The first spatial feature of the trajectory point ; in, represents the weight matrix, represents the bias term.
[0038] In the second step, the structural attention score is calculated based on all the first structural features, and the spatial attention score is calculated based on all the first spatial features.
[0039] Specifically, through the formula: Calculating structural attention score ; in, Represents the structure query vector, represents the structure bond vector, represents a structure value vector, Represents dimension, represents all first structural features, 、 、 Both represent weight matrices.
[0040] By formula: Calculating spatial attention score ; in, represents the spatial query vector, represents the spatial key vector, represents a space-valued vector, Represents dimension, represents all first space features, 、 、 Both represent weight matrices.
[0041] In the third step, self-attention encoding is performed on the first trajectory to obtain the trajectory encoding of the first trajectory, and the contrast enhancement feature of the first trajectory is obtained according to the trajectory encoding.
[0042] Specifically, through the formula: Computing contrast enhancement features ; in, represents the weight coefficient, represents the trajectory encoding, Indicates the Trajectory encoding of negative sample trajectories, , Indicates the number of negative sample tracks.
[0043] In the fourth step, the first trajectory feature of the first trajectory is calculated using the structural attention score, spatial attention score, and contrast enhancement feature.
[0044] Specifically, through the formula:
[0045] Calculate the first trajectory feature of the first trajectory .
[0046] Exemplarily, the above steps may be executed using computer software such as MATLAB and Python to obtain the first trajectory feature of the first trajectory.
[0047] It is worth mentioning that by obtaining the first structural features and the first spatial features of the trajectory points in the first trajectory, the structural information and the spatial information of the trajectory points can be characterized, thereby improving the information richness and accuracy of the first trajectory features obtained based on the first structural features and the first spatial features.
[0048] Step 13: For each second trajectory, calculate the second structural feature and the second spatial feature of each trajectory point in the second trajectory, and calculate the second trajectory feature of the second trajectory based on all the second structural features and the second spatial features.
[0049] It should be noted that the process of calculating the second structural features and second spatial features of each trajectory point in the second trajectory and calculating the second trajectory features of the second trajectory based on all the second structural features and second spatial features is consistent with step 12. The second trajectory is processed in the same way as the first trajectory in step 12 to obtain the second trajectory features of the second trajectory.
[0050] In some embodiments of the present application, in order to improve the accuracy of the first trajectory feature and the second trajectory feature, a loss function can be constructed and used to optimize the first trajectory feature and the second trajectory feature. If the value of the loss function is greater than a preset value of the loss function, the parameters in the formula for calculating the first trajectory adjustment and the second trajectory feature are adjusted. If the value of the loss function is less than or equal to the preset value of the loss function, the optimization is completed. The loss function can be: in, represents the value of the loss function, represents the first trajectory feature, represents the second trajectory feature corresponding to the first trajectory feature, represents the first trajectory features of other first trajectories, Indicates the number of target trajectories.
[0051] It is worth mentioning that by obtaining the second structural features and second spatial features of the trajectory points in the second trajectory, the structural information and spatial information of the trajectory points can be characterized, thereby improving the information richness and accuracy of the second trajectory features obtained based on the second structural features and the second spatial features.
[0052] Step 14: Calculate the similarity between every two target trajectories based on all first trajectory features and all second trajectory features, and construct a potential anomaly matrix based on all similarities.
[0053] The above potential anomaly matrix is used to describe the potential anomaly conditions of each target trajectory.
[0054] In some embodiments of the present application, the steps of calculating the similarity between each two target trajectories based on all first trajectory features and all second trajectory features, and constructing a potential anomaly matrix based on all similarities are specifically as follows: In the first step, the similarity between every two target trajectories is calculated based on all first trajectory features and all second trajectory features.
[0055] Specifically, through the formula: Calculate the The target trajectory and The similarity between target trajectories ; in, Represents similarity calculation, Indicates the The first trajectory feature or the second trajectory feature corresponding to the target trajectory, Indicates the The first trajectory feature or the second trajectory feature corresponding to the target trajectory, , , Indicates the number of target trajectories.
[0056] It should be noted that For the One of the first trajectory feature or the second trajectory feature corresponding to each target trajectory is randomly selected to participate in the calculation.
[0057] In the second step, the anomaly score of each target trajectory is calculated based on all similarities.
[0058] Specifically, through the formula: Calculate the Anomaly score of target trajectories .
[0059] In the third step, a potential anomaly matrix is constructed based on all anomaly scores.
[0060] Specifically, through the formula: Calculate the elements in the potential anomaly matrix .
[0061] in, Indicates the The anomaly score of the target trajectory, represents the anomaly score threshold, when When target trajectory and the target trajectories are marked as potential anomalies when When target trajectory and the None of the target trajectories are marked as potential anomalies.
[0062] It should be noted that the potential anomaly matrix includes elements, each of which takes the value of 1 or 0, describing whether the corresponding two target trajectories are both marked as potential anomalies.
[0063] It is worth mentioning that by calculating the similarity between target trajectories and constructing a potential anomaly matrix, the similarity between target trajectories can be analyzed to preliminarily determine whether there is an anomaly in each target trajectory.
[0064] In step 15, each target trajectory is divided into multiple trajectory segments according to multiple time periods, and the detection error of each target trajectory is obtained using all the trajectory segments, and a concurrent noise matrix is constructed based on all the detection errors.
[0065] The above concurrent noise matrix is used to describe the false anomaly conditions of each target trajectory.
[0066] In some embodiments of the present application, the steps of dividing each target trajectory into multiple trajectory segments according to multiple time periods, obtaining the detection error of each target trajectory using all trajectory segments, and constructing a concurrent noise matrix based on all detection errors are specifically as follows: In the first step, each target trajectory is divided into multiple trajectory segments according to multiple time periods.
[0067] For example, the target trajectory can be divided using a time window. For example, the corresponding segment of the first target trajectory in the first time period is divided into a trajectory segment and marked as the first trajectory segment of the first target trajectory, corresponding to the first time period. The corresponding segment of the second target trajectory in the first time period is divided into a trajectory segment and marked as the first trajectory segment of the second target trajectory, which also corresponds to the first time period. When dividing all target trajectories, the window size used is the same, and the time points corresponding to the starting points of all target trajectories are aligned with the starting time point of the first time period.
[0068] In the second step, for each trajectory segment, the segment similarity between each other trajectory segment with the same time period as the trajectory segment is calculated.
[0069] Specifically, through the formula: Calculate the The target trajectory The trajectory segment and The target trajectory The segment similarity between trajectory segments ; in, Indicates the The target trajectory Track segments, Indicates the The target trajectory Track segments, , , represents the number of target trajectories, , Indicates the number of time periods.
[0070] For example, for each divided window (ie, time period), multiple trajectory segments corresponding to the divided window can be used as multiple nodes, and similarities between the nodes can be used as edges to construct a graph structure.
[0071] The third step is to obtain the original features of each trajectory segment and update the original features of each trajectory segment using the similarity of all segments to obtain the updated features of each trajectory segment.
[0072] For example, a model such as a gated neural network can be used to obtain the original features, and a graph convolutional neural network can be used to update the original features to obtain updated features. The calculation formula of the graph convolutional neural network is: in, Indicates the Layer The target trajectory The features corresponding to the trajectory segments, Indicates the Layer The target trajectory The features corresponding to the trajectory segments, With the The target trajectory There is a set of target trajectories corresponding to the trajectory segments with segment similarity between the trajectory segments (if a graph structure is constructed, For the The target trajectory The set of neighbor nodes of the node corresponding to the trajectory segment). represents the adaptive propagation weight, Indicates the The target trajectory The trajectory segment and The target trajectory The segment similarity between trajectory segments, Indicates the The weights of the layers, Indicates the The bias of the layer, , Represents the total number of layers of the graph convolutional neural network. hour, Indicates the The target trajectory The original features of the trajectory segments, when hour, Indicates the The target trajectory Update features of each trajectory segment.
[0073] It should be noted that the adaptive propagation weight The calculation formula is: in, represents an adjustable hyperparameter, Indicates the The target trajectory The trajectory segment and The target trajectory The segment similarity between trajectory segments.
[0074] The fourth step is to use all updated features to perform feature reconstruction and obtain multiple reconstructed features.
[0075] Specifically, through the formula: Calculate the The target trajectory Reconstructed features of trajectory segments .
[0076] in, Indicates the The target trajectory The updated features of the trajectory segments, With the The target trajectory There is a set of target trajectories corresponding to the trajectory segments with segment similarity between the trajectory segments, Represents the weight coefficient: in, Indicates the The initial detection error of the target trajectory is Indicates the The target trajectory and The similarity between target trajectories, Indicates the The anomaly score of each target trajectory.
[0077] In the fifth step, the detection error of each target track is calculated based on all reconstructed features and all original features.
[0078] Specifically, through the formula: Calculate the The detection error of target trajectory .
[0079] in, Indicates the The set of original features of all trajectory segments of a target trajectory, Indicates the The set of reconstructed features of all trajectory segments of a target trajectory, represents the L2 norm.
[0080] In the sixth step, a concurrent noise matrix is constructed based on all detection errors.
[0081] Specifically, through the formula: Compute elements in the concurrent noise matrix .
[0082] in, Indicates the The detection error of the target trajectory is Represents the detection error threshold. When target trajectory and the target tracks are marked as false anomalies when When target trajectory and the target tracks are not marked as false anomalies.
[0083] It should be noted that the concurrent noise matrix includes elements, each of which takes the value of 1 or 0, describing whether the corresponding two target trajectories are both marked as false anomalies.
[0084] It is worth mentioning that by dividing the target trajectory into multiple trajectory segments and analyzing the trajectory segments, a detailed analysis of the target trajectory is achieved, which improves the accuracy of the elements in the concurrent noise matrix.
[0085] In step 16, abnormal trajectories are determined from all target trajectories according to the potential abnormality matrix and the concurrent noise reconstruction matrix.
[0086] In some embodiments of the present application, the step of determining abnormal trajectories from all target trajectories based on the potential abnormality matrix and the concurrent noise reconstruction matrix is specifically as follows: The first step is through the formula: Calculate the target trajectory and the Abnormal value of target trajectory .
[0087] in, Represents the first target trajectory and the The elements corresponding to the target trajectory, represents the first target trajectory and the The elements corresponding to the target trajectory, , , Indicates the number of target trajectories.
[0088] The logic of the above formula is: if and , that is, target trajectory and the target trajectories are marked as potential anomalies but are not affected by concurrent noise, then , indicating that they are finally judged as abnormal trajectories.
[0089] if and , that is, target trajectory and the target trajectories are marked as potential anomalies, but may be affected by concurrent noise, then , indicating that they are excluded as false anomalies.
[0090] if , then regardless of What is the value of ? , indicating that the two trajectories are considered normal.
[0091] In the second step, for each target trajectory, if there is an abnormal condition value of 1 among all abnormal condition values corresponding to the target trajectory, the target trajectory is marked as an abnormal trajectory.
[0092] Exemplarily, the abnormal condition values of the first target trajectory, the second target trajectory, the third target trajectory, and the fourth target trajectory are 0, 1, 0, and 0 respectively. If there is an abnormal condition value of 1, the first target trajectory is marked as an abnormal trajectory.
[0093] It is worth mentioning that the similarity between trajectories is used to identify trajectory anomalies. There is no need to mark the trajectories in advance, which reduces the cost of data collection and processing. It is also suitable for anomaly detection in unknown anomalies and improves the reliability of trajectory anomaly detection. In addition, the abnormal trajectory is determined based on the potential anomaly matrix and the concurrent noise reconstruction matrix, which improves the accuracy of trajectory anomaly detection.
[0094] The following is an exemplary description of the trajectory anomaly detection device based on trajectory similarity provided by this application.
[0095] like Figure 2 As shown, the embodiment of the present application provides a trajectory anomaly detection device based on trajectory similarity. The trajectory anomaly detection device 200 based on trajectory similarity includes: An enhancement module 201 acquires a plurality of target trajectories and applies an enhancement operation to each target trajectory to obtain a first trajectory and a second trajectory of each target trajectory; A first calculation module 202 calculates, for each first trajectory, a first structural feature and a first spatial feature of each trajectory point in the first trajectory, and calculates a first trajectory feature of the first trajectory based on all the first structural features and the first spatial features; A second calculation module 203 calculates, for each second trajectory, a second structural feature and a second spatial feature of each trajectory point in the second trajectory, and calculates a second trajectory feature of the second trajectory based on all the second structural features and the second spatial features; The first construction module 204 calculates the similarity between each two target trajectories based on all the first trajectory features and all the second trajectory features, and constructs a potential anomaly matrix based on all the similarities; the potential anomaly matrix is used to describe the potential abnormality of each target trajectory; The second construction module 205 divides each target trajectory into multiple trajectory segments according to multiple time periods, obtains the detection error of each target trajectory using all the trajectory segments, and constructs a concurrent noise matrix based on all the detection errors; the concurrent noise matrix is used to describe the false anomaly condition of each target trajectory; The determination module 206 determines abnormal trajectories from all target trajectories according to the potential abnormality matrix and the concurrent noise reconstruction matrix.
[0096] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0097] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0098] like Figure 3 As shown, an embodiment of the present application provides a terminal device. The terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 3 Only one processor is shown in the figure), a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100, wherein the processor D100 implements the steps of any of the above-mentioned method embodiments when executing the computer program D102.
[0099] Specifically, when the processor D100 executes the computer program D102, it obtains multiple target trajectories and applies an enhancement operation to each target trajectory to obtain a first trajectory and a second trajectory of each target trajectory. Then, for each first trajectory, the first structural feature and the first spatial feature of each trajectory point in the first trajectory are calculated, and the first trajectory feature of the first trajectory is calculated based on all the first structural features and the first spatial features. Then, for each second trajectory, the second structural feature and the second spatial feature of each trajectory point in the second trajectory are calculated, and the second trajectory feature of the second trajectory is calculated based on all the second structural features and the second spatial features. Then, the similarity between each two target trajectories is calculated based on all the first trajectory features and all the second trajectory features, and a potential anomaly matrix is constructed based on all the similarities. Then, each target trajectory is divided into multiple trajectory segments according to multiple time periods, and all the trajectory segments are used to obtain the detection error of each target trajectory, and a concurrent noise matrix is constructed based on all the detection errors. Finally, the abnormal trajectory is determined from all the target trajectories based on the potential anomaly matrix and the concurrent noise reconstruction matrix. Among them, the similarity between trajectories is used to identify trajectory anomalies, without the need to mark the trajectories in advance, which reduces the cost of data collection and processing. It is also suitable for anomaly detection in unknown anomalies and improves the reliability of trajectory anomaly detection. In addition, the abnormal trajectory is determined based on the potential anomaly matrix and the concurrent noise reconstruction matrix, which improves the accuracy of trajectory anomaly detection.
[0100] The processor D100 may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or any conventional processor.
[0101] In some embodiments, the memory D101 may be an internal storage unit of the terminal device D10, such as a hard disk or memory of the terminal device D10. In other embodiments, the memory D101 may also be an external storage device of the terminal device D10, such as a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device D10. Furthermore, the memory D101 may include both an internal storage unit of the terminal device D10 and an external storage device. The memory D101 is used to store an operating system, application programs, a boot loader, data, and other programs, such as the program code of the computer program. The memory D101 may also be used to temporarily store data that has been output or is about to be output.
[0102] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned various method embodiments can be implemented.
[0103] An embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0104] If the integrated unit is implemented as a software functional unit and sold or used as a standalone product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process steps in the above-mentioned method embodiments by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to the trajectory anomaly detection method apparatus / terminal device based on trajectory similarity, a recording medium, computer memory, read-only memory (ROM), random access memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Examples include a USB flash drive, a removable hard drive, a magnetic disk, or an optical disk.
[0105] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0106] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0107] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A trajectory anomaly detection method based on trajectory similarity, characterized in that: include: Acquire multiple target trajectories, and apply an enhancement operation to each of the target trajectories to obtain a first trajectory and a second trajectory of each of the target trajectories; For each of the first trajectories, respectively, calculate a first structural feature and a first spatial feature of each trajectory point in the first trajectory, and calculate a first trajectory feature of the first trajectory based on all the first structural features and the first spatial features; For each of the second trajectories, respectively, calculate a second structural feature and a second spatial feature of each trajectory point in the second trajectory, and calculate a second trajectory feature of the second trajectory based on all the second structural features and the second spatial features; Calculate the similarity between every two target trajectories according to all first trajectory features and all second trajectory features, and construct a potential anomaly matrix based on all similarities; The potential anomaly matrix is used to describe the potential abnormal conditions of each target trajectory; Divide each of the target trajectories into a plurality of trajectory segments according to a plurality of time periods, obtain the detection error of each of the target trajectories using all the trajectory segments, and construct a concurrent noise matrix based on all the detection errors; the concurrent noise matrix is used to describe the false abnormality of each target trajectory; An abnormal track is determined from all target tracks according to the potential anomaly matrix and the concurrent noise reconstruction matrix.
2. The trajectory anomaly detection method according to claim 1, characterized in that: The calculating the first structural feature and the first spatial feature of each trajectory point in the first trajectory includes: By formula: Calculate the The first structural feature of the trajectory point ; in, represents the weight matrix, Indicates the first track Track points, represents the bias term, , represents the number of trajectory points in the first trajectory; By formula: Calculate the The first spatial feature of the trajectory points ; in, represents the weight matrix, Represents the bias term.
3. The trajectory anomaly detection method according to claim 1, characterized in that: The calculating the first trajectory feature of the first trajectory based on all the first structural features and the first spatial features comprises: Calculating a structural attention score based on all first structural features, and calculating a spatial attention score based on all first spatial features; Performing self-attention encoding on the first trajectory to obtain a trajectory encoding of the first trajectory, and obtaining a contrast enhancement feature of the first trajectory according to the trajectory encoding; The first trajectory feature of the first trajectory is calculated using the structural attention score, the spatial attention score, and the contrast enhancement feature.
4. The trajectory anomaly detection method according to claim 3, characterized in that: The calculating of the structural attention score based on all the first structural features comprises: By formula: Calculate the structural attention score ; in, represents the structure query vector, represents the structure key vector, represents a structure value vector, Represents the dimension, represents all first structural features, , , Both represent weight matrices; The calculating of the spatial attention score based on all the first spatial features comprises: By formula: Calculate the spatial attention score ; in, represents the spatial query vector, represents the spatial key vector, represents a space-valued vector, Represents the dimension, represents all first space features, , , Both represent weight matrices; The acquiring the contrast enhancement feature of the first trajectory according to the trajectory encoding includes: By formula: Computing contrast enhancement features ; in, represents the weight coefficient, represents the trajectory encoding, Indicates The trajectory encoding of negative sample trajectories, , Represents the number of negative sample trajectories; The calculating the first trajectory feature of the first trajectory by using the structural attention score, the spatial attention score, and the contrast enhancement feature includes: By formula: Calculate the first trajectory feature of the first trajectory .
5. The trajectory anomaly detection method according to claim 1, characterized in that: The calculating the similarity between every two target trajectories according to all the first trajectory features and all the second trajectory features includes: By formula: Calculate the The target trajectory and The similarity between target trajectories ; in, Represents similarity calculation, Indicates The first trajectory feature or the second trajectory feature corresponding to the target trajectory, Indicates The first trajectory feature or the second trajectory feature corresponding to the target trajectory, , , Indicates the number of target trajectories.
6. The trajectory anomaly detection method according to claim 5, characterized in that: The potential anomaly matrix is constructed based on all similarities, including: Calculate the anomaly score of each target track based on all similarities; Construct a potential anomaly matrix based on all anomaly scores.
7. The trajectory anomaly detection method according to claim 6, characterized in that: The anomaly score of each target track is calculated based on all similarities, including: By formula: Calculate the Anomaly score of target trajectories ; The potential anomaly matrix is constructed according to all anomaly scores, including: By formula: Calculate the elements in the potential anomaly matrix ; in, Indicates The anomaly score of the target trajectory, represents the anomaly score threshold, when When The target trajectory and target tracks are marked as potential anomalies.
8. The trajectory anomaly detection method according to claim 1, characterized in that: The method of obtaining the detection error of each target trajectory by using all trajectory segments includes: For each trajectory segment, respectively, calculate the segment similarity between each other trajectory segment having the same time period as the trajectory segment and the trajectory segment; Acquire the original features of each trajectory segment, and update the original features of each trajectory segment using all segment similarities to obtain updated features of each trajectory segment; All updated features are used to perform feature reconstruction to obtain multiple reconstructed features; The detection error of each object track is calculated based on all reconstructed features and all original features.
9. The trajectory anomaly detection method according to claim 8, characterized in that: The calculating of the segment similarity between each other trajectory segment having the same number as the target trajectory segment and the trajectory segment includes: By formula: Calculate the The target trajectory The trajectory segment and The target trajectory The segment similarity between trajectory segments ; in, Indicates The target trajectory A trajectory segment, Indicates The target trajectory A trajectory segment, , , represents the number of target trajectories, , Indicates the number of time periods; The feature reconstruction is performed using all updated features to obtain multiple reconstructed features, including: By formula: Calculate the The target trajectory Reconstructed features of trajectory segments ; in, Indicates The target trajectory The updated features of the trajectory segments, Indicates that The target trajectory There is a set of target trajectories corresponding to the trajectory segments with segment similarity between the trajectory segments, Represents the weight coefficient: in, Indicates The initial detection error of the target trajectory is Indicates The target trajectory and The similarity between target trajectories is Indicates The anomaly score of each target track; The detection error of each target track is calculated based on all the reconstructed features and all the original features, including: By formula: Calculate the The detection error of the target trajectory ; in, Indicates the The set of original features of all trajectory segments of a target trajectory, Indicates the The set of reconstructed features of all trajectory segments of a target trajectory, represents the L2 norm; The concurrent noise matrix is constructed based on all detection errors, including: By formula: Compute the elements in the concurrent noise matrix ; in, Indicates The detection error of the target trajectory is Represents the detection error threshold. When The target trajectory and target tracks are marked as false anomalies.
10. The trajectory anomaly detection method according to claim 1, characterized in that: The determining of abnormal trajectories from all target trajectories according to the potential abnormal matrix and the concurrent noise reconstruction matrix includes: By formula: Calculate the The target trajectory and Abnormal value of target trajectory ; in, Represents the potential anomaly matrix The target trajectory and The elements corresponding to the target trajectory are represents the number of concurrent noise reconstruction matrices The target trajectory and The elements corresponding to the target trajectory are , , represents the number of target trajectories; For each of the target trajectories respectively, if there is an abnormal condition value with a value of 1 among all abnormal condition values corresponding to the target trajectory, the target trajectory is marked as an abnormal trajectory.
Citation Information
Patent Citations
Urban traffic illegal behavior detection method based on video monitoring system
CN103942533A
Ship trajectory model establishment and abnormal trajectory detection method
CN111949750A
Traffic flow prediction method, device, equipment and medium
CN118522151A
