Trajectory similarity calculation method and device and computer readable storage medium

By using a two-dimensional dynamic array and dynamic programming in trajectory similarity calculation, the problem of low efficiency in discrete Fréchet distance calculation is solved, and efficient trajectory similarity calculation is achieved.

CN115994309BActive Publication Date: 2026-03-20ZHEJIANG 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
Filing Date
2022-10-25
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

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

Method used

By creating a two-dimensional dynamic array and using the idea of ​​dynamic programming, the trajectory similarity is calculated based on the path planning conditions. The element values ​​of the two-dimensional dynamic array are directly obtained to determine the trajectory similarity.

Benefits of technology

This improves the efficiency of trajectory similarity calculation, reduces computational complexity, and ensures the accuracy of the calculation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115994309B_ABST
    Figure CN115994309B_ABST
Patent Text Reader

Abstract

The application discloses a trajectory similarity calculation method, a trajectory similarity calculation device and a computer readable storage medium. The trajectory similarity calculation method comprises the following steps: obtaining at least two trajectories, wherein the at least two trajectories comprise 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 comprises a plurality of trajectory point distances; creating a two-dimensional dynamic array based on the first trajectory and the second trajectory; calculating element values of the two-dimensional dynamic array based on the distance matrix and according to path planning conditions; and determining a trajectory similarity of the first trajectory and the second trajectory according to the element values of the two-dimensional dynamic array. The application creates a two-dimensional dynamic array based on the first trajectory and the second trajectory, calculates the element values of the two-dimensional dynamic array by means of a dynamic programming idea, and determines the trajectory similarity of the two trajectories, thereby improving the calculation efficiency of the trajectory similarity.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of trajectory similarity calculation, in particular to a trajectory similarity calculation method, a trajectory similarity calculation device and a computer readable storage medium. BACKGROUND

[0002] With the continuous development of society, the technology of obtaining the travel mode of the city by analyzing the travel trajectory of the vehicle is also more and more perfect. In this analysis process, the similarity measurement of the travel trajectory of the vehicle is one of the most core problems.

[0003] In the process of solving the problem of measuring the similarity of vehicle trajectory, an intuitive solution is to calculate the distance between vehicle trajectories. Obviously, the smaller the distance between trajectories, the higher the similarity of the two, and vice versa. The current method for calculating the distance between trajectories includes maximum distance, minimum distance, average distance, Hausdorff distance, etc. Research shows that the discrete Fréchet distance contains the time sequence relationship between trajectory points, and the calculation process considers the node structure inside the trajectory, which can more accurately consider the similarity between trajectories. When the trajectory appears back, ring and interlacing, it will not appear measurement distortion, so the description ability of the discrete Fréchet distance is stronger, and it is most suitable for measuring the similarity between trajectories. However, the current technology generally iteratively calculates the definition of the discrete Fréchet distance, which has very low calculation efficiency. SUMMARY

[0004] The present application provides a trajectory similarity calculation method, a trajectory similarity calculation device and a computer readable storage medium to solve the problem of low calculation efficiency of the current discrete Fréchet distance, so as to improve the calculation efficiency of the trajectory similarity.

[0005] To solve the above technical problems, one technical solution adopted by the present application is to provide a trajectory similarity calculation method, which comprises:

[0006] The trajectory similarity calculation method comprises: obtaining at least two trajectories, wherein the at least two trajectories comprise a first trajectory and a second trajectory; calculating the distance matrix between the trajectories based on the first trajectory and the second trajectory, wherein the distance matrix comprises a plurality of trajectory point distances, each trajectory point distance being 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; creating a two-dimensional dynamic array based on the first trajectory and the second trajectory; calculating the element values of the two-dimensional dynamic array based on the distance matrix according to the path planning conditions; and determining the trajectory similarity of the first trajectory and the second trajectory according to the element values of the two-dimensional dynamic array.

[0007] The element value of the two-dimensional dynamic array is calculated based on the distance matrix according to the path planning condition, including:

[0008] According to the path planning condition, the adjacent element of the current element in the two-dimensional dynamic array is determined; and the element value of the current element is obtained based on the distance matrix and the adjacent element of the current element.

[0009] The element value of the current element is obtained based on the distance matrix and the adjacent element of the current element, including:

[0010] The current trajectory point distance corresponding to the current element is obtained based on the distance matrix; the element value of the adjacent element of the current element is obtained, and the minimum element value of the adjacent element of the current element is determined; and the maximum value of the minimum element value and the current trajectory point distance is taken as the element value of the current element.

[0011] The path planning condition is that the coordinate value of the current element is greater than the coordinate value of the adjacent element; and the coordinate value includes the first coordinate value and / or the second coordinate value.

[0012] The trajectory similarity of the first trajectory and the second trajectory is determined according to the element value of the two-dimensional dynamic array, including:

[0013] The end element of the two-dimensional dynamic array is located according to the end point of the first trajectory and the end point of the second trajectory; and the trajectory similarity of the first trajectory and the second trajectory is determined by using the element value of the end element of the two-dimensional dynamic array.

[0014] Before the adjacent element of the current element in the two-dimensional dynamic array is determined according to the path planning condition, the trajectory similarity calculation method further includes:

[0015] The start point distance of the distance matrix and the start element of the two-dimensional dynamic array are located according to the start point of the first trajectory and the start point of the second trajectory; and the numerical value of the start point distance is determined as the element value of the start element.

[0016] The two-dimensional dynamic array is created based on the first trajectory and the second trajectory, including:

[0017] The first length of the first trajectory and the second length of the second trajectory are obtained; and the number of rows and the number of columns of the two-dimensional dynamic array are determined based on the first length and the second length.

[0018] To solve the above technical problems, one technical scheme adopted by the present application is to provide a trajectory similarity calculation device, which comprises a trajectory acquisition module, a distance calculation module, an array updating module and a similarity determination module.

[0019] The trajectory obtaining module is configured to obtain at least two trajectories, wherein the at least two trajectories include a first trajectory and a second trajectory; the distance calculating module is configured to calculate 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 based on the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory; the array updating module is configured to create a two-dimensional dynamic array based on the first trajectory and the second trajectory, and calculate the element values of the two-dimensional dynamic array based on the distance matrix and according to a path planning condition; and the similarity determining module is configured to determine the trajectory similarity of the first trajectory and the second trajectory according to the element values of the two-dimensional dynamic array.

[0020] To solve the above technical problems, one technical solution of the present application is to provide a trajectory similarity calculation device, which comprises a processor and a memory coupled with the processor, the memory storing program data, and the processor executing the program data stored in the memory to implement the trajectory similarity calculation method described above.

[0021] To solve the above technical problems, another technical solution of the present application is to provide a computer readable storage medium, which internally stores program instructions, and the program instructions are executed to implement the trajectory similarity calculation method described above.

[0022] The beneficial effects of the present application are as follows: Unlike the prior art, the present application obtains the first trajectory and the second trajectory, calculates the distances between all trajectory points, obtains the distance matrix, creates a two-dimensional dynamic array based on the two trajectories, calculates the element values of the two-dimensional dynamic array based on the dynamic programming idea and the distance matrix according to the path planning condition, finally obtains all element values of the two-dimensional dynamic array, and determines the trajectory similarity of the two trajectories based on all element values of the two-dimensional dynamic array. Compared with the traditional iterative algorithm, the present application only needs to calculate all element values of the two-dimensional dynamic array to obtain the trajectory similarity of the two trajectories. The present application greatly improves the calculation efficiency under the premise of ensuring the accuracy of the trajectory similarity, and the calculation complexity is also reduced compared with the iterative algorithm. BRIEF DESCRIPTION OF DRAWINGS

[0023] Figure 1 is a flowchart of an embodiment of the trajectory similarity calculation method provided by the present application;

[0024] Figure 2 is Figure 1 is a flowchart of the first embodiment of step S103 in

[0025] Figure 3 is Figure 1 is a flowchart of the second embodiment of step S103 in

[0026] Figure 4 is Figure 2 A specific flowchart of step S202 in

[0027] Figure 5 is Figure 1 A specific flowchart of step S105 in

[0028] Figure 6 is Figure 1 A specific flowchart of step S104 in

[0029] Figure 7 is a schematic diagram of an embodiment of the first trajectory and the second trajectory provided by the present application;

[0030] Figure 8 is a structural schematic diagram of a first embodiment of the trajectory similarity calculation device provided by the present application;

[0031] Figure 9 is a structural schematic diagram of a second embodiment of the trajectory similarity calculation device provided by the present application;

[0032] Figure 10 is a structural schematic diagram of an embodiment of the computer readable storage medium provided by the present application. DETAILED DESCRIPTION

[0033] The technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0034] With the continuous development of society, especially in urban areas, more and more roads and intersections are installed with various types of vehicle snapshot devices. Snapshot devices play a huge role in controlling and investigating vehicle speed snapshot, mobile phone snapshot, and red light running and other traffic violations. At the same time, these snapshot devices can effectively record the travel trajectories of various vehicles traveling on urban roads. As the space-time information data of vehicles, vehicle travel trajectories contain rich and valuable travel patterns of various vehicles. How to use data mining technology to mine vehicle travel trajectories has become a hot issue of concern in the academic and industrial communities.

[0035] In the process of using data mining technology to mine vehicle travel trajectories, the similarity calculation of the travel trajectories of vehicles is one of the most core problems. Through the similarity calculation between trajectories, the travel patterns of a city can be mined, which has immeasurable value for relieving urban traffic congestion and improving traffic efficiency.

[0036] Currently, for the calculation of the similarity of vehicle trajectories, one intuitive solution is to calculate the distance between the vehicle trajectories; obviously, the smaller the distance between the trajectories, the higher the similarity, and vice versa. There are many methods for calculating the distance between trajectories, such as calculating the maximum distance, the minimum distance, the average distance, the Hausdorff distance, and the discrete Fréchet distance, etc. However, subsequent studies show that the discrete Fréchet distance is the most suitable for calculating the similarity of trajectories. The discrete Fréchet distance contains the time sequence relationship between the nodes of the trajectories, and the calculation process considers the internal node structure of the trajectories, which can more accurately consider the similarity between the trajectories, and will not cause measurement distortion when the trajectories appear to be back, loop, and stagger, etc. Therefore, the discrete Fréchet distance has stronger description ability for the similarity of trajectories.

[0037] However, in the prior art, when the discrete Fréchet distance is used to describe the similarity of trajectories, it is still calculated repeatedly by using the definition of the discrete Fréchet distance, which has high calculation complexity and low calculation efficiency.

[0038] Before explaining the low calculation efficiency, the definition of the discrete Fréchet distance will be explained first.

[0039] In the field, a trajectory can represent a set of coordinate points sampled in time sequence. For example, a trajectory P is {P(1), …, P(m)}; where P(i) = (x i ,y i ), x i and y i are the longitude and latitude of the i-th sampling point P(i) or the horizontal coordinate or vertical coordinate of the sampling point P(i), and m is the length of the trajectory P.

[0040] Before explaining the discrete Fréchet distance, the definition of the mapping sequence L needs to be understood. In the field, the definition of the mapping sequence L is as follows:

[0041] Given two trajectories P = {P(1), …, P(m)} and Q = {Q(1), …, Q(n)}, which satisfy the following conditions:

[0042] a1 = 1, b1 = 1, a l = m, b l = n, a i+1 = a i or a i+1 = a i +1, b i+1 = b i or b i+1 = b i +1, i = 1, …, l-1;

[0043] Then L = {<P(a1),Q(b1)>},…, <P(a l ),Q(b l )> is a mapping sequence of trajectories P and Q.

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

[0045] 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 node P(a i ) and Q(b i The distance.

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

[0047] 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:

[0048]

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

[0050] In existing technologies, given two trajectories P = {P(1), ..., P(m)} and Q = {Q(1), ..., Q(n)}, in order to obtain their similarity by calculating the discrete Fréchet distance, it is generally necessary to traverse all pair mapping sequences L between trajectory P and trajectory Q according to the definition of discrete Fréchet distance; then for each selected pair mapping sequence L = {<P(a1),Q(b1)>},…, <P(a l ),Q(b l Find the maximum distance d between the largest pairs of nodes. L =max 0≤i≤l ||P(a i )-Q(b i )‖, then from all d L The smallest value is selected as the discrete Fréchet distance between trajectories P and Q.

[0051] If the discrete Fréchet distance is directly calculated according to the definition of the discrete Fréchet distance, the number of the mapping sequence L is obviously exponential O(n m ) order, and the calculation complexity is high, and the calculation efficiency is extremely low.

[0052] In order to solve the above problems, improve the calculation efficiency of the discrete Fréchet distance, and improve the calculation efficiency of the trajectory similarity, the present application first proposes a trajectory similarity calculation method, please refer to Figure 1 , Figure 1 is the flowchart of the trajectory similarity calculation method provided by the present application. As shown in Figure 1 , the trajectory similarity calculation method of the present embodiment specifically includes steps S101 to S105:

[0053] Step S101: obtaining at least two trajectories, wherein the at least two trajectories include a first trajectory and a second trajectory.

[0054] The trajectory similarity calculation device first obtains at least two trajectories. Wherein, the at least two trajectories include a first trajectory and a second trajectory. In the present embodiment, the first trajectory is defined as P={P(1),…,P(m)}, and the second trajectory is defined as Q={Q(1),…,Q(n)}.

[0055] Step S102: calculating the 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 from the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory.

[0056] After the trajectory similarity calculation device obtains the first trajectory P and the second trajectory Q, the trajectory point distance between the coordinates of each first trajectory point and each second trajectory point can be calculated, so as to obtain the distance matrix between the first trajectory and the second trajectory.

[0057] The distance matrix and the calculation formula are as follows:

[0058]

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

[0060] Step S103: creating a two-dimensional dynamic array based on the first trajectory and the second trajectory.

[0061] In the prior art above, if the discrete Fréchet distance is directly calculated according to the definition of the discrete Fréchet distance, the order of magnitude of the mapping sequence L is obviously exponential O(n m ) and the calculation efficiency is extremely low.

[0062] In order to improve the calculation efficiency of the discrete Fréchet distance, in the embodiments of the present application, the calculation problem of the discrete Fréchet distance between the first trajectory P and the second trajectory Q is transformed into finding a path from d 1,1 to d m,n on the distance matrix D of the first trajectory P and the second trajectory Q. Wherein the path must satisfy the following conditions:

[0063] 1. The moving direction of the path from the previous position to the next position can only be one of the three directions of down, right or right-down corner.

[0064] 2. The maximum element on the path is the smallest in all paths satisfying condition 1.

[0065] The above problem of finding a path satisfying conditions 1 and 2 is calculated by using the dynamic programming idea in the present application.

[0066] Wherein, the principle of the above problem transformation is as follows:

[0067] The actual meaning of the mapping sequence L = {<P(a1), Q(b1)>},…, <P(a l ), Q(b l )>: a) According to the requirements a1 = 1, b1 = 1, a l = m, b l = n of the definition of the mapping sequence, it can be seen that the head and tail node pairs of any mapping sequence L respectively correspond to the head and tail nodes P(1), Q(1) and P(m), Q(n) of the trajectories P and Q, which indicates that any mapping sequence L corresponds to a path from the left upper corner to the right lower corner of the distance matrix D; b) According to the requirements a i+1 = a i or a i+1 = a i +1, b i+1 = b i or b i+1 = b i +1 of the definition of the mapping sequence L, the path can have at most 3 choices of direction at each time: right, down or right-down diagonal.

[0068]

[0069] Based on the above principle, the present application can solve the discrete Fréchet distance of the trajectory P and the trajectory Q by using the dynamic programming idea. After calculating and obtaining the distance matrix of the first trajectory and the second trajectory, a two-dimensional dynamic array Dp can be created based on the first trajectory and the second trajectory, wherein the size of the two-dimensional dynamic array is determined by the length of the first trajectory P and the second trajectory Q. Taking the first trajectory P and the second trajectory Q in the above as an example, the length of the first trajectory P is m, and the length of the second trajectory Q is n. Then, 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, wherein Dp[i,j] represents the discrete Fréchet distance of the trajectory {P(1), …, P(i)} and the trajectory {Q(1), …, Q(j)}.

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

[0071]

[0072] Step S104: Based on the distance matrix, the element value of the two-dimensional dynamic array is calculated according to the path planning condition.

[0073] After the trajectory similarity calculation device creates the initial two-dimensional dynamic array Dp, the adjacent elements of the current element of the two-dimensional dynamic array Dp are obtained based on the path planning condition, wherein the path planning condition is that 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.

[0074] That is, the first coordinate value (first subscript) and / or the second coordinate value (second subscript) of the adjacent element is less than the current element.

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

[0076] After confirming the adjacent elements of each current element of the two-dimensional dynamic array Dp, the element value of the two-dimensional dynamic array Dp is calculated based on the distance matrix D and the adjacent elements.

[0077] The two-dimensional dynamic array Dp[1,1] is the d 1,1The other current element of the two-dimensional dynamic array Dp is calculated by obtaining the element value of the adjacent element of the current element, and determining the minimum element value of the adjacent element of the current element, and the maximum value in the current trajectory point distance is taken as the element value of the current element of the two-dimensional dynamic array Dp.

[0078] Step S105: According to the element value of the two-dimensional dynamic array, the trajectory similarity of the first trajectory and the second trajectory is determined.

[0079] After calculating the element value of all two-dimensional dynamic arrays Dp, the element value Dp[m,n] of the two-dimensional dynamic array Dp is obtained, and the element value Dp[m,n] is determined as the trajectory similarity of the first trajectory and the second trajectory, wherein m is the length of the first trajectory P, and n is the length of the second trajectory Q.

[0080] Unlike the prior art, the present application obtains the first trajectory P and the second trajectory Q and calculates the distance between all trajectory points, thereby obtaining the distance matrix D, and creates a two-dimensional dynamic array Dp based on the two trajectories, and calculates the element value of the two-dimensional dynamic array Dp based on the dynamic programming idea and the distance matrix according to the path planning condition, finally obtains all element values of the two-dimensional dynamic array Dp, and based on all element values of the two-dimensional dynamic array Dp, the trajectory similarity of the two trajectories can be determined. Compared with the traditional iterative algorithm, the present application only needs to calculate all element values of the two-dimensional dynamic array Dp to obtain the trajectory similarity of the two trajectories, and the calculation efficiency is greatly improved under the premise of ensuring the accuracy of the trajectory similarity, and the calculation complexity is also reduced compared with the iterative algorithm.

[0081] Optionally, the method for calculating the element value of the two-dimensional dynamic array Dp is as shown in Figure 2 , please refer to Figure 2 , Figure 2 is Figure 1 the flowchart of the first embodiment of step S103. This embodiment can realize step S103 by the method as shown in Figure 2 , the specific implementation steps include steps S201 to S202:

[0082] Step S201: According to the path planning condition, the adjacent elements of the current element in the two-dimensional dynamic array are determined.

[0083] The trajectory similarity calculation device calculates the element value of the two-dimensional dynamic array Dp, first determines the adjacent elements of the current element based on the path planning condition in the above.

[0084] Step S202: Based on the distance matrix and the adjacent elements of the current element, the element value of the current element is obtained.

[0085] The trajectory similarity calculation device determines the adjacent element of the current element, and then obtains the current trajectory point distance corresponding to the current element in the distance matrix D, and obtains the element value of the current element based on the adjacent element and the current trajectory point distance.

[0086] Optionally, the method for calculating the element value of the two-dimensional dynamic array Dp is as shown in Figure 3 Please refer to Figure 3 , Figure 3 is Figure 1 a flowchart of a second embodiment of step S103 in Figure 3 The embodiment can implement step S103 by the method as shown in

[0087] Step S301: According to the starting point of the first trajectory and the starting point of the second trajectory, the starting point distance of the distance matrix is located, and the starting point element of the two-dimensional dynamic array is located; the value of the starting point distance is determined as the element value of the starting point element.

[0088] When determining the starting point element of the two-dimensional dynamic array, the trajectory similarity calculation device needs to locate the starting point distance d 1,1 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 value of the starting point distance d 1,1 is determined as the element value Dp[1,1] of the starting point element. That is, Dp[1,1] of the two-dimensional dynamic array = 1,1 .

[0089] Step S302: Determine the adjacent element of the current element in the two-dimensional dynamic array according to the path planning condition.

[0090] Step S302 is consistent with step S201, and will not be repeated here.

[0091] Step S303: Obtain the element value of the current element based on the distance matrix and the adjacent element of the current element.

[0092] Step S303 is consistent with step S202, and will not be repeated here.

[0093] Optionally, the method for obtaining the element value of the current element is as shown in Figure 4 Please refer to Figure 4 , Figure 4 is Figure 2 a specific flowchart of step S202 in Figure 3 The embodiment can implement step S202 by the method as shown in

[0094] Step S401: Obtain the current trajectory point distance corresponding to the current element based on the distance matrix.

[0095] The trajectory similarity calculation device, when calculating a current element Dp[i,j] of the two-dimensional dynamic array Dp, first obtains a current trajectory point distance d i,j .

[0096] Step S402: Obtain the element values of the neighboring elements of the current element, and determine the minimum element value of the neighboring elements of the current element.

[0097] The trajectory similarity calculation device, after determining the neighboring elements of the current element, obtains the element values of the neighboring elements of the current element, and determines the minimum element value of the neighboring elements of the current element.

[0098] Step S403: Take the maximum value between the minimum element value and the current trajectory point distance d

[0099] The trajectory similarity calculation device, after obtaining the minimum element value of the neighboring elements, compares the current trajectory point distance d i,j corresponding to the current element with the minimum element value, and takes the larger value as the element value of the current element.

[0100] In a specific application scenario of the two-dimensional dynamic array Dp calculation, the calculation method is as follows:

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

[0102] II. Calculate the distance matrix D=[d i,j ] m×n of the trajectories P and Q.

[0103] III. Create a two-dimensional dynamic array Dp with m rows and n columns, and initialize all elements Dp[i,j] of the array to -1.

[0104] IV. Set Dp[1,1]=d 1,1 ; set Dp[i,1]=max(Dp[i-1,1],d i,1 ), 2≤i≤m; set Dp[1,j]=max(Dp[1,j-1],d 1,j ), 2≤j≤n; set 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.

[0105] Optionally, the method for determining the trajectory similarity is as shown in Figure 5 , please refer to Figure 5 , Figure 5 .Figure 1 A specific flowchart of step S105 is shown in FIG. 12. The embodiment can implement step S105 by the method shown in FIG. 13. Figure 5 The step S105 can be implemented by the method shown in FIG. 13, and the specific implementation steps include steps S501-S502.

[0106] Step S501: Position the end element of the two-dimensional dynamic array according to the end point of the first trajectory and the end point of the second trajectory.

[0107] After calculating all element values of the two-dimensional dynamic array, the trajectory similarity calculation device positions the end element Dp[m, n] of the two-dimensional dynamic array according to the end point P(m) of the first trajectory and the end point Q(n) of the second trajectory.

[0108] Step S502: Determine the trajectory similarity of the first trajectory and the second trajectory by using the element value of the end element of the two-dimensional dynamic array.

[0109] Finally, the trajectory similarity calculation device obtains the element value Dp[m, n] of the end element of the two-dimensional dynamic array Dp, and takes it as the trajectory similarity of the first trajectory P and the second trajectory Q, that is, the discrete Fréchet distance of the first trajectory P and the second trajectory Q.

[0110] Optionally, the method for creating the two-dimensional dynamic array is shown in FIG. 14, please refer to Figure 6 , Figure 6 , Figure 6 is Figure 1 A specific flowchart of step S104 is shown in FIG. 11. The embodiment can implement step S104 by the method shown in FIG. 12. Figure 5 The step S104 can be implemented by the method shown in FIG. 12, and the specific implementation steps include steps S601-S602.

[0111] Step S601: Obtain the first length of the first trajectory and the second length of the second trajectory.

[0112] When creating the two-dimensional dynamic array Dp, the trajectory similarity calculation device determines the size of the two-dimensional dynamic array Dp based on the length of the first trajectory P and the length of the second trajectory Q, that is, before creating the two-dimensional dynamic array Dp, the trajectory similarity calculation device first obtains the first length of the first trajectory P and the second length of the second trajectory Q.

[0113] Step S602: Determine the number of rows and columns of the two-dimensional dynamic array based on the first length and the second length.

[0114] The trajectory similarity calculation device can take the first length as the number of rows of the two-dimensional dynamic array Dp, and take the second length as the number of columns of the two-dimensional dynamic array Dp, so as to create and initialize the two-dimensional dynamic array Dp.

[0115] In an application scenario, please refer toFigure 7 , Figure 7 is a schematic diagram of an embodiment of the first trajectory and the second trajectory provided by the present application. The first trajectory P = {P(1),...,P(5)} and the second trajectory Q = {Q(1),...,Q(6)} are obtained, wherein, as shown in the following table, 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), Q(5) = (4, 0), Q(6) = (5, 1). Figure 7

[0116] Based on the first trajectory P and the second trajectory Q described above, a distance matrix D between the two trajectories is calculated, and the distance matrix D is shown in the following table:

[0117]

[0118] At this time, a 5x6 two-dimensional dynamic array Dp is newly created based on the length of the first trajectory P and the length of the second trajectory Q, and the elements Dp[i,j] of the two-dimensional dynamic array Dp are all initialized to -1, as shown in the following table:

[0119]

[0120] Dp[1,1] is set to the value of the starting point distance d 1,1 in the distance matrix, at this time, the two-dimensional dynamic array is updated as follows:

[0121]

[0122] According to the formula Dp[i,1] = max(Dp[i-1,1],d i,1 ), 2≤i≤m, the element values of the first column of the dynamic array Dp are updated, and then the two-dimensional dynamic array Dp is updated as follows:

[0123]

[0124] According to the formula Dp[1,j] = max(Dp[1,j],d i,1 ), 2≤j≤n, the element values of the first column of the two-dimensional dynamic array Dp are updated, and then the dynamic array Dp is updated as follows:

[0125]

[0126] According to the formula Dp[i,j] = max(min(Dp[i-1,j],p[i,j-1],Dp[i-1,j-1]),d i,j ​), 2≤i≤m, 2≤j≤n update the other element values of the two-dimensional dynamic array Dp, at this time the two-dimensional dynamic array Dp is updated as follows:

[0127]

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

[0129] Optionally, the present application further provides a trajectory similarity calculation device, please refer to Figure 8 , Figure 8 is a structural schematic diagram of the first embodiment of the trajectory similarity calculation device provided by the present application, and the trajectory similarity calculation device 100 comprises a trajectory acquisition module 10, a distance calculation module 20, an array updating module 30 and a similarity determination module 40.

[0130] The trajectory acquisition module 10 is connected with the distance calculation module 20, the array updating module 30 is connected with the trajectory acquisition module 10 and the distance calculation module 20, and the similarity determination module 40 is connected with the array updating module 30.

[0131] The trajectory acquisition module 10 is configured to acquire at least two trajectories, wherein the at least two trajectories comprise a first trajectory and a second trajectory; the distance calculation module 20 is configured to calculate a distance matrix between the trajectories based on the first trajectory and the second trajectory, wherein the distance matrix comprises a plurality of trajectory point distances, each trajectory point distance being calculated based on the coordinates of a first trajectory point in the first trajectory and the coordinates of a second trajectory point in the second trajectory; the array updating module 30 is configured to create a two-dimensional dynamic array based on the first trajectory and the second trajectory, and calculate the element values of the two-dimensional dynamic array based on the distance matrix and according to a path planning condition; and the similarity determination module 40 is configured to determine the trajectory similarity of the first trajectory and the second trajectory according to the element values of the two-dimensional dynamic array.

[0132] Optionally, the present application further provides a trajectory similarity calculation device, please refer to Figure 9 , Figure 9 is a structural schematic diagram of the second embodiment of the trajectory similarity calculation device provided by the present application, and the trajectory similarity calculation device 200 comprises a processor 201 and a memory 202 connected with the processor 201.

[0133] The processor 201 can also be referred to as a CPU (Central Processing Unit). The processor 201 can be an integrated circuit chip having a processing capability of signals. The processor 201 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application-Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0134] The memory 202 is configured to store program data required by the processor 201.

[0135] The processor 201 is further configured to execute the program data stored in the memory 202 to implement the trajectory similarity calculation method.

[0136] Optionally, the present application further provides a computer readable storage medium. Please refer to Figure 10 , Figure 10 FIG. 3 is a structural schematic diagram of an embodiment of the computer readable storage medium provided by the present application.

[0137] The computer readable storage medium 300 of the embodiment of the present application internally stores program instructions 310, which are executed to implement the trajectory similarity calculation method.

[0138] The program instructions 310 can form a program file and be stored in the storage medium in the form of a software product, so that a trajectory similarity calculation device (which can be a personal computer, a server, or a network device, etc.) or a processor executes all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes, or a computer, a server, a mobile phone, a tablet, etc.

[0139] The computer readable storage medium 300 of the embodiment can be, but is not limited to, a U disk, an SD card, a PD optical drive, a mobile hard disk, a large-capacity floppy disk drive, a flash memory, a multimedia memory card, a server, etc.

[0140] In one embodiment, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. The processor of the trajectory similarity calculation device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the trajectory similarity calculation device performs the steps in each of the above method embodiments.

[0141] In addition, when the above functions are implemented in the form of software functions and sold or used as independent products, they can be stored in a mobile terminal readable storage medium, that is, the present application also provides a storage device storing program data, which can be executed to implement the method of the above embodiments. The storage device can be, for example, a U disk, an optical disk, a server, etc. That is, the present application can be embodied in the form of a software product, which includes a plurality of instructions for causing an intelligent terminal to execute all or part of the steps of the method described in each embodiment.

[0142] In addition, the terms "first", "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise specifically limited.

[0143] Any process or method descriptions in flow charts or otherwise described herein, represent embodiments of examples that can be implemented as executable instructions stored in a computer-readable storage medium, and the scope of the preferred embodiments of the present application includes additional implementations that can not be expressly shown or described in the description herein, but which are included in the scope of the embodiments of the present application, which should be understood by those skilled in the art of the technology to which the embodiments of the present application belong.

[0144] The logic and / or steps represented in the flow diagrams and / or otherwise described herein, for example, can be embodied in non-transitory computer-readable media, executed by an instruction execution system, apparatus, or device, such as a personal computer, server, network device, or other computing / processing apparatuses that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. In this regard, the "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can comprise any one of the following: electric connections (electronic devices), a portable computer diskette (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable medium upon which the program is printed, as the program can be electronically captured, via for example, an optical scanner, then compiled, interpreted, or otherwise processed in a suitable manner, if necessary, and stored in a computer memory.

[0145] The above description is merely illustrative of the application, and does not limit the scope of the application, which is defined by the appended claims. Any equivalent structure or process variations, which transform the teachings of the present application directly or indirectly into other technical fields related thereto, are intended to be covered by the present claims.

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; Based on the first trajectory and the second trajectory, create a two-dimensional dynamic array; Based on the distance matrix and according to the path planning conditions, calculate the element values ​​of the two-dimensional dynamic array; The step of calculating the element value of the two-dimensional dynamic array based on the distance matrix according to the 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 distance to the current trajectory point corresponding to the current element based on the distance matrix; obtaining the element value 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. The path planning condition is: the coordinate value of the current element is greater than the coordinate value of the adjacent element; wherein, the coordinate value includes a first coordinate value and / or a second coordinate value; The trajectory similarity between the first trajectory and the second trajectory is determined based on the element values ​​of the two-dimensional dynamic array.

2. The trajectory similarity calculation method according to claim 1, characterized in that... ; Determining the trajectory similarity between the first trajectory and the second trajectory based on the element values ​​of the two-dimensional dynamic array includes: Locate the endpoint element of the two-dimensional dynamic array according to the endpoint of the first trajectory and the endpoint of the second trajectory; The trajectory similarity between the first trajectory and the second trajectory is determined by using the element value of the endpoint element of the two-dimensional dynamic array.

3. The trajectory similarity calculation method according to claim 1, 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.

4. The trajectory similarity calculation method according to claim 1, characterized in that, The step of creating a two-dimensional dynamic array based on the first trajectory and the second trajectory includes: Obtain the first length of the first trajectory and the second length of the second trajectory. The number of rows and columns of the two-dimensional dynamic array are determined based on the first length and the second length.

5. A trajectory similarity calculation device, characterized in that, include: A trajectory acquisition module is used to acquire at least two trajectories, wherein the at least two trajectories include a first trajectory and a second trajectory; The distance calculation module is used to calculate 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, 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; An array update module is used to create a two-dimensional dynamic array based on the first trajectory and the second trajectory, and to calculate the element values ​​of the two-dimensional dynamic array according to the path planning conditions based on the distance matrix. The calculation of the element values ​​of the two-dimensional dynamic array according to the path planning conditions based on the distance matrix includes: determining the neighboring elements of the current element in the two-dimensional dynamic array according to the path planning conditions; 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; 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, wherein the path planning condition is that the coordinate value of the current element is greater than the coordinate values ​​of the neighboring elements; wherein the coordinate values ​​include a first coordinate value and / or a second coordinate value. The similarity determination module is used to determine the trajectory similarity between the first trajectory and the second trajectory based on the element values ​​of the two-dimensional dynamic array.

6. 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 4.

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

Citation Information

Patent Citations

  • Track similarity determination method and device

    CN110555061A

  • Improved DTW measurement method for track privacy protection, storage equipment and equipment

    CN111914287A