Trajectory similarity calculation method, trajectory similarity calculation device, and storage medium

By setting a threshold and pruning invalid paths in trajectory similarity calculation, the problem of low efficiency in discrete Fréchet distance calculation is solved, and efficient trajectory similarity calculation is achieved.

CN115982592BActive Publication Date: 2026-04-21ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG DAHUA TECH CO LTD
Filing Date
2022-10-27
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, the calculation efficiency of discrete Fréchet distance is low, resulting in low efficiency in trajectory similarity calculation.

Method used

By calculating the lower bound of the distance between trajectory points and setting a preset threshold, invalid computational paths are pruned, and trajectory similarity is calculated using the threshold-constrained distance matrix and a two-dimensional dynamic array.

Benefits of technology

It effectively reduces invalid calculations, improves the efficiency of trajectory similarity calculation, and saves computational costs and complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115982592B_ABST
    Figure CN115982592B_ABST
Patent Text Reader

Abstract

This application discloses a trajectory similarity calculation method, a trajectory similarity calculation device, and a computer storage medium. The trajectory similarity calculation method includes: acquiring at least two trajectories; calculating a distance matrix between the trajectories based on a first trajectory and a second trajectory, wherein the distance matrix includes distances between several trajectory points; traversing the distances between trajectory points in the distance matrix and obtaining a lower bound value for the position of each trajectory point distance; determining whether there exists a lower bound value for the position of any trajectory point distance that is greater than or equal to a preset threshold; if so, setting the trajectory similarity between the first trajectory and the second trajectory to a preset distance. Through this method, this application performs thresholding on the distance matrix based on the first and second trajectories using a preset threshold, and compares the lower bound value of each point in the distance matrix with the preset threshold, thereby directly excluding trajectory similarity calculations where the lower bound value is greater than or equal to the preset threshold, thus reducing the time required to calculate trajectory similarity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data mining, and in particular to a trajectory similarity calculation method, a trajectory similarity calculation device, and a computer storage medium. Background Technology

[0002] With the continuous development of science and technology, more and more people are choosing to travel by car. Analyzing vehicle travel trajectories to extract spatiotemporal information data has become a hot topic in academia and industry. Among these, measuring the similarity of vehicle travel trajectories is one of the most crucial issues.

[0003] In one application scenario, an intuitive approach to measuring the similarity of vehicle trajectories is to calculate the distance between them. Currently, there are many methods for measuring the distance between trajectories, such as maximum distance, minimum distance, average distance, and Hausdorff distance. However, these methods may suffer from distortion in measuring trajectory similarity when trajectories exhibit backtracking, loops, or intersections. Discrete Fréchet distance, on the other hand, incorporates the temporal relationships between trajectory points and considers the internal node structure of the trajectory during calculation. It can more accurately assess the similarity between trajectories, thus possessing stronger descriptive power and being most suitable as a measure of trajectory similarity. However, current techniques typically involve iterative calculations based on the definition of discrete Fréchet distance, resulting in very low computational efficiency. Summary of the Invention

[0004] The main technical problem addressed by this application is the low efficiency of current discrete Fréchet distance calculation. To address this, this application provides a trajectory similarity calculation method, a trajectory similarity calculation device, and a computer-readable storage medium.

[0005] To solve the above-mentioned technical problems, one technical solution adopted in this application is: providing a trajectory similarity calculation method, the method comprising: acquiring at least two trajectories, wherein the at least two trajectories include a first trajectory and a second trajectory; calculating a distance matrix between the trajectories based on the first trajectory and the second trajectory, wherein the distance matrix includes a plurality of trajectory point distances, each trajectory point distance being calculated by the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory; traversing the trajectory point distances in the distance matrix to obtain a lower bound value of the position of each trajectory point distance, wherein the lower bound value of the position of the trajectory point distance is the minimum value among the distance of the trajectory point distance and the distance of its horizontally adjacent trajectory point and its vertically adjacent trajectory point; determining whether there exists any trajectory point distance whose lower bound value is greater than or equal to a preset threshold; if so, setting the trajectory similarity between the first trajectory and the second trajectory to a preset distance; wherein the horizontal coordinates of the horizontally adjacent trajectory points are the same as the horizontal coordinates of the trajectory point distance, and the vertical coordinates of the horizontally adjacent trajectory points are less than the vertical coordinates of the trajectory point distance; the vertical coordinates of the vertically adjacent trajectory points are the same as the vertical coordinates of the trajectory point distance, and the horizontal coordinates of the vertically adjacent trajectory points are less than the horizontal coordinates of the trajectory point distance.

[0006] The method for calculating trajectory similarity after calculating the distance matrix between the first and second trajectories includes: updating the distance matrix based on a preset threshold, and setting the distance between trajectory points in the distance matrix whose values ​​are greater than or equal to the preset threshold as the preset distance, so as to obtain a threshold-constrained distance matrix.

[0007] The trajectory similarity calculation method further includes: creating a two-dimensional dynamic array based on the first trajectory and the second trajectory when there is no lower bound value of the distance between trajectory points that is greater than or equal to a preset threshold; calculating the element values ​​of the two-dimensional dynamic array based on the threshold constraint distance matrix according to the path planning conditions; and determining the trajectory similarity between the first trajectory and the second trajectory according to the element values ​​of the two-dimensional dynamic array.

[0008] Specifically, based on the threshold constraint distance matrix and according to the path planning conditions, the element values ​​of the two-dimensional dynamic array are calculated, including: in response to the fact that the distance to any point in the trajectory matrix is ​​a preset distance, the value of the element value of the distance to any point in the trajectory matrix is ​​set to the value of the preset distance.

[0009] The calculation of the element values ​​of the two-dimensional dynamic array based on the distance matrix and path planning conditions includes: determining the neighboring elements of the current element in the two-dimensional dynamic array according to the path planning conditions; and obtaining the element value of the current element based on the distance matrix and the neighboring elements of the current element.

[0010] The process of obtaining the element value of the current element based on the distance matrix and its neighboring elements includes: obtaining the distance to the current trajectory point corresponding to the current element based on the distance matrix; obtaining the element values ​​of the neighboring elements of the current element and determining the minimum element value of the neighboring elements of the current element; and taking the maximum value between the minimum element value and the distance to the current trajectory point as the element value of the current element.

[0011] The trajectory similarity calculation method further includes, before determining the adjacent elements of the current element in the two-dimensional dynamic array according to the path planning conditions: locating the starting distance of the distance matrix and the starting element of the two-dimensional dynamic array according to the starting point of the first trajectory and the starting point of the second trajectory; and determining the value of the starting distance as the element value of the starting element.

[0012] The path planning condition is that the coordinates of the current element are greater than the coordinates of the adjacent elements; where the coordinates include the first coordinate and / or the second coordinate.

[0013] The process of determining the trajectory similarity between the first trajectory and the second trajectory based on the element values ​​of the two-dimensional dynamic array includes: locating the endpoint element of the two-dimensional dynamic array based on the endpoint of the first trajectory and the endpoint of the second trajectory; and determining the trajectory similarity between the first trajectory and the second trajectory using the element values ​​of the endpoint element of the two-dimensional dynamic array.

[0014] To solve the above-mentioned technical problems, another technical solution adopted in this application is: to provide a trajectory similarity calculation device, which includes a processor and a memory, the memory being coupled to the processor, the memory storing program data, and the processor executing the program data to implement the trajectory similarity calculation method as described above.

[0015] To solve the above-mentioned technical problems, another technical solution adopted in this application is to provide a computer-readable storage medium that stores program data, which, when executed, is used to implement the above-mentioned trajectory similarity calculation method.

[0016] The beneficial effects of this application are as follows: Unlike existing technologies, the trajectory similarity calculation method provided in this application is applied to a trajectory similarity calculation device. The trajectory similarity calculation device acquires at least two trajectories, including a first trajectory and a second trajectory. A distance matrix between the trajectories is calculated based on the first and second trajectories. This distance matrix includes distances between several trajectory points, each distance calculated from the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory. The distances between trajectory points in the distance matrix are traversed to obtain the lower bound of the position of each trajectory point distance. This lower bound is the minimum value among the distances between the trajectory point and its horizontally adjacent trajectory points and its vertically adjacent trajectory points. It is determined whether any lower bound of the position of a trajectory point distance is greater than or equal to a preset threshold. If so, the trajectory similarity between the first and second trajectories is set to a preset distance. Specifically, the horizontal coordinates of horizontally adjacent trajectory points are the same as the horizontal coordinates of the trajectory point distance, and the vertical coordinates of horizontally adjacent trajectory points are less than the vertical coordinates of the trajectory point distance. Similarly, the vertical coordinates of vertically adjacent trajectory points are the same as the vertical coordinates of the trajectory point distance, and the horizontal coordinates of vertically adjacent trajectory points are less than the horizontal coordinates of the trajectory point distance. Compared to conventional trajectory similarity calculation methods, this application employs a distance threshold constraint when calculating the distance matrix of two trajectories. This threshold is used to determine the lower bound of the distance between two trajectory points, directly excluding trajectories with a lower bound greater than or equal to the preset threshold. This method effectively reduces invalid calculations and significantly improves computational efficiency. This trajectory similarity calculation method saves on trajectory distance calculation costs through threshold constraints, and the determination of the lower bound of the distance reduces computational complexity and avoids invalid calculations. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] in:

[0019] Figure 1 This is a flowchart illustrating an embodiment of the trajectory similarity calculation method provided in this application;

[0020] Figure 2 This is a schematic diagram of the trajectory similarity calculation device provided in this application performing the trajectory similarity calculation method;

[0021] Figure 3This is a schematic diagram of an embodiment of the first and second trajectories provided in this application;

[0022] Figure 4 This is a schematic diagram of the structure of the first embodiment of the trajectory similarity calculation device provided in this application;

[0023] Figure 5 This is a schematic diagram of the structure of the second embodiment of the trajectory similarity calculation device provided in this application;

[0024] Figure 6 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium provided in this application;

[0025] Figure 7 A geometrical diagram illustrating the lower bound of position (4,3) in the trajectory similarity method provided in this application. Detailed Implementation

[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0027] With continuous social development, especially in urban areas, more and more roads and intersections are equipped with various types of vehicle monitoring devices. These devices play a significant role in controlling and penalizing traffic violations such as speeding, using mobile phones while driving, and running red lights. Simultaneously, these devices effectively record the travel trajectories of various vehicles on urban roads. As spatiotemporal information data of vehicles, vehicle travel trajectories contain rich and valuable information on various vehicle travel patterns. How to utilize data mining techniques to extract information from vehicle travel trajectories has increasingly become a hot topic of interest in academia and industry.

[0028] In the process of using data mining techniques to analyze vehicle travel trajectories, calculating the similarity between these trajectories is one of the most crucial issues. By calculating the similarity between trajectories, it is possible to uncover a city's travel patterns, which has immeasurable value in alleviating urban traffic congestion and improving traffic efficiency.

[0029] Currently, an intuitive approach to calculating vehicle trajectory similarity is to calculate the distance between vehicle trajectories; obviously, the smaller the distance between trajectories, the higher their similarity, and vice versa. There are many methods for calculating the distance between trajectories, such as calculating the maximum distance, minimum distance, average distance, Hausdorff distance, and discrete Fréchet distance, etc. However, subsequent research shows that discrete Fréchet distance is the most suitable for calculating trajectory similarity. Discrete Fréchet distance incorporates the temporal relationship between trajectory points, and the calculation process considers the node structure within the trajectory, allowing for a more accurate assessment of the similarity between trajectories. It also avoids measurement distortion when trajectories exhibit backtracking, loops, or intersections, thus providing a stronger descriptive ability for trajectory similarity.

[0030] However, in existing technologies, when using discrete Fréchet distance to describe trajectory similarity, the discrete Fréchet distance between two trajectories can be calculated using a dynamic programming algorithm. Specifically, this involves first calculating the distance matrix between the two trajectories, i.e., the distance between each node on the two trajectories; then calculating the discrete Fréchet distance from the starting point to that position at each location based on the dynamic transition equation on the distance matrix; and finally obtaining the final discrete Fréchet distance by traversing and transforming the distance matrix. However, this calculation method is not very efficient in practice.

[0031] Before explaining the inefficiency of computation, this application first explains the definition of discrete Fréchet distance.

[0032] In this field, a trajectory can represent a set of coordinate points sampled in time sequence. Taking a trajectory P as an example, P = {P(1), ..., P(m)}; where P(i) = (x... i y i ), x i and y i Let be the longitude and latitude of the i-th sampling point P(i), or the x-coordinate or y-coordinate of the sampling point P(i), respectively, and m be called the length of the trajectory P.

[0033] The discrete Fréchet distance is defined as:

[0034] Given two trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)}, we say that... Let Ω be the discrete Fréchet distance between trajectories P and Q, where Ω is the set of pairs of mapping sequences of trajectories P and Q, and ||P(a i )-Q(b i )|| is for node P(a i ) and Q(b i The distance.

[0035] The distance matrix is ​​defined as follows:

[0036] Given two trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)}, the following matrix D is called the distance matrix between trajectory P and trajectory Q:

[0037]

[0038] Where d i,j =||P(a i )-Q(b j )||, i=1,…,m, j=1,…,n.

[0039] In existing technology, given two trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)}, in order to calculate the discrete Fréchet distance and obtain their similarity, the problem of calculating the discrete Fréchet distance between the two trajectories can be transformed into finding a path from d on the distance matrix of these two trajectories. 1,1 to d m,n A path exists that satisfies the following conditions: a) the direction of movement from the previous position to the next position can only be up, right, or to the upper right corner; b) the maximum element on this path is the smallest among all paths that satisfy condition a). Therefore, dynamic programming can be used to calculate it: Let dp be a 2D dynamic variable array of shape m×n, where the dynamic variable dp[i,j] represents the distance from d to the next position on the distance matrix. 1,1 The path to j that satisfies the discrete Fréchet distance equivalence problem is the discrete Fréchet distance between the trajectories {P(1), ..., P(i)} and {Q(1), ..., Q(j)}. Then the state transition equation is: a) If j = 1, then dp[i, 1] = max(dp[i-1, 1], d i,1 b) If i = 1, then dp[1, j] = max(dp[1, j-1], d 1,j c) If j > 1 and i > 1, then dp[i, j] = max(min(dp[i-1, j], dp[i, j-1], dp[i-1, j-1]), d i,j This transforms the discrete Fréchet distance between trajectories into a dynamic programming problem.

[0040] If the discrete Fréchet distance is calculated using this dynamic programming approach, the computational complexity is O(m·n), which is not efficient enough.

[0041] To address the aforementioned issues and improve the computational efficiency of discrete Fréchet distance, thereby enhancing the computational efficiency of trajectory similarity, this application proposes a trajectory similarity calculation method. Please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the trajectory similarity calculation method provided in this application.

[0042] Step 11: Obtain at least two trajectories, wherein the at least two trajectories include a first trajectory and a second trajectory.

[0043] Specifically, the trajectory similarity calculation device first acquires at least two trajectories. These at least two trajectories include a first trajectory and a second trajectory. In this embodiment, the first trajectory is defined as P = {P(1), ..., P(m)}, and the second trajectory is defined as Q = {Q(1), ..., Q(n)}.

[0044] Step 12: Calculate the distance matrix between the first and second trajectories, where the distance matrix includes the distances between several trajectory points.

[0045] Specifically, the distance between each trajectory point is calculated from the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory;

[0046] After the trajectory similarity calculation device obtains the first trajectory P and the second trajectory Q, it can calculate the trajectory point distance between the coordinates of each first trajectory point and each second trajectory point, thereby obtaining the distance matrix between the first trajectory and the second trajectory.

[0047] The formula for calculating the distance matrix is ​​shown below:

[0048]

[0049] Where, d i,j =||P(a i )-Q(b j )||, i=1,…,m, j=1,…,n.

[0050] Specifically, after obtaining the distance matrix, the trajectory similarity calculation device updates the distance matrix based on a preset threshold θ, setting the distances of trajectory points in the distance matrix whose values ​​are greater than or equal to the preset threshold to a preset distance ∞, thus obtaining a threshold-constrained distance matrix. Using the threshold-constrained distance matrix instead of the standard distance matrix can save a significant amount of computational cost for discrete Fréchet distances.

[0051] Step 13: Traverse the distances of the trajectory points in the distance matrix and obtain the lower bound of the distance for each trajectory point.

[0052] Specifically, the lower bound of the position The definition is: given two trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)}, the lower bound of the position defined by P(i) and Q(j) is... Defined as min{min k∈[1,j ]||P(i)-Q(k)||,min k∈[1,i] ||P(k)-Q(j)||}.

[0053] The lower bound of the distance between trajectory points is the minimum value among the distances between the trajectory point and its horizontally adjacent trajectory points and its vertically adjacent trajectory points. Specifically, the horizontal coordinates of the horizontally adjacent trajectory points are the same as the horizontal coordinates of the distance between the trajectory points, and the vertical coordinates of the horizontally adjacent trajectory points are less than the vertical coordinates of the distance between the trajectory points; the vertical coordinates of the vertically adjacent trajectory points are the same as the vertical coordinates of the distance between the trajectory points, and the horizontal coordinates of the vertically adjacent trajectory points are less than the horizontal coordinates of the distance between the trajectory points.

[0054] See Figure 7 , Figure 7 This is a geometrical diagram illustrating the lower bound of the position (4, 3) in the trajectory similarity method provided in this application. The principle of the lower bound is explained using position (4, 3) as an example. The geometric meaning of is the smallest of all shaded distance values ​​in the figure.

[0055] Since any one from d 1,1 to d 5,5 And its maximum distance is equal to the discrete Fréchet distance d. F The path must pass through some grid (i, j) in the shaded area. Obviously, the inequality relationship is not true. Therefore, if Then there must be d. F >θ. Therefore, the elements at the remaining positions do not need to be judged anymore, and ∞ is directly returned as the discrete Fréchet distance, which means that the difference between the two trajectories is too large. This is the principle of using the lower bound value of the position for pruning.

[0056] Specifically, the trajectory similarity calculation device calculates the lower bound of the distance between all trajectory points in the threshold constraint distance matrix. If the lower bound of the distance between any trajectory point is greater than the preset threshold θ, it will directly output information indicating that the difference between the two trajectories is too large. Using the lower bound of the distance for pruning can avoid invalid calculations and improve the efficiency of trajectory similarity calculation.

[0057] Step 14: Determine whether there exists any trajectory point whose distance to the lower bound is greater than or equal to a preset threshold.

[0058] Specifically, if the trajectory similarity calculation device determines that there is a trajectory point in the threshold constraint distance matrix whose lower bound value is greater than or equal to the preset threshold, then proceed to step 15.

[0059] If the trajectory similarity calculation device determines that there is no lower bound value of the distance between trajectory points in the threshold constraint distance matrix that is greater than or equal to the preset threshold, it will create a two-dimensional dynamic array dp based on the first trajectory P and the second trajectory Q; calculate the element values ​​of the two-dimensional dynamic array according to the path planning conditions based on the threshold constraint distance matrix; and determine the trajectory similarity between the first trajectory and the second trajectory according to the element values ​​of the two-dimensional dynamic array.

[0060] The size of the created two-dimensional dynamic array dp is determined by the lengths of the first trajectory P and the second trajectory Q. Taking the length of the first trajectory P as m and the length of the second trajectory Q as n as an example, the created two-dimensional dynamic array dp is a two-dimensional array with m rows and n columns. During the creation process, each element value dp[i, j] in the two-dimensional dynamic array dp is initialized to -1, where dp[i, j] represents the discrete Fréchet distance between trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)}.

[0061] If m = 5 and n = 6, the initialized two-dimensional dynamic array dp is as follows:

[0062]

[0063] Specifically, after creating the initial two-dimensional dynamic array dp, the trajectory similarity calculation device will set the value of the element corresponding to any trajectory point in the threshold constraint distance matrix that is at a preset distance ∞ to the value of the preset distance ∞.

[0064] Specifically, the trajectory similarity calculation device will also determine the adjacent elements of the current element in the two-dimensional dynamic array according to the path planning conditions, wherein the path planning conditions are: the coordinate value of the current element is greater than the coordinate value of the adjacent element; wherein the coordinate value includes the first coordinate value and / or the second coordinate value.

[0065] That is, the first coordinate value (first subscript) and / or the second coordinate value (second subscript) of the adjacent element must be smaller than the current element.

[0066] For example, if the current element in the two-dimensional dynamic array dp is dp[2,1], then the adjacent elements of the current element dp[2,1] are dp[1,1]. If the current element is dp[1,2], then the adjacent elements of the current element dp[1,2] are also dp[1,1]. If the current element is dp[2,3], then the adjacent elements of dp[2,3] are dp[1,3], dp[2,2], and dp[1,2].

[0067] After confirming the neighboring elements of each current element in the two-dimensional dynamic array dp, the element values ​​of the two-dimensional dynamic array dp are calculated based on the distance matrix d and the neighboring elements.

[0068] The two-dimensional dynamic array dp[1,1] represents the distance matrix with the corresponding index d. 1,1 The calculation of other current elements in the two-dimensional dynamic array dp involves obtaining the element values ​​of the adjacent elements of the current element, determining the minimum element value of the adjacent elements, and taking the maximum value between the minimum element value of the adjacent elements and the distance of the current trajectory point as the element value of the current element in the two-dimensional dynamic array dp.

[0069] Optionally, before determining the adjacent elements of the current element in the two-dimensional dynamic array, the trajectory similarity calculation device will also locate the starting distance of the distance matrix and the starting element of the two-dimensional dynamic array according to the starting point of the first trajectory and the starting point of the second trajectory; and determine the value of the starting distance as the element value of the starting element.

[0070] When determining the starting element of the two-dimensional dynamic array, the trajectory similarity calculation device needs to locate the starting distance d of the distance matrix D based on the starting point P(1) of the first trajectory and the starting point Q(1) of the second trajectory. 1,1 , the starting point distance d 1,1 The value of the starting element is determined as dp[1, 1]. That is, the value of the two-dimensional dynamic array dp[1, 1] = d 1,1 .

[0071] In a specific application scenario of calculating dp using a two-dimensional dynamic array, the calculation method is as follows:

[0072] 1. Input two trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)};

[0073] II. Calculate the distance matrix D between trajectories P and Q. θ =[d i,j ] m×n ;

[0074] 3. Create a two-dimensional dynamic array dp with m rows and n columns, and initialize all elements dp[i,j] to -1;

[0075] IV. Let dp[1, 1] = d 1,1 ; Let dp[I,1]=max(dp[i-1,1],d i,1 ), 2≤i≤m; let dp[1,j]=max(dp[1,j-1],d 1,j ), 2≤j≤n; let dp[i,j]=max(min(dp[i-1,j],Dp[i,j-1],dp[i-1,j-1]), d i,j ), 2≤i≤m, 2≤j≤n.

[0076] After the trajectory similarity calculation device updates the two-dimensional dynamic array dp, the endpoint element dp[m, n] of the two-dimensional dynamic array can be located according to the endpoint of the first trajectory P and the endpoint of the second trajectory Q. The trajectory similarity of the first trajectory P and the second trajectory Q, i.e., the discrete Fréchet distance between the first trajectory P and the second trajectory Q, can be determined using the element value of the endpoint element of the two-dimensional dynamic array.

[0077] In one application scenario, please refer to Figure 3 , Figure 3 This is a schematic diagram of an embodiment of the first and second trajectories provided in this application. The first trajectory P = {P(1), ..., P(4)} and the second trajectory Q = {Q(1), ..., Q(5)} are obtained, where, as... Figure 3 As shown, P(1) = (0, 3), P(2) = (1, 4), P(3) = (3, 2), P(4) = (4, 2), P(5) = (5, 3), Q(1) = (0, 2), Q(2) = (1, 1), Q(3) = (2, 2), Q(4) = (3, 1.5),

[0078] Q(5)=(4,0), Q(6)=(5,1);

[0079] Meanwhile, let the distance threshold θ = 3.0.

[0080] Based on the first trajectory P and the second trajectory Q described above, the distance matrix D between them is calculated, and the threshold-constrained distance matrix D is obtained through the distance threshold θ. θ As shown below:

[0081]

[0082] At this point, a new 5×6 two-dimensional dynamic array dp is created based on the length of the first trajectory P and the length of the second trajectory Q, and its elements dp[i, j] are all initialized to -1, as shown below:

[0083]

[0084] Set dp[1,1] as the starting distance d in the distance matrix.1,1 The value is then updated in the two-dimensional dynamic array as follows:

[0085]

[0086] According to the formula dp[i, 1] = max(dp[i-1, 1], d i,1 If 2≤i≤m, update the element value of the first column of the dynamic array dp, then the two-dimensional dynamic array dp is updated as follows:

[0087]

[0088] According to the formula dp[1,j]=max(dp[1,j],d i,1 If 2≤j≤n, update the element value of the first column of the two-dimensional dynamic array dp, then the dynamic array dp is updated as follows:

[0089]

[0090] According to the formula dp[i,j]=max(min(dp[i-1,j],Dp[i,j-1],dp[i-1,j-1]),d i,j For any given condition 2≤i≤m, 2≤j≤n, update the other elements of the two-dimensional dynamic array dp. The updated two-dimensional dynamic array dp is then:

[0091]

[0092] Finally, the endpoint element dp[5,6] = 2.236 of the two-dimensional dynamic array dp is located. The endpoint element dp[5,6] = 2.236 is the discrete Fréchet distance between the first trajectory P and the second trajectory Q.

[0093] In the example above, the threshold-constrained distance matrix D θ Of the 30 elements, 12 were directly assigned the value of infinity (∞), therefore the threshold constraint distance matrix D... θ The introduction of [the technology] saved more than [amount]. The distance calculation cost is reduced, and the computational efficiency for calculating the magnitude of trajectory similarity is improved.

[0094] Step 15: Set the trajectory similarity between the first trajectory and the second trajectory to a preset distance.

[0095] Please continue reading. Figure 2 If the trajectory similarity calculation device determines in step 14 that there is a trajectory point distance with a lower bound value greater than or equal to a preset threshold, it will directly set the trajectory similarity to the preset distance, that is, it is considered that the difference between the first trajectory and the second trajectory is too large.

[0096] Specifically, if the preset threshold is 3 and the lower bound of the distance between a certain trajectory point and the location is greater than 3, the trajectory similarity between the two trajectories used for trajectory similarity calculation will be set to ∞ directly, thus avoiding subsequent invalid calculations.

[0097] Unlike existing technologies, the trajectory similarity calculation method provided in this application is applied to a trajectory similarity calculation device. The trajectory similarity calculation device acquires at least two trajectories, including a first trajectory and a second trajectory. It calculates a distance matrix between the trajectories based on the first and second trajectories, wherein the distance matrix includes distances between several trajectory points. Each trajectory point distance is calculated from the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory. It iterates through the trajectory point distances in the distance matrix to obtain the lower bound value of the position of each trajectory point distance. The lower bound value of the position of the trajectory point distance is the minimum value among the distances of the trajectory point distance to its horizontally adjacent trajectory points and its vertically adjacent trajectory points. It determines whether there exists any trajectory point distance whose lower bound value is greater than or equal to a preset threshold. If so, the trajectory similarity between the first and second trajectories is set to a preset distance. Specifically, the horizontal coordinates of horizontally adjacent trajectory points are the same as the horizontal coordinates of the trajectory point distance, and the vertical coordinates of horizontally adjacent trajectory points are less than the vertical coordinates of the trajectory point distance; the vertical coordinates of vertically adjacent trajectory points are the same as the vertical coordinates of the trajectory point distance, and the horizontal coordinates of vertically adjacent trajectory points are less than the horizontal coordinates of the trajectory point distance. Compared to conventional trajectory similarity calculation methods, this application employs a distance threshold constraint when calculating the distance matrix of two trajectories. This threshold is used to determine the lower bound of the distance between two trajectory points, directly excluding trajectories with a lower bound greater than or equal to the preset threshold. This effectively reduces invalid calculations and significantly improves computational efficiency. This trajectory similarity calculation method saves on trajectory distance calculation costs through threshold constraints, and the determination of the lower bound reduces computational complexity and avoids invalid calculations.

[0098] The method described in the above embodiments can be implemented using a trajectory similarity calculation device, as described below. Figure 4 Describe it. Figure 4 This is a schematic diagram of the structure of the first embodiment of the trajectory similarity calculation device provided in this application.

[0099] like Figure 4 As shown, the trajectory similarity calculation device 40 of this application embodiment includes an acquisition module 41, a matrix generation module 42, a calculation module 43, a judgment module 44, and a setting module 45.

[0100] Among them, the acquisition module 41 is used to acquire at least two trajectories.

[0101] The matrix generation module 42 is used to calculate the distance matrix between the trajectories based on the first trajectory and the second trajectory.

[0102] The calculation module 43 is used to traverse the distances of trajectory points in the distance matrix and obtain the lower bound value of the distance of each trajectory point.

[0103] The judgment module 44 is used to determine whether there is a lower bound value of the distance between any trajectory point and the position greater than or equal to a preset threshold.

[0104] Setting module 45 is used to set the trajectory similarity of the first trajectory and the second trajectory to a preset distance when the lower bound of the distance between any trajectory point is greater than or equal to a preset threshold.

[0105] The method described in the above embodiments can be implemented using a trajectory similarity calculation device, as described below. Figure 5 , Figure 5 This is a schematic diagram of the structure of the second embodiment of the trajectory similarity calculation device provided in this application. The trajectory similarity calculation device 50 includes a memory 51 and a processor 52. The memory 51 is used to store program data, and the processor 52 is used to execute the program data to implement the following method:

[0106] At least two trajectories are obtained, including a first trajectory and a second trajectory. A distance matrix between the trajectories is calculated based on the first and second trajectories, wherein the distance matrix includes several trajectory point distances, and each trajectory point distance is calculated by the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory. The trajectory point distances in the distance matrix are traversed, and the lower bound value of the position of each trajectory point distance is obtained, wherein the lower bound value of the position of the trajectory point distance is the minimum value among the distance of the trajectory point distance and the distance of the horizontally adjacent trajectory point and the vertically adjacent trajectory point. It is determined whether there is any trajectory point distance with a lower bound value greater than or equal to a preset threshold. If so, the trajectory similarity between the first and second trajectories is set to a preset distance. Wherein, the horizontal coordinates of the horizontally adjacent trajectory points are the same as the horizontal coordinates of the trajectory point distance, and the vertical coordinates of the horizontally adjacent trajectory points are less than the vertical coordinates of the trajectory point distance; the vertical coordinates of the vertically adjacent trajectory points are the same as the vertical coordinates of the trajectory point distance, and the horizontal coordinates of the vertically adjacent trajectory points are less than the horizontal coordinates of the trajectory point distance.

[0107] See Figure 6 , Figure 6 This is a schematic diagram of an embodiment of the computer-readable storage medium 60 provided in this application. The computer-readable storage medium 60 stores program data 61, which, when executed by a processor, is used to implement the following method:

[0108] At least two trajectories are obtained, including a first trajectory and a second trajectory. A distance matrix between the trajectories is calculated based on the first and second trajectories, wherein the distance matrix includes several trajectory point distances, and each trajectory point distance is calculated by the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory. The trajectory point distances in the distance matrix are traversed, and the lower bound value of the position of each trajectory point distance is obtained, wherein the lower bound value of the position of the trajectory point distance is the minimum value among the distance of the trajectory point distance and the distance of the horizontally adjacent trajectory point and the vertically adjacent trajectory point. It is determined whether there is any trajectory point distance with a lower bound value greater than or equal to a preset threshold. If so, the trajectory similarity between the first and second trajectories is set to a preset distance. Wherein, the horizontal coordinates of the horizontally adjacent trajectory points are the same as the horizontal coordinates of the trajectory point distance, and the vertical coordinates of the horizontally adjacent trajectory points are less than the vertical coordinates of the trajectory point distance; the vertical coordinates of the vertically adjacent trajectory points are the same as the vertical coordinates of the trajectory point distance, and the horizontal coordinates of the vertically adjacent trajectory points are less than the horizontal coordinates of the trajectory point distance.

[0109] When the embodiments of this application are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0110] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for calculating trajectory similarity, characterized in that, The trajectory similarity calculation method includes: Obtain at least two trajectories, wherein the at least two trajectories include a first trajectory and a second trajectory; A distance matrix between the trajectories is calculated based on the first trajectory and the second trajectory, wherein the distance matrix includes a plurality of trajectory point distances, and each trajectory point distance is calculated by the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory; Traverse the distances of trajectory points in the distance matrix and obtain the lower bound of the distance of each trajectory point. The lower bound of the distance of each trajectory point is the minimum value among the distance of the trajectory point and the distance of its horizontally adjacent trajectory point and the distance of its vertically adjacent trajectory point. Determine whether there exists a trajectory point whose distance to the lower bound is greater than or equal to a preset threshold. If so, the trajectory similarity between the first trajectory and the second trajectory is set to a preset distance, where the trajectory similarity is the preset distance indicating that the difference between the first trajectory and the second trajectory is too large; Wherein, the horizontal coordinate of the horizontally adjacent trajectory point is the same as the horizontal coordinate of the distance to the trajectory point, and the vertical coordinate of the horizontally adjacent trajectory point is less than the vertical coordinate of the distance to the trajectory point; the vertical coordinate of the vertically adjacent trajectory point is the same as the vertical coordinate of the distance to the trajectory point, and the horizontal coordinate of the vertically adjacent trajectory point is less than the horizontal coordinate of the distance to the trajectory point.

2. The trajectory similarity calculation method according to claim 1, characterized in that, After calculating the distance matrix between the trajectories based on the first trajectory and the second trajectory, the trajectory similarity calculation method includes: The distance matrix is ​​updated based on the preset threshold, and the distances of trajectory points in the distance matrix whose values ​​are greater than or equal to the preset threshold are set as preset distances to obtain a threshold-constrained distance matrix.

3. The trajectory similarity calculation method according to claim 2, characterized in that, The trajectory similarity calculation method also includes: If the lower bound of the distance between the non-trajectory points is greater than or equal to the preset threshold, a two-dimensional dynamic array is created based on the first trajectory and the second trajectory; Based on the threshold constraint distance matrix and according to the path planning conditions, calculate the element values ​​of the two-dimensional dynamic array; Based on the element values ​​of the two-dimensional dynamic array, determine the trajectory similarity between the first trajectory and the second trajectory; The step of calculating the element values ​​of the two-dimensional dynamic array based on the distance matrix and path planning conditions includes: determining the neighboring elements of the current element in the two-dimensional dynamic array according to the path planning conditions; obtaining the element value of the current element based on the distance matrix and the neighboring elements of the current element, wherein the path planning condition is that the coordinate value of the current element is greater than the coordinate value of the neighboring elements; wherein the coordinate value includes a first coordinate value and / or a second coordinate value; Determining the trajectory similarity between the first trajectory and the second trajectory based on the element values ​​of the two-dimensional dynamic array includes: locating the endpoint element of the two-dimensional dynamic array based on the endpoint of the first trajectory and the endpoint of the second trajectory; and determining the trajectory similarity between the first trajectory and the second trajectory using the element values ​​of the endpoint element of the two-dimensional dynamic array.

4. The trajectory similarity calculation method according to claim 3, characterized in that, The step of calculating the element values ​​of the two-dimensional dynamic array based on the threshold constraint distance matrix according to the path planning conditions further includes: In response to the threshold constraint distance matrix having a preset distance, the value of the element corresponding to the distance of the arbitrary point in the two-dimensional dynamic array is set to the value of the preset distance.

5. The trajectory similarity calculation method according to claim 3, characterized in that, The step of obtaining the element value of the current element based on the distance matrix and the neighboring elements of the current element includes: Based on the distance matrix, obtain the distance to the current trajectory point corresponding to the current element; Get the element values ​​of the adjacent elements of the current element, and determine the minimum element value of the adjacent elements of the current element; The maximum value between the minimum element value and the distance to the current trajectory point is taken as the element value of the current element.

6. The trajectory similarity calculation method according to claim 5, characterized in that, Before determining the adjacent elements of the current element in the two-dimensional dynamic array based on the path planning conditions, the trajectory similarity calculation method further includes: Based on the starting point of the first trajectory and the starting point of the second trajectory, locate the starting distance of the distance matrix and the starting element of the two-dimensional dynamic array; The value of the starting point distance is determined as the element value of the starting point element.

7. A trajectory similarity calculation device, characterized in that, The trajectory similarity calculation device includes a memory and a processor coupled to the memory; The memory is used to store program data, and the processor is used to execute the program data to implement the trajectory similarity calculation method as described in any one of claims 1 to 6.

8. A computer storage medium, characterized in that, The computer storage medium is used to store program data, which, when executed by the computer, is used to implement the trajectory similarity calculation method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Inquiring method of best matching with fuzzy trajectory problems

    CN102567497A

  • Peer vehicle analysis method and device and storage device

    CN110766088A