Track similarity calculation method and device

The method equalizes trajectory density using a coordinate filling algorithm and Redis Geo commands to enhance accuracy in trajectory similarity calculations, addressing uneven sampling issues and maintaining motion characteristics.

CN119150047AActive Publication Date: 2024-12-17BEIJING YUNXING ONLINE SOFTWARE DEV CO LTD

Patent Information

Application Number
CN202411648589.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2024-12-17
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

Existing trajectory similarity calculation methods are prone to misjudgment due to uneven sampling, leading to inconsistent trajectory density and deviation in calculation results.

Method used

A method and device that utilize a coordinate filling algorithm to equalize distance in trajectories, construct circled data, and mark coordinate points to calculate similarity, using Redis Geo commands to store and circle data, ensuring consistent density and accurate similarity calculation.

Benefits of technology

The method addresses the issue of uneven sampling by maintaining original motion characteristics and improving accuracy in trajectory similarity calculations, suitable for real-time and big data applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150047A_ABST
    Figure CN119150047A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of trajectory similarity calculation, in particular to a trajectory similarity calculation method and device.The method comprises the steps that firstly, a first trajectory to be calculated and a second trajectory to be calculated are obtained, equidistant filling is conducted on the first trajectory and the second trajectory through a coordinate filling algorithm, circling data are constructed according to the filled second trajectory, and the first trajectory and the second trajectory are calculated; and circling the circling data according to the filled first track, marking the coordinate points in the filled first track according to a circling result, and calculating the track similarity of the second track relative to the first track according to the marked coordinate points and the unmarked coordinate points in the filled first track. According to the invention, the coordinate filling algorithm is adopted to preprocess the original track, and the problems of inconsistent track density and calculation result deviation caused by non-uniform sampling at present are solved on the premise of keeping the original motion characteristics unchanged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of trajectory similarity calculation, and in particular to a trajectory similarity calculation method and device. Background Art

[0002] In the online car-hailing industry, drivers often do not follow the navigation. The reasons may be that the driver takes a detour, takes the wrong road, or the passenger gives directions. In order to improve the platform service experience, a similarity comparison will be made between the driver's actual driving trajectory and navigation trajectory, or the estimated planning trajectory and billing trajectory. Through the similarity comparison, some problematic orders and drivers can be discovered and processed for immediate risk control, thereby improving the platform service experience.

[0003] In the existing technology, trajectory similarity evaluation is usually affected by the uneven sampling of trajectory points. Although traditional methods such as Euclidean distance and dynamic time warping (DTW) are effective to a certain extent, they are prone to misjudgment when dealing with trajectories with inconsistent density. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a trajectory similarity calculation method and device to overcome the current problem of inconsistent trajectory density and deviation in calculation results due to uneven sampling.

[0005] To achieve the above objectives, the present invention adopts the following technical solutions: On the one hand, the present application provides a trajectory similarity calculation method, comprising: Obtain a first trajectory and a second trajectory to be calculated; Using a coordinate filling algorithm to fill the first track and the second track with equal distance; Constructing circled data according to the filled second track; Encircling the encircled data according to the filled first track, and marking the coordinate points in the filled first track according to the encircling result; The trajectory similarity of the second trajectory with respect to the first trajectory is calculated according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory.

[0006] Furthermore, in the above method, the step of using a coordinate filling algorithm to fill the first track and the second track with equal distances includes: Confirm all coordinate points in the first trajectory and the second trajectory; Determining a minimum distance between the first trajectory coordinate point and the second trajectory coordinate point; Determining a filling distance according to the minimum distance; According to the filling distance, a coordinate filling algorithm is used to fill the first track and the second track with equal distance.

[0007] Furthermore, in the above method, the step of constructing the circled data according to the filled second track includes: Confirm all coordinate points of the second track after filling; The redis geo command geoadd is used to store all coordinate points of the second trajectory into the redis database to generate circled data.

[0008] Furthermore, in the method described above, the step of circling the circled data according to the filled first track, and marking the coordinate points in the filled first track according to the circling result, includes: Confirm all coordinate points of the first track after filling; Store all the filled coordinate points of the first trajectory into the map data structure in sequence; confirming the circled distance according to the filling distance; Use the Redis Geo command Georedius command to circle the circled data with the circled distance as the radius and the coordinate point of the filled first track as the center, and mark the circled results of all the coordinate points of the filled first track.

[0009] Further, the method described above, wherein the use of the redis geo command georedius command to circle the circled data with the circled distance as the radius and the coordinate point of the filled first track as the center, and marking the circled results of all the coordinate points of the filled first track, includes: Use the Redis Geo command Georedius command to circle the selected data with the selected distance as the radius and the coordinate point of the first track after filling as the center; Confirm all circled coordinate points of the current coordinate point; If there is no circled coordinate point at the current coordinate point, the current coordinate point is not marked, and the next coordinate point is circled; If there is a circled coordinate point at the current coordinate point, mark the current coordinate point, and confirm the coordinate point closest to the current coordinate point among the circled coordinate points; The coordinate point closest to the current coordinate point is deleted from the circled data, and the next coordinate point is circled.

[0010] Furthermore, in the above method, the step of calculating the trajectory similarity of the second trajectory relative to the first trajectory according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory includes: Calculating the ratio of the number of coordinate points marked in the first track after filling to the number of all coordinate points in the first track after filling; The ratio result is the trajectory similarity of the second trajectory to the first trajectory.

[0011] On the other hand, the present application provides a trajectory similarity calculation device, including a processor and a memory, wherein the processor is connected to the memory: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store the program, and the program is at least used to execute any one of the above trajectory similarity calculation methods.

[0012] The beneficial effects of the present invention are: The present application first obtains the first trajectory and the second trajectory to be calculated, uses the coordinate filling algorithm to fill the first trajectory and the second trajectory with equal distances, constructs the circled data according to the filled second trajectory, circles the circled data according to the filled first trajectory, and marks the coordinate points in the filled first trajectory according to the circled result, and calculates the trajectory similarity of the second trajectory relative to the first trajectory according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory. In the present application, the coordinate filling algorithm is used to pre-process the original trajectory, which solves the problem of inconsistent trajectory density and deviation in calculation results due to uneven sampling while keeping the original motion characteristics unchanged. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0014] Figure 1 It is a flow chart provided by an embodiment of a method for calculating trajectory similarity of the present invention; Figure 2 It is a structural schematic diagram provided by an embodiment of a trajectory similarity calculation device of the present invention. DETAILED DESCRIPTION

[0015] To make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described in detail below. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other implementation methods obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.

[0016] Figure 1 This is a flow chart provided by an embodiment of a method for calculating trajectory similarity of the present invention. Figure 1 , this embodiment may include the following steps: S1. Obtain a first trajectory and a second trajectory to be calculated.

[0017] S2. Use a coordinate filling algorithm to fill the first track and the second track with equal distance.

[0018] S3. Construct circled data according to the filled second track.

[0019] S4. Encircle the encircled data according to the filled first track, and mark the coordinate points in the filled first track according to the encircling result.

[0020] S5. Calculate the trajectory similarity of the second trajectory with respect to the first trajectory according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory.

[0021] It can be understood that, in this embodiment, the first trajectory and the second trajectory to be calculated are first obtained, and the coordinate filling algorithm is used to fill the first trajectory and the second trajectory with equal distances, and the circled data is constructed according to the filled second trajectory, and the circled data is circled according to the filled first trajectory, and the coordinate points in the filled first trajectory are marked according to the circled result, and the trajectory similarity of the second trajectory relative to the first trajectory is calculated according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory. In this embodiment, the coordinate filling algorithm is used to pre-process the original trajectory, and the problem of inconsistent trajectory density and deviation in calculation results due to uneven sampling is solved under the premise of keeping the original motion characteristics unchanged.

[0022] It should be noted that the number of coordinate points of the first track and the second track is unknown, the length is unknown, and the track density is unknown.

[0023] Preferably, step S2 comprises: Confirm all coordinate points in the first track and the second track; Determine the minimum distance between the first track coordinate point and the second track coordinate point; Confirm the filling distance according to the minimum distance; According to the filling distance, the first track and the second track are filled with equal distance using the coordinate filling algorithm.

[0024] It can be understood that using the coordinate filling algorithm to pre-process the trajectory can solve the problem of inconsistent density caused by uneven sampling while keeping the original motion characteristics unchanged.

[0025] Preferably, step S3 includes: Confirm all coordinate points of the filled second track; Use the redis geo command geoadd to store all the coordinate points of the second track into the redis database to generate circled data.

[0026] It is understandable that redis is a high-performance memory database. There is a data structure in redis called zset. Zset is an ordered set data structure, which contains three attributes: key, value, and score. Key = "sampleB1", value = the sequence number n of the coordinate (x, y) in the B1 trajectory, and score is the value calculated using the redis geo command geohash(x, y).

[0027] Preferably, step S4 comprises: Confirm all coordinate points of the first track after filling; Store all the coordinate points of the filled first trajectory into the map data structure in sequence; Confirm the circle distance according to the filling distance; Use the Redis Geo command georedius command to circle the selected data with the circle distance as the radius and the coordinate point of the first track after filling as the center, and mark the circle results of all coordinate points of the first track after filling.

[0028] Preferably, the redis geo command georedius command is used to circle the selected data with the circle distance as the radius and the coordinate point of the filled first track as the center, and the circle results of all the coordinate points of the filled first track are marked, including: Use the Redis Geo command georedius command to circle the selected data with the circle distance as the radius and the coordinate point of the first filled track as the center; Confirm all circled coordinate points of the current coordinate point; If there is no circled coordinate point at the current coordinate point, the current coordinate point will not be marked, and the next coordinate point will be circled; If there is a circled coordinate point at the current coordinate point, mark the current coordinate point and confirm the coordinate point closest to the current coordinate point among the circled coordinate points; Delete the coordinate point closest to the current coordinate point in the circled data, and circle the next coordinate point.

[0029] Preferably, step S5 includes: Calculate the ratio of the number of coordinate points marked in the first track after filling to the number of all coordinate points in the first track after filling; The ratio result is the trajectory similarity of the second trajectory relative to the first trajectory.

[0030] In practice, to find the similarity of track B with respect to track A, first use the coordinate filling algorithm to fill the two tracks with equal distance d, where d is less than or equal to half of the minimum distance between the points of tracks A and B, so that the density of tracks A and B is similar, and new tracks A1 and B1 with similar track density are obtained. Then all coordinates (x, y) in track B1 are stored using the redisgeo command geoadd(key, value, score), for example, key = "sampleB1", value = the sequence number n of the coordinate (x, y) in track B1, and score is the value calculated using the redis geo command geohash(x, y). And so on, traverse all points in B. Traverse the coordinate points in A1 and store them in the map data structure in sequence. The key of the map is [A1_coordinate sequence number], and the value is flag, which means 1 or 0. At the same time, use the coordinate points (p, q) in A1 in sequence. Use the redis geo command georedius command to circle the coordinates in B1 with a radius less than or equal to d / 2 from the data built in step 1. The circle selection results are output in ascending order of distance. The first coordinate of the output result is the point that meets the circle selection radius from the coordinates in B1 to the coordinate point (p, q) in A1. Get the sequence number of this point, and use the redis zset command zrem to delete the data with the value of the sequence number in the circled data. And so on, traverse all the points in A1. If the circle selection result of the coordinate point in A1 is not empty, find the value of the coordinate point (p, q) in the map data storing the coordinates of A1 and rewrite it to 1. Otherwise, mark it as 0. The marking is completed, which means that there are coordinates in B1 that are similar to the point (p, q) in A1. Count all coordinate points in A1 with flag 1 / all coordinate points in A1, and the result is the trajectory similarity of the original trajectory B relative to the original trajectory A.

[0031] It is understandable that the present embodiment can be extended to various types of mobile object analysis, including vehicle monitoring, motion path planning, group behavior analysis and other fields.

[0032] It demonstrates excellent performance when processing large-scale location data and can support applications such as intelligent transportation systems and location services in complex urban environments.

[0033] The use of geo-circle selection simplifies the spatial data structure and reduces the computational complexity, making the method suitable for real-time and big data. At the same time, compared with the hexagonal honeycomb grid algorithm, geo-circle selection is more accurate, has more comprehensive coverage, and is more suitable for online car-hailing scenarios.

[0034] The present invention also provides a trajectory similarity calculation device, which is used to implement the above method embodiment. Figure 2 FIG. 1 is a schematic diagram of a structure of a trajectory similarity calculation device according to an embodiment of the present invention. Figure 2 As shown, a trajectory similarity calculation device of this embodiment includes a processor 21 and a memory 22, and the processor 21 is connected to the memory 22. The processor 21 is used to call and execute the program stored in the memory 22; the memory 22 is used to store the program, and the program is used to execute at least one trajectory similarity calculation method in the above embodiment.

[0035] The specific implementation scheme of a trajectory similarity calculation device provided in an embodiment of the present application can refer to the implementation scheme of a trajectory similarity calculation method in any of the above embodiments, which will not be repeated here.

[0036] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.

[0037] It should be noted that, in the description of the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" refers to at least two.

[0038] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.

[0039] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0040] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0041] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0042] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.

[0043] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0044] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A trajectory similarity calculation method, It is characterized in that include: Obtain a first trajectory and a second trajectory to be calculated; Using a coordinate filling algorithm to fill the first track and the second track with equal distance; Constructing circled data according to the filled second track; Encircling the encircled data according to the filled first track, and marking the coordinate points in the filled first track according to the encircling result; The trajectory similarity of the second trajectory with respect to the first trajectory is calculated according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory.

2. The method according to claim 1, It is characterized in that The using a coordinate filling algorithm to fill the first track and the second track with equal distances includes: Confirm all coordinate points in the first trajectory and the second trajectory; Determining a minimum distance between the first trajectory coordinate point and the second trajectory coordinate point; Determining a filling distance according to the minimum distance; According to the filling distance, a coordinate filling algorithm is used to fill the first track and the second track with equal distance.

3. The method according to claim 2, It is characterized in that The step of constructing the circled data according to the filled second track includes: Confirm all coordinate points of the second track after filling; The redis geo command geoadd is used to store all coordinate points of the second trajectory into the redis database to generate circled data.

4. The method according to claim 3, It is characterized in that The step of encircling the encircled data according to the filled first track, and marking the coordinate points in the filled first track according to the encircling result, includes: Confirm all coordinate points of the first track after filling; Store all the filled coordinate points of the first trajectory into the map data structure in sequence; confirming the circled distance according to the filling distance; Use the Redis Geo command Georedius command to circle the circled data with the circled distance as the radius and the coordinate point of the filled first track as the center, and mark the circled results of all the coordinate points of the filled first track.

5. The method according to claim 4, It is characterized in that The method of using the redis geo command georedius command to encircle the selected data with the encircled distance as the radius and the coordinate point of the filled first track as the center, and marking the encircled results of all the coordinate points of the filled first track includes: Use the Redis Geo command Georedius command to circle the selected data with the selected distance as the radius and the coordinate point of the first track after filling as the center; Confirm all circled coordinate points of the current coordinate point; If there is no circled coordinate point at the current coordinate point, the current coordinate point is not marked, and the next coordinate point is circled; If there is a circled coordinate point at the current coordinate point, mark the current coordinate point, and confirm the coordinate point closest to the current coordinate point among the circled coordinate points; The coordinate point closest to the current coordinate point is deleted from the circled data, and the next coordinate point is circled.

6. The method according to claim 5, It is characterized in that The calculating the trajectory similarity of the second trajectory with respect to the first trajectory according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory includes: Calculating the ratio of the number of coordinate points marked in the first track after filling to the number of all coordinate points in the first track after filling; The ratio result is the trajectory similarity of the second trajectory to the first trajectory.

7. A trajectory similarity calculation device, It is characterized in that The invention comprises a processor and a memory, wherein the processor is connected to the memory: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store the program, and the program is at least used to execute the trajectory similarity calculation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • GPS trajectory similarity matching algorithm based on time

    CN108508465A

  • Vehicle classification trajectory error correction method based on map matching

    CN113505187A

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

    CN115982592A

  • Track prediction method, system and equipment based on track similarity

    CN116701951A

  • Trajectory tracking duplicate removal method and device based on vehicle infrastructure cooperation

    CN117202105A

Cited By

  • Robot similar motion route identification method based on deep learning model

    CN120196917A