Trajectory optimization method, device and equipment
By combining the sliding enclosure box and preset threshold conditions, the trajectory points of the optimized trajectory are compressed, which solves the problem of high trajectory optimization time complexity in the prior art, improves optimization efficiency and ensures accuracy.
Patent Information
- Application Number
- CN202411898100.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-25
AI Technical Summary
When the prior art optimizes the trajectory of the positioning object, there is a problem of high time complexity, resulting in low optimization efficiency.
Trajectory optimization is achieved by using a sliding bounding box to sequentially enclosing the track points to be optimized, and the track points are compressed according to the target sliding bounding box and preset threshold conditions.
It improves the efficiency of trajectory optimization, avoids repeated calculations caused by inappropriate segmentation, and ensures the space proximity of compressed points, thereby ensuring optimization accuracy.
Smart Images

Figure CN119884262A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to computer technology, and in particular to a trajectory optimization method, device and equipment. Background Art
[0002] With the development of information technology and the popularization of various auxiliary positioning methods such as satellite positioning, trajectory information is becoming more and more common in daily life. At present, thanks to the reduction of data storage costs, a large amount of trajectory point data is collected and stored.
[0003] It is understandable that when the positioning object is stationary for a long time, due to the objective conditions of the positioning technology, its positioning information will jitter within a certain range, thereby generating a large number of trajectory points. The same is true when the positioning object wanders in a small range for a long time. In order to quickly extract effective information from the trajectory information of the positioning object, the known technology proposes to optimize the trajectory of the positioning object by compressing it.
[0004] However, the process of optimizing the trajectory of the positioning object in the known technology has the defect of high time complexity, which is not conducive to ensuring the optimization efficiency. Summary of the invention
[0005] The present application provides a trajectory optimization method, device and equipment to improve the optimization efficiency of the trajectory to be optimized.
[0006] In a first aspect, the present application provides a trajectory optimization method, the method comprising:
[0007] Update the initial diagonal coordinates of the sliding bounding box according to the xth trajectory point of the trajectory to be optimized to obtain a target sliding bounding box; x is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty;
[0008] According to the target sliding bounding box and a preset threshold condition, the trajectory points included in the trajectory to be optimized are compressed to obtain an optimized trajectory of the trajectory to be optimized; the preset threshold condition is used to control the size of the target sliding bounding box.
[0009] In another possible implementation, the step of compressing the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and a preset threshold condition to obtain an optimized trajectory of the trajectory to be optimized includes:
[0010] In the range of x to N, n is taken as integer values in sequence, and the following steps are performed until n+1=N, and the optimized trajectory corresponding to the trajectory to be optimized is determined according to the optimized trajectory points; wherein N is the number of trajectory points contained in the trajectory to be optimized:
[0011] If the target sliding bounding box meets the preset threshold condition, the diagonal coordinates of the target sliding bounding box are updated according to the n+1th trajectory point to obtain an updated target sliding bounding box;
[0012] If the target sliding bounding box does not meet the preset threshold condition, the other track points in the target sliding bounding box except the nth track point are compressed to obtain the optimized track point, and after the target sliding bounding box is cleared, the diagonal coordinates of the target sliding bounding box are updated according to the nth track point to obtain the updated target sliding bounding box.
[0013] In another possible implementation, the method further includes:
[0014] Determine the target distance of the target sliding bounding box according to the diagonal coordinates of the target sliding bounding box; the target distance includes at least one of the following: diagonal length, bounding box length, and bounding box height;
[0015] If the target distance is not greater than the preset distance, it is determined that the target sliding bounding box meets the preset threshold condition.
[0016] In another possible implementation, the method further includes:
[0017] If the target distance is greater than the preset distance, it is determined that the target sliding bounding box does not meet the preset threshold condition.
[0018] In another possible implementation, the diagonal corners of the target sliding bounding box include a lower left corner and an upper right corner; and updating the diagonal coordinates of the target sliding bounding box according to the n+1th trajectory point to obtain an updated target sliding bounding box includes:
[0019] If the first horizontal axis coordinate corresponding to the n+1th trajectory point is smaller than the second horizontal axis coordinate of the lower left corner, the second horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the second horizontal axis coordinate remains unchanged;
[0020] If the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third horizontal axis coordinate of the upper right corner, the third horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the third horizontal axis coordinate remains unchanged;
[0021] If the first vertical axis coordinate corresponding to the n+1th trajectory point is smaller than the second vertical axis coordinate of the lower left corner, then the second vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the second vertical axis coordinate remains unchanged;
[0022] If the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third vertical axis coordinate of the upper right corner, the third vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the third vertical axis coordinate remains unchanged.
[0023] In another possible implementation, compressing the other trajectory points except the nth trajectory point in the target sliding bounding box to obtain the optimized trajectory point includes:
[0024] Based on the coordinate data of the other trajectory points, determining the target coordinate data corresponding to the center of gravity of the other trajectory points;
[0025] Determine the optimized trajectory points corresponding to the other trajectory points according to the target coordinate data.
[0026] In another possible implementation, the preset threshold condition is related to a user demand; the user demand is used to indicate a required trajectory key point.
[0027] In another possible implementation, the method further includes:
[0028] The value of x is determined according to the user's needs.
[0029] In a second aspect, the present application provides an energy management device, the device comprising:
[0030] An updating module, used for updating the initial diagonal coordinates of the sliding bounding box according to the x-th trajectory point of the trajectory to be optimized, to obtain a target sliding bounding box; x is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty;
[0031] The optimization module is used to compress the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and a preset threshold condition to obtain an optimized trajectory of the trajectory to be optimized; the preset threshold condition is used to control the size of the target sliding bounding box.
[0032] In a third aspect, the present application provides an electronic device, including: at least one processor and a memory;
[0033] The memory stores computer-executable instructions;
[0034] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method as described in any one of the first aspects above.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a central processing unit, they are used to implement the method described in any one of the first aspects above.
[0036] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a central processing unit, implements the method described in any one of the first aspects.
[0037] The present application provides a trajectory optimization method, device and equipment, wherein the method of the present application is executed by any electronic device, the electronic device updates the initial diagonal coordinates of the sliding bounding box according to the x-th trajectory point of the trajectory to be optimized, obtains the target sliding bounding box, and compresses the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and the preset threshold condition, to obtain the optimized trajectory of the trajectory to be optimized. In the method of the present application, the trajectory points of the trajectory to be optimized are sequentially enclosed by the sliding bounding box, which is equivalent to segmentation and compression at the same time without pre-segmentation, and by setting the preset threshold condition, it can be ensured that the compressed trajectory points must be close in space, thereby avoiding repeated calculations caused by inappropriate segmentation, and thus making the optimization efficiency higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0039] Figure 1A Figure 1 is an example of a trajectory optimization scenario in a known technology provided in an embodiment of the present application;
[0040] Figure 1B An example of a trajectory optimization scenario in a known technology provided in an embodiment of the present application Figure 2 ;
[0041] Figure 2 A schematic diagram of an application scenario of a trajectory optimization method provided in an embodiment of the present application;
[0042] Figure 3 A flow chart of a trajectory optimization method provided in an embodiment of the present application is shown in FIG1 ;
[0043] Figure 4 A schematic diagram of a trajectory optimization method provided in an embodiment of the present application Figure 2 ;
[0044] Figure 5 A schematic diagram of a trajectory optimization method provided in an embodiment of the present application Figure 3 ;
[0045] Figure 6A-6H An example diagram of a trajectory optimization process provided in an embodiment of the present application;
[0046] Figure 7 A schematic diagram of the structure of a trajectory optimization device provided in an embodiment of the present application;
[0047] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0048] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0049] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0050] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0051] With the rapid development of information technology, the popularity of various auxiliary positioning methods such as satellite positioning, Wi-Fi positioning, and Bluetooth positioning has made trajectory information ubiquitous in daily life. Specifically, whether it is guiding directions in navigation applications, tracking the location of goods in the logistics industry, or recording running routes in sports and fitness applications, trajectory information plays an important role. In addition, services such as food delivery and shared travel also rely on accurate trajectory information to optimize routes and improve user experience.
[0052] At present, thanks to the advancement of data storage technology and the reduction of costs, a large amount of trajectory point data is continuously collected and stored. As the driving force of modern information technology, especially as the "fuel" of artificial intelligence and machine learning, the importance of data is self-evident. Therefore, most companies have adopted a "better to be excessive than to be insufficient" strategy in data collection and storage, hoping to support future analysis and decision-making through the accumulation of massive amounts of data. This strategy is no exception in the processing of trajectory data. Companies tend to save as many trajectory points as possible so that they can conduct in-depth analysis when needed.
[0053] However, too much track point information may cause information overload in some cases. When a user views a track, if all points are presented indiscriminately, it may appear too cumbersome and drown out the truly valuable information. For example, when the positioning object remains stationary for a long time, due to the accuracy limitations of the positioning technology, the positioning information may jitter in a small range, resulting in a large number of nearly overlapping positioning points. Similarly, when the positioning object wanders in a small range for a long time, a similar effect will occur. These redundant points not only do not provide additional value, but instead form "dead knots", thereby interfering with the user's extraction of effective information.
[0054] Therefore, it is proposed in the known technology to optimize the trajectory information of the positioning object to simplify the trajectory information, so that the key points and paths can be highlighted, which is convenient for users to extract effective information in time.
[0055] For example, the known technology proposes to optimize the trajectory to be optimized by Douglas-Peucker algorithm. Specifically, Douglas-Peucker algorithm, referred to as DP algorithm, is a classic trajectory compression algorithm. The general idea of the algorithm is as follows: a straight line L is virtually connected through the initial trajectory point and the terminal trajectory point of a trajectory, and the distances d1, d2...dn from the remaining trajectory points to L are calculated. The largest one max (d1, d2...dn) is selected and compared with a given threshold. If it is less than or equal to the threshold, all these trajectory points are deleted. If it is greater than the threshold, the trajectory point with the largest distance from L is retained, and the trajectory is divided into two parts, L1 and L2, by this point, and then L1 and L2 are compressed again recursively.
[0056] It is understandable that the above process needs to be optimized through recursion, which has the problem of high time complexity. On the other hand, in the above optimization process, only the trajectory shape is combined for optimization, which will cause some key points that users pay attention to to be compressed, reducing the value of trajectory information. For example, when a vehicle is traveling on a long straight road, the DP algorithm will only retain the starting point and the end point, but in fact the user wants to see the points in the middle, because this is a long journey, and these points in the middle will increase the user's trust in this trajectory.
[0057] In addition, the core of the DP algorithm relies on finding the distance between a point and a line L. When the distance between the two points that determine L is far, the algorithm performs well, and when the distance between the two points is close, the performance is very poor. For example, Figure 1A FIG1 is an example of a trajectory optimization scenario in a known technology provided in an embodiment of the present application. Figure 1B An example of a trajectory optimization scenario in a known technology provided in an embodiment of the present application Figure 2 .like Figure 1A As shown in , the DP algorithm performs well when the starting and ending points of the trajectory are far apart. Figure 1B As shown in Figure 2, the DP algorithm performs poorly when the start and end points of the trajectory are close.
[0058] Furthermore, in the known technology, the idea of sliding window is introduced on the basis of DP algorithm to solve the problem of high time complexity caused by recursive process. Specifically, the algorithm is described as follows: first, the first point of the trajectory to be optimized is stored, the first point of the trajectory to be optimized is selected as the starting trajectory point of the sliding window, the third point is used as the ending trajectory point of the sliding window, the straight line determined by the starting trajectory point and the ending trajectory point is recorded as L, and the distance of other points in the sliding window from L is calculated. If all distances are less than a predetermined threshold, the sliding window slides back one trajectory point along the trajectory sequence direction. Otherwise, if a point with an offset distance greater than the threshold appears, the trajectory point before the ending trajectory point of the sliding window is added to the compressed trajectory set, and the new sliding window starts from this trajectory point, and the above processing method is continued until the processing is completed.
[0059] However, although the above process avoids recursive calculation, each sliding will cause the line L to change, and all points in the window need to be recalculated, which makes the time complexity still very high. In addition, the above process also completely inherits other defects of the DP algorithm.
[0060] Therefore, the present application provides a trajectory optimization method, device and equipment to solve the above problems. Among them, the trajectory optimization method of the present application proposes a sliding window-based idea and a bounding box to achieve trajectory compression. Specifically, the method of the present application can be executed by any electronic device. The electronic device makes the sliding bounding box surround the trajectory points of the trajectory to be optimized in sequence, and in the process, determines whether it is necessary to compress the trajectory points in the target sliding bounding box according to the target sliding bounding box and the preset threshold condition, so as to achieve the optimization of the trajectory to be optimized.
[0061] It can be understood that, through the above process, on the one hand, repeated calculations caused by inappropriate segmentation can be avoided, and the present application is equivalent to performing segmentation and compression simultaneously, so that the optimization efficiency of the present application is higher. On the other hand, in the method of the present application, the sliding bounding box sequentially surrounds the trajectory points of the trajectory to be optimized, and the size of the sliding bounding box is controlled by a preset threshold condition, which is conducive to ensuring that the compressed points are close in space, thereby ensuring the accuracy of the optimization.
[0062] It is understandable that the method of the present application can be applied to the scenario of optimizing the trajectory to be optimized output by any terminal device. Figure 2 A schematic diagram of an application scenario of a trajectory optimization method provided in an embodiment of the present application, such as Figure 2 As shown, the method of the present application can be used in a scenario where the trajectory to be optimized output by a children's watch is optimized.
[0063] Specifically, the electronic device and the children's watch are connected in a wired or wireless communication manner to obtain the trajectory to be optimized output by the children's watch. Through the method of the present application, the electronic device uses a sliding bounding box to sequentially enclose the trajectory points of the trajectory to be optimized. In this process, the electronic device updates the diagonal coordinates of the sliding bounding box according to the x-th trajectory point of the trajectory to be optimized to obtain the target sliding bounding box. Furthermore, according to the target sliding bounding box and the preset threshold condition, the trajectory points included in the trajectory to be optimized are compressed to obtain the optimized trajectory of the trajectory to be optimized.
[0064] Among them, the preset threshold condition can be configured by the user to the children's watch and transmitted to the electronic device by the children's watch, so that the optimized trajectory output by the electronic device is an optimized trajectory that omits the trajectory points that the user does not want to pay attention to.
[0065] Through the above settings, the electronic device can output the optimization trajectory in a timely manner, so that the user of the children's watch can receive the required optimization trajectory in a timely manner.
[0066] It is understandable that in actual applications, the electronic device can also be integrated into the children's watch, which is not limited in this embodiment. In addition, in different application scenarios, the electronic device can also be connected to other devices that require attention to the optimized trajectory, such as the parent's mobile phone, etc., through wired or wireless means, which is not limited in this embodiment.
[0067] It is understandable that the method of the present application can also be applied to vehicle locators, mobile phone locators, etc., which will not be described in detail here.
[0068] In the following, some embodiments of the present application are described in detail in conjunction with the accompanying drawings. In the case where the embodiments do not conflict with each other, the following embodiments and features in the embodiments can be combined with each other.
[0069] This application provides a trajectory optimization method. Figure 3 A flow chart of a trajectory optimization method provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the method provided in this embodiment includes:
[0070] S301, updating the initial diagonal coordinates of the sliding bounding box according to the x-th trajectory point of the trajectory to be optimized to obtain a target sliding bounding box.
[0071] Wherein, x is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty.
[0072] It can be understood that the trajectory to be optimized includes multiple trajectory points. In this embodiment, the sliding bounding box is used to sequentially surround the trajectory points in the trajectory to be optimized. Among them, the sliding bounding box starts to surround the trajectory points from the trajectory point to be optimized, which can be configured according to user needs. That is, the value of x is determined according to the user's demand for indicating the required trajectory key points. Exemplarily, if the user does not use the starting trajectory point as a key point, x can be 1. If the starting trajectory point is a key point that the user is concerned about, x can only be an integer greater than 1.
[0073] In this embodiment, the sliding bounding box is specifically an axis-aligned bounding box, and the diagonal coordinates specifically refer to the coordinates of the lower left corner and the upper right corner of the axis-aligned bounding box. On this basis, the initial diagonal coordinates are specifically used to indicate that the coordinates of the lower left corner are (+∞, +∞) and the coordinates of the lower right corner are (-∞, -∞), so that the sliding bounding box is infinitely small, thereby making the sliding bounding box empty.
[0074] Optionally, in practical applications, the diagonal coordinates may also refer to the coordinates of the lower right corner and the upper left corner of the axis-aligned bounding box, which is not limited in this embodiment, as long as the specific process of updating the diagonal coordinates is adaptively changed. In addition, when the diagonal coordinates indicate the coordinates of the lower left corner and the upper right corner of the axis-aligned bounding box, the initial diagonal coordinates may also specifically indicate that the coordinates of the lower left corner are (0, 0) and the coordinates of the lower right corner are (0, 0), so that the sliding bounding box is empty, that is, the initial diagonal coordinates are not limited in this embodiment, as long as the sliding bounding box can be made empty.
[0075] It is understandable that when the electronic device slides the bounding box to enclose the x-th trajectory point, it updates the initial diagonal coordinates of the sliding bounding box according to the coordinates of the x-th trajectory point to obtain the target sliding bounding box. Specifically, in this embodiment, the process of updating the initial diagonal coordinates of the sliding bounding box according to the coordinates of the x-th trajectory point is not limited, as long as the x-th trajectory point can be within the target sliding bounding box.
[0076] S302, compressing the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and the preset threshold condition to obtain an optimized trajectory of the trajectory to be optimized.
[0077] The preset threshold condition is used to control the size of the target sliding bounding box.
[0078] In this embodiment, the preset threshold condition is related to the user demand, that is, the preset threshold condition is specifically set according to the user demand. The user demand is used to indicate the key points of the trajectory that the user needs to pay attention to. In actual applications, when the electronic device does not receive the user demand, it can also determine the preset threshold condition based on historical user demand and combined with the current scene. This embodiment does not limit this.
[0079] For example, if the user demand indicates that the user does not pay attention to the trajectory changes within 5 meters from the current trajectory point, the preset threshold condition can be used to control the diagonal length of the target sliding bounding box within 5 meters. If the electronic device does not receive the user demand, the electronic device determines the user demand based on the historical user demand corresponding to the current scene in combination with the current scene.
[0080] It is understandable that when the target sliding bounding box meets the preset threshold condition, it means that the trajectory points in the target sliding bounding box can be compressed. When the target sliding bounding box does not meet the preset threshold condition, it means that the trajectory points recently added to the target sliding bounding box cannot be compressed with the trajectory points previously added to the target sliding bounding box. For the trajectory points that can be compressed, the electronic device compresses them to obtain the optimized trajectory of the trajectory to be optimized.
[0081] In the method provided in this embodiment, the electronic device makes the sliding bounding box surround the track points in the track to be optimized in sequence, and updates the diagonal coordinates of the sliding bounding box according to the coordinates of the track point each time a track point is surrounded, and obtains the corresponding target sliding bounding box. Then, according to the target sliding bounding box and the preset threshold condition for controlling the size of the target sliding bounding box, the track points of the track to be optimized are compressed to obtain the optimized track of the track to be optimized.
[0082] By using the method of this embodiment, segmentation and compression can be performed simultaneously, which can save the time of early segmentation on the one hand, and avoid repeated calculations caused by inappropriate segmentation on the other hand, thereby making the optimization more efficient. In addition, since a preset threshold condition is set to control the size of the target sliding bounding box, the compressed trajectory points must be close in space, thereby avoiding unreasonable compression caused by inappropriate segmentation, thereby ensuring the accuracy of optimization.
[0083] Based on the above embodiments, the present application provides a method embodiment for describing in detail the process of obtaining an optimized trajectory by an electronic device according to a target sliding bounding box and a preset threshold condition. Figure 4 A schematic diagram of a trajectory optimization method provided in an embodiment of the present application Figure 2 ,like Figure 4 As shown, the method of this embodiment includes:
[0084] S401, updating the initial diagonal coordinates of the sliding bounding box according to the nth trajectory point of the trajectory to be optimized to obtain a target sliding bounding box.
[0085] Wherein, n is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty.
[0086] Specifically, in this embodiment, n is 2 to retain the starting point of the trajectory to be optimized. In addition, in this embodiment, the initial diagonal coordinates of the sliding bounding box are specifically used to indicate that the lower left corner coordinates are (+∞, +∞) and the lower right corner coordinates are (-∞, -∞).
[0087] S402, determine whether n is equal to N-1; if so, execute S403, otherwise execute S407.
[0088] It should be understood that N is the number of trajectory points included in the trajectory to be optimized.
[0089] S403: Determine a target distance of the target sliding bounding box according to the diagonal coordinates of the target sliding bounding box.
[0090] The target distance includes at least one of the following: diagonal length, bounding box length, and bounding box height.
[0091] Specifically, when the diagonal coordinates of the target sliding bounding box are known, the length of the bounding box can be calculated according to the horizontal coordinates of the lower left corner and the upper right corner contained in the diagonal coordinates; the height of the bounding box can be calculated according to the vertical coordinates of the lower left corner and the upper right corner contained in the diagonal coordinates; the diagonal length of the target sliding bounding box can be calculated according to the horizontal and vertical coordinates of the lower left corner and the upper right corner contained in the diagonal coordinates. It can be understood that the diagonal length of the target sliding bounding box can more directly reflect the distance between the trajectory points than the bounding box length and the bounding box height.
[0092] S404, determining whether the target sliding bounding box meets a preset threshold condition according to the target distance; if so, executing S405, otherwise, executing S406.
[0093] In this embodiment, when any one of the bounding box length, the bounding box height, and the diagonal length is used as the target distance, when the value of the corresponding item is not greater than the preset distance, it is determined that the target sliding bounding box meets the preset threshold condition. Otherwise, it is determined that the target sliding bounding box does not meet the preset threshold condition.
[0094] In practical applications, at least two of the bounding box length, the bounding box height, and the diagonal length can also be used as the target distance. The target distance is specifically the weighted average of the at least two items. Based on this target distance, it is determined whether the target sliding bounding box meets the preset threshold condition to ensure optimization accuracy. This is not limited in this embodiment.
[0095] S405, updating the diagonal coordinates of the target sliding bounding box according to the n+1th trajectory point, obtaining an updated target sliding bounding box, and setting n=n+1.
[0096] Specifically, in this embodiment, when the current target sliding bounding box meets the preset threshold condition, the electronic device continues to make the target sliding bounding box enclose the next trajectory point of the x-th trajectory point, the n+1-th trajectory point, and updates the diagonal coordinates of the target sliding bounding box according to the coordinates of the n+1-th trajectory point to obtain an updated target sliding bounding box.
[0097] In this embodiment, the diagonals of the target sliding bounding box include the lower left corner and the upper right corner. Figure 5 A schematic diagram of a trajectory optimization method provided in an embodiment of the present application Figure 3 ,like Figure 5 As shown, the electronic device updates the diagonal coordinates of the target sliding bounding box through the following steps:
[0098] S1, if the first horizontal axis coordinate corresponding to the n+1th trajectory point is smaller than the second horizontal axis coordinate of the lower left corner, the second horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the second horizontal axis coordinate remains unchanged.
[0099] S2, if the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third horizontal axis coordinate of the upper right corner, the third horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the third horizontal axis coordinate remains unchanged.
[0100] S3, if the first vertical axis coordinate corresponding to the n+1th trajectory point is smaller than the second vertical axis coordinate of the lower left corner, the second vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the second vertical axis coordinate remains unchanged.
[0101] S4, if the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third vertical axis coordinate of the upper right corner, the third vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the third vertical axis coordinate remains unchanged.
[0102] Specifically, when the target sliding bounding box surrounds the n+1th track point, the electronic device determines whether it is necessary to assign the first horizontal axis coordinate of the n+1th track point to the second horizontal axis coordinate by judging the size of the first horizontal axis coordinate corresponding to the n+1th track point and the second horizontal axis coordinate of the lower left corner of the target sliding bounding box. Similarly, the electronic device determines the third horizontal axis coordinate of the upper right corner of the target sliding bounding box based on the first horizontal axis coordinate of the n+1th track point.
[0103] The electronic device determines whether to assign the first vertical axis coordinate of the n+1th trajectory point to the second vertical axis coordinate by judging the size of the first vertical axis coordinate corresponding to the n+1th trajectory point and the second vertical axis coordinate of the lower left corner of the target sliding bounding box. Similarly, the electronic device determines the third vertical axis coordinate of the upper right corner of the target sliding bounding box based on the first vertical axis coordinate of the n+1th trajectory point.
[0104] Through the above process, on the one hand, it can be ensured that the target sliding bounding box can enclose the n+1th track point and the track point originally located in the target sliding bounding box, which is conducive to ensuring the accuracy of track optimization. On the other hand, according to the first horizontal axis coordinate and the first vertical axis coordinate of the n+1th track point, the diagonal coordinates of the target sliding bounding box are updated, which can make the target sliding bounding box as small as possible, so that the target distance of the target sliding bounding box can be closer to the distance between adjacent track points, which is also conducive to ensuring the accuracy of track optimization.
[0105] S406, compress the other track points in the target sliding bounding box except the nth track point to obtain the optimized track points, and after clearing the target sliding bounding box, update the diagonal coordinates of the target sliding bounding box according to the nth track point, and then make n=n+1.
[0106] In this embodiment, the electronic device determines the target coordinate data corresponding to the center of gravity of other trajectory points based on the coordinate data of other trajectory points; and determines the optimized trajectory points corresponding to other trajectory points according to the target coordinate data.
[0107] Optionally, in practical applications, other trajectory points except the nth trajectory point in the target sliding bounding box may be compressed by other methods to obtain optimized trajectory points. Exemplarily, this may be achieved by the aforementioned DP algorithm, by linear interpolation, etc., which is not limited in this embodiment.
[0108] It is understandable that after the target sliding bounding box adds the nth track point, it does not meet the preset threshold condition, which means that the nth track point cannot be compressed with the original track points in the target sliding bounding box. Therefore, in this embodiment, when the target sliding bounding box does not meet the preset threshold condition, the electronic device compresses the other track points in the target sliding bounding box except the nth track point to obtain the optimized track points corresponding to the other track points.
[0109] Among them, when n=3, the target sliding bounding box has only the second track point except the nth track point. At this time, the optimized track point corresponding to the second track point is itself. It can be understood that when n=2, the target sliding bounding box only contains one second track point, and the target sliding bounding box at this time meets the preset threshold condition.
[0110] In this embodiment, when the target sliding bounding box does not meet the preset threshold condition, after obtaining the optimized trajectory point according to other trajectory points in the target sliding bounding box, the electronic device initializes the diagonal coordinates of the target sliding bounding box so that the diagonal coordinates are updated to the initial diagonal coordinates to clear the target sliding bounding box. Further, the electronic device updates the diagonal coordinates of the target sliding bounding box according to the nth trajectory point to obtain an updated target sliding bounding box, so that the updated target sliding bounding box only contains the nth trajectory point.
[0111] It is understandable that after executing S405 or S406, the electronic device needs to continue to execute S402 until n+1=N, even if the target sliding bounding box encloses each trajectory point that needs to be enclosed in the trajectory to be optimized.
[0112] S407, determining the optimized trajectory corresponding to the trajectory to be optimized according to the optimized trajectory point.
[0113] Specifically, the electronic device generates an optimized trajectory corresponding to the trajectory to be optimized according to the optimized trajectory points and the uncompressed trajectory points.
[0114] In the method provided in this embodiment, the electronic device takes integer values for n in the range of x to N in turn, and executes the steps of making the target sliding bounding box surround the trajectory points of the trajectory to be optimized, and determining whether to compress the trajectory points in the target sliding bounding box in combination with the preset threshold condition and the target sliding bounding box after adding the trajectory points, thereby achieving segmentation and compression.
[0115] In addition, in the method of this embodiment, when the target sliding bounding box does not meet the preset threshold condition, the other trajectory points in the target sliding bounding box except the most recently added nth trajectory point are compressed. After obtaining the optimized trajectory point, the target sliding bounding box is cleared, and the diagonal coordinates of the target sliding bounding box are continued to be updated according to the coordinates of the nth trajectory point to obtain the updated target sliding bounding box, which can further confirm whether the nth trajectory point and the n+1th trajectory point can be compressed, thereby avoiding the situation of missed compression.
[0116] As an example, Figure 6A-6H An example diagram of a trajectory optimization process provided in an embodiment of the present application is shown in FIG. Fig. 6A As shown in , the blue line segment is used to represent the trajectory to be optimized, which contains 11 trajectory points. Initially, the sliding bounding box is empty. Figure 6B As shown in , if the processing starts from the second trajectory point, the second trajectory point is first added to the sliding bounding box, that is, the diagonal coordinates of the sliding bounding box are updated according to the coordinates of the second trajectory point, and the target sliding bounding box is obtained, that is, the axis-aligned bounding box shown in the red box in 6B. At this time, the sliding bounding box contains only one trajectory point, and the bounding box length and bounding box height of the sliding bounding box are both 0.
[0117] At this time, n is not equal to N-1, and the target sliding bounding box meets the preset threshold condition, so the third trajectory point is added to the target sliding bounding box, that is, the diagonal coordinates of the target sliding bounding box are updated according to the coordinates of the third trajectory point to obtain the updated target sliding bounding box, and n=n+1.
[0118] Specifically, if the coordinates of the third trajectory point are marked as P (X, Y), the coordinates of the lower left corner of the target sliding bounding box are marked as P0 (X0, Y0), and the coordinates of the upper right corner are marked as P1 (X1, Y1), then when X is less than X0, the value of X is assigned to X0, otherwise X0 remains unchanged. When X is greater than X1, the value of X is assigned to X1, otherwise X1 remains unchanged. When Y is less than Y0, the value of Y is assigned to Y0, otherwise Y0 remains unchanged. When Y is greater than Y1, the value of Y is assigned to Y1, otherwise Y1 remains unchanged. Based on this process, for Fig. 6A The trajectory to be optimized shown in the figure can finally make the target sliding bounding box contain the second and third trajectory points. At this time, the target sliding bounding box appears as an axis-aligned rectangle.
[0119] Furthermore, the electronic device calculates the size of the target sliding bounding box based on the diagonal coordinates of the target sliding bounding box and compares it with the preset distance. Specifically, the longer of the bounding box length and the bounding box height can be used as the target distance, that is, the target distance is expressed as max(X1-X0, Y1-Y0). Fig. 6AThe trajectory to be optimized shown is the output of a child locator, so the preset distance can be set to 25 meters. Based on this, if a child plays and stays in a 25-meter square range for a long time, the method of this application can compress the messy trajectory points within this range into one point.
[0120] In this example, the target distance of the target sliding bounding box does not exceed the preset distance at this time. Therefore, the 4th and 5th track points are added to the target sliding bounding box. At this time, the target distance of the target sliding bounding box does not exceed the preset distance. Specifically, the target sliding bounding box at this time is as follows Figure 6C shown.
[0121] In addition, since the current value of n has not yet reached N-1, if Fig.6D As shown in , the sixth track point is added to the target sliding bounding box, that is, the diagonal coordinates of the target sliding bounding box are updated according to the coordinates of the sixth track point. After calculation, the target distance of the target sliding bounding box with the sixth track point added exceeds the preset distance, so the other track points (the second track point, the third track point, the fourth track point, and the fifth track point) in the target sliding bounding box except the sixth track point are compressed to obtain the following: Fig. 6E The optimized trajectory points are shown.
[0122] Then, the diagonal coordinates of the target sliding bounding box are updated to the initial diagonal coordinates, and the current diagonal coordinates of the target sliding bounding box are updated according to the nth trajectory point, that is, the 6th point is re-added to the sliding bounding box to obtain the updated target sliding bounding box. On this basis, since the current value of n has not yet reached N-1, if Fig. 6F As shown, continue to add the 7th trajectory point into the target sliding bounding box.
[0123] After calculation, if Figure 6G As shown in , the target distance of the target sliding bounding box at this time exceeds the preset distance. Therefore, the 6th and 7th track points cannot be compressed. It is necessary to further determine whether the 7th and 8th track points can be compressed. The specific processing process can be found in the above content and will not be repeated here. Finally, when n is equal to N-1, it can be obtained as follows Figure 6H The optimized trajectory points shown are used to obtain the optimized trajectory.
[0124] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0125] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0126] The above embodiment introduces a trajectory optimization method from the perspective of method flow, and the following embodiment introduces a trajectory optimization device from the perspective of a virtual module or a virtual unit. Please refer to the following embodiment for details.
[0127] The present application embodiment provides a trajectory optimization device, Figure 7 A schematic diagram of the structure of a trajectory optimization device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the device comprises:
[0128] An updating module 71 is used to update the initial diagonal coordinates of the sliding bounding box according to the x-th trajectory point of the trajectory to be optimized, so as to obtain a target sliding bounding box; x is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty;
[0129] The optimization module 72 is used to compress the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and the preset threshold condition to obtain the optimized trajectory of the trajectory to be optimized; the preset threshold condition is used to control the size of the target sliding bounding box.
[0130] In another possible implementation of the embodiment of the present application, the optimization module 72 is specifically used to:
[0131] In the range of x to N, n is taken as integer values in turn, and the following steps are performed until n+1=N, and the optimized trajectory corresponding to the trajectory to be optimized is determined according to the optimized trajectory points; wherein N is the number of trajectory points contained in the trajectory to be optimized:
[0132] If the target sliding bounding box meets the preset threshold condition, the diagonal coordinates of the target sliding bounding box are updated according to the n+1th trajectory point to obtain an updated target sliding bounding box;
[0133] If the target sliding bounding box does not meet the preset threshold condition, the other track points in the target sliding bounding box except the nth track point are compressed to obtain the optimized track points. After the target sliding bounding box is cleared, the diagonal coordinates of the target sliding bounding box are updated according to the nth track point to obtain the updated target sliding bounding box.
[0134] In another possible implementation of the embodiment of the present application, the optimization module 72 is further configured to:
[0135] Determine the target distance of the target sliding bounding box according to the diagonal coordinates of the target sliding bounding box; the target distance includes at least one of the following: diagonal length, bounding box length, and bounding box height;
[0136] If the target distance is not greater than the preset distance, it is determined that the target sliding bounding box meets the preset threshold condition.
[0137] In another possible implementation manner of the embodiment of the present application, the optimization module 72 is further configured to:
[0138] If the target distance is greater than the preset distance, it is determined that the target sliding bounding box does not meet the preset threshold condition.
[0139] In another possible implementation of the embodiment of the present application, the diagonals of the target sliding bounding box include the lower left corner and the upper right corner; the optimization module 72 is specifically used for:
[0140] If the first horizontal axis coordinate corresponding to the n+1th trajectory point is smaller than the second horizontal axis coordinate of the lower left corner, the second horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the second horizontal axis coordinate remains unchanged;
[0141] If the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third horizontal axis coordinate of the upper right corner, the third horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the third horizontal axis coordinate remains unchanged;
[0142] If the first vertical axis coordinate corresponding to the n+1th trajectory point is smaller than the second vertical axis coordinate of the lower left corner, the second vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the second vertical axis coordinate remains unchanged;
[0143] If the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third vertical axis coordinate of the upper right corner, the third vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the third vertical axis coordinate remains unchanged.
[0144] In another possible implementation of the embodiment of the present application, the optimization module 72 is specifically used to:
[0145] Based on the coordinate data of other trajectory points, determine the target coordinate data corresponding to the center of gravity of other trajectory points;
[0146] Determine the optimized trajectory points corresponding to other trajectory points based on the target coordinate data.
[0147] In another possible implementation manner of the embodiment of the present application, the preset threshold condition is related to the user demand; the user demand is used to indicate the key points of the required trajectory.
[0148] Another possible implementation of the embodiment of the present application includes:
[0149] Determine the value of x based on user needs.
[0150] A trajectory optimization device provided in an embodiment of the present application is applicable to the above-mentioned method embodiment and will not be described in detail here.
[0151] An electronic device is provided in an embodiment of the present application. Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, Figure 8 The electronic device shown includes: a processor 81 and a memory 82. The processor 81 and the memory 82 are connected, such as through a bus 83. Optionally, the electronic device may further include a transceiver 84. It should be noted that in actual applications, the transceiver 84 is not limited to one, and the structure of the electronic device does not constitute a limitation on the embodiments of the present application.
[0152] The processor 81 may be a central processing unit (CPU), a general processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 81 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0153] The bus 83 may include a path to transmit information between the above components. The bus 83 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus 83 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Although only one thick line is used in the figure, it does not mean that there is only one bus 83 or only one type of bus 83.
[0154] The memory 82 can be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0155] The memory 82 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 81. The processor 81 is used to execute the application code stored in the memory 82 to implement the contents shown in the above method embodiment.
[0156] The present application also provides a computer-readable storage medium, which may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes. Specifically, the computer-readable storage medium stores program instructions, and the program instructions are used to implement the methods in the above-mentioned embodiments.
[0157] A computer program product is also provided in an embodiment of the present application, including a computer program. When the computer program is executed by a processor, the technical solution of the above-mentioned method embodiment is implemented. The implementation principle and technical effect are similar and will not be repeated here.
[0158] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.
[0159] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A trajectory optimization method, characterized in that: The method comprises: Update the initial diagonal coordinates of the sliding bounding box according to the xth trajectory point of the trajectory to be optimized to obtain a target sliding bounding box; x is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty; According to the target sliding bounding box and a preset threshold condition, the trajectory points included in the trajectory to be optimized are compressed to obtain an optimized trajectory of the trajectory to be optimized; the preset threshold condition is used to control the size of the target sliding bounding box.
2. The method according to claim 1, characterized in that The step of compressing the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and a preset threshold condition to obtain an optimized trajectory of the trajectory to be optimized includes: In the range of x to N, n is taken as integer values in sequence, and the following steps are performed until n+1=N, and the optimized trajectory corresponding to the trajectory to be optimized is determined according to the optimized trajectory points; wherein N is the number of trajectory points contained in the trajectory to be optimized: If the target sliding bounding box meets the preset threshold condition, the diagonal coordinates of the target sliding bounding box are updated according to the n+1th trajectory point to obtain an updated target sliding bounding box; If the target sliding bounding box does not meet the preset threshold condition, the other track points in the target sliding bounding box except the nth track point are compressed to obtain the optimized track point, and after the target sliding bounding box is cleared, the diagonal coordinates of the target sliding bounding box are updated according to the nth track point to obtain the updated target sliding bounding box.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: Determine the target distance of the target sliding bounding box according to the diagonal coordinates of the target sliding bounding box; the target distance includes at least one of the following: diagonal length, bounding box length, and bounding box height; If the target distance is not greater than the preset distance, it is determined that the target sliding bounding box meets the preset threshold condition.
4. The method according to claim 3, characterized in that The method further comprises: If the target distance is greater than the preset distance, it is determined that the target sliding bounding box does not meet the preset threshold condition.
5. The method according to claim 2, characterized in that: The diagonal coordinates of the target sliding bounding box include a lower left corner and an upper right corner; and updating the diagonal coordinates of the target sliding bounding box according to the n+1th trajectory point to obtain an updated target sliding bounding box includes: If the first horizontal axis coordinate corresponding to the n+1th trajectory point is smaller than the second horizontal axis coordinate of the lower left corner, the second horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the second horizontal axis coordinate remains unchanged; If the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third horizontal axis coordinate of the upper right corner, the third horizontal axis coordinate is updated to the first horizontal axis coordinate; otherwise, the third horizontal axis coordinate remains unchanged; If the first vertical axis coordinate corresponding to the n+1th trajectory point is smaller than the second vertical axis coordinate of the lower left corner, then the second vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the second vertical axis coordinate remains unchanged; If the first horizontal axis coordinate corresponding to the n+1th trajectory point is greater than the third vertical axis coordinate of the upper right corner, the third vertical axis coordinate is updated to the first vertical axis coordinate; otherwise, the third vertical axis coordinate remains unchanged.
6. The method according to claim 2, characterized in that The step of compressing the other trajectory points except the nth trajectory point in the target sliding bounding box to obtain the optimized trajectory point includes: Based on the coordinate data of the other trajectory points, determining the target coordinate data corresponding to the center of gravity of the other trajectory points; Determine the optimized trajectory points corresponding to the other trajectory points according to the target coordinate data.
7. The method according to claim 1 or 2, characterized in that: The preset threshold condition is related to user demand; the user demand is used to indicate the key points of the required trajectory.
8. The method according to claim 7, characterized in that The method further comprises: The value of x is determined according to the user's needs.
9. A trajectory optimization device, characterized in that: The device comprises: An updating module, used for updating the initial diagonal coordinates of the sliding bounding box according to the x-th trajectory point of the trajectory to be optimized, to obtain a target sliding bounding box; x is an integer greater than zero, the sliding bounding box is used to sequentially enclose the trajectory points of the trajectory to be optimized, and the initial diagonal coordinates are used to make the sliding bounding box empty; The optimization module is used to compress the trajectory points included in the trajectory to be optimized according to the target sliding bounding box and a preset threshold condition to obtain an optimized trajectory of the trajectory to be optimized; the preset threshold condition is used to control the size of the target sliding bounding box.
10. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 8.