Disclosure of Invention
The invention provides a data compression method and equipment applied to a vector space, which are used for solving the technical problems of complex algorithm and large calculation amount of the vector space data compression method in the prior art.
The embodiment of the invention provides a data compression method applied to a vector space, which comprises the following steps:
acquiring a point to be judged, and calculating to obtain a polar coordinate of the point to be judged according to the longitude and latitude coordinates of the point to be judged; the point to be judged is a vector space point on a vector space curve to be compressed;
calculating a polar coordinate difference value according to the polar coordinate of the point to be judged and the polar coordinate of the current characteristic point; the current characteristic point is a vector space point which is closest to the point to be determined on the vector space curve to be compressed and is reserved after compression processing;
calculating a characteristic value according to the polar coordinate difference value and a preset characteristic function;
and if the characteristic value is determined to be larger than a preset threshold value, taking the point to be determined as the current characteristic point, otherwise, removing the point to be determined from the vector space curve to be compressed.
Optionally, the obtaining a point to be determined includes:
according to the extending direction of the vector space curve to be compressed, vector space points except a starting point and an end point on the vector space curve to be compressed are sequentially used as the points to be determined;
after the point to be determined is taken as the current feature point, the method further comprises the following steps:
returning to the step of acquiring the points to be judged until all the points to be judged are processed;
and taking the vector space curve formed by the starting point and the end point of the vector space curve to be compressed and the reserved vector space point as the compressed vector space curve.
Optionally, the characteristic function is:
T=Δρ*sinΔθ
wherein, T is the characteristic value, Δ ρ is a difference between the polar diameter of the point to be determined and the polar diameter of the current characteristic point, and Δ θ is a difference between the polar angle of the point to be determined and the polar angle of the current characteristic point.
Optionally, the characteristic function is:
wherein, T is the characteristic value, Δ ρ 'is a value obtained by normalizing a polar diameter difference between the polar diameter of the point to be determined and the polar diameter of the current characteristic point, and Δ θ' is a value obtained by normalizing a polar angle difference between the polar angle of the point to be determined and the polar angle of the current characteristic point.
Based on the same inventive concept, the present invention provides a computing device, comprising:
the acquisition module is used for acquiring a point to be judged; the point to be judged is a vector space point on a vector space curve to be compressed;
the calculation module is used for calculating to obtain the polar coordinates of the point to be judged according to the longitude and latitude coordinates of the point to be judged; calculating a polar coordinate difference value according to the polar coordinate of the point to be judged and the polar coordinate of the current characteristic point; calculating a characteristic value according to the polar coordinate difference value and a preset characteristic function; the current characteristic point is a vector space point which is closest to the point to be determined on the vector space curve to be compressed and is reserved after compression processing;
and the processing module is used for taking the point to be determined as the current characteristic point if the characteristic value is determined to be larger than a preset threshold value, and otherwise, removing the point to be determined from the vector space curve to be compressed.
Optionally, the obtaining module is specifically configured to:
according to the extending direction of the vector space curve to be compressed, vector space points except a starting point and an end point on the vector space curve to be compressed are sequentially used as the points to be determined;
the processing module is further configured to:
returning to the step of acquiring the points to be judged until all the points to be judged are processed;
and taking the vector space curve formed by the starting point and the end point of the vector space curve to be compressed and the reserved vector space point as the compressed vector space curve.
Optionally, the characteristic function is:
T=Δρ*sinΔθ
wherein, T is the characteristic value, Δ ρ is a difference between the polar diameter of the point to be determined and the polar diameter of the current characteristic point, and Δ θ is a difference between the polar angle of the point to be determined and the polar angle of the current characteristic point.
Optionally, the characteristic function is:
wherein, T is the characteristic value, Δ ρ 'is a value obtained by normalizing a polar diameter difference between the polar diameter of the point to be determined and the polar diameter of the current characteristic point, and Δ θ' is a value obtained by normalizing a polar angle difference between the polar angle of the point to be determined and the polar angle of the current characteristic point.
Another embodiment of the present invention provides a computing device, which includes a memory for storing program instructions and a processor for calling the program instructions stored in the memory to execute any one of the above methods according to the obtained program.
Another embodiment of the present invention provides a computer storage medium having stored thereon computer-executable instructions for causing a computer to perform any one of the methods described above.
The data compression method applied to the vector space in the embodiment of the invention comprises the steps of obtaining a point to be judged; calculating to obtain the polar coordinates of the point to be judged according to the longitude and latitude coordinates of the point to be judged; calculating a polar coordinate difference value according to the polar coordinate of the point to be judged and the polar coordinate of the current characteristic point; calculating a characteristic value according to the polar coordinate difference value and a preset characteristic function; and if the characteristic value is determined to be larger than a preset threshold value, taking the point to be determined as the current characteristic point, otherwise, removing the point to be determined from the vector space curve to be compressed. Therefore, for each point to be judged on the vector space curve to be compressed, whether the point to be judged is reserved or not is judged only according to the characteristic value obtained by calculation of the polar coordinate difference between the point to be judged and the current characteristic point closest to the point to be judged, the algorithm is simple, and the time complexity and the space complexity are low, so that the calculated amount in the data compression processing process is greatly reduced. In addition, as other vector space points except the current characteristic point on the vector space curve to be compressed do not need to be involved in the calculation process of any point to be determined on the vector space curve to be compressed, the data compression method provided by the embodiment of the invention is not only suitable for a non-real-time operation scene in which all vector space points on the vector space curve to be compressed are obtained integrally and then processed, but also suitable for a real-time operation scene in which all vector space points on the vector space curve to be compressed are obtained and processed one by one.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiments of the present invention will be described in further detail with reference to the drawings attached hereto.
Fig. 1 shows a schematic flowchart corresponding to a data compression method applied to a vector space in an embodiment of the present invention, and as shown in fig. 1, the method includes:
s101, acquiring a point to be judged, and calculating to obtain a polar coordinate of the point to be judged according to the longitude and latitude coordinates of the point to be judged; the point to be judged is a vector space point on a vector space curve to be compressed;
step S102, calculating a polar coordinate difference value according to the polar coordinate of the point to be judged and the polar coordinate of the current characteristic point; the current characteristic point is a vector space point which is closest to the point to be determined on the vector space curve to be compressed and is reserved after compression processing;
step S103, calculating a characteristic value according to the polar coordinate difference value and a preset characteristic function;
and step S104, if the characteristic value is determined to be larger than a preset threshold value, taking the point to be determined as the current characteristic point, otherwise, removing the point to be determined from the vector space curve to be compressed.
Therefore, for each point to be judged on the vector space curve to be compressed, whether the point to be judged is reserved or not is judged only according to the characteristic value obtained by calculation of the polar coordinate difference between the point to be judged and the current characteristic point closest to the point to be judged, the algorithm is simple, and the time complexity and the space complexity are low, so that the calculated amount in the data compression processing process is greatly reduced. In addition, as other vector space points except the current characteristic point on the vector space curve to be compressed do not need to be involved in the calculation process of any point to be determined on the vector space curve to be compressed, the data compression method provided by the embodiment of the invention is not only suitable for a non-real-time operation scene in which all vector space points on the vector space curve to be compressed are obtained integrally and then processed, but also suitable for a real-time operation scene in which all vector space points on the vector space curve to be compressed are obtained and processed one by one.
The data compression method applied to the vector space in the embodiment of the present invention may be specifically executed by multiple types of computing devices with an operation function, for example, the data compression method may be implemented by a server-level computer, a desktop computer, a notebook computer, and various types of intelligent terminal devices (i.e., a mobile phone, a tablet computer, etc.), or may also be implemented by various types of embedded devices such as a car navigation device, and the like, which is not limited herein.
In the embodiment of the invention, the vector space curve to be compressed is composed of a plurality of continuous vector space points, wherein any vector space point on the curve corresponds to a longitude and latitude coordinate. According to different application scenes, the data of each vector space point in the vector space curve to be compressed can be acquired by different types of acquisition equipment and then sent to the computing equipment. Therefore, the computing device may store the data of all vector space points on the vector space curve to be compressed into the cache of the computing device after receiving the data, and then trigger to execute the above method flow, or may trigger to execute the above method flow immediately after receiving the data of the first vector space point (i.e., the starting point of the curve) on the vector space curve to be compressed sent by the acquisition device, which is not limited specifically here.
Specifically, in step S101, the computing device first acquires a point to be determined, which is a vector space point on a vector space curve to be compressed. And further, calculating to obtain the polar coordinates of the point to be judged according to the longitude and latitude coordinates of the point to be judged.
Taking the longitude and latitude coordinates of the point to be determined as pn={xn,ynFor example, the polar coordinates of the point to be determined are:
in step S102, the computing device first obtains a current feature point, where the current feature point is a vector space point on a vector space curve to be compressed, which is closest to a point to be determined and is reserved after compression processing, and then calculates a polar coordinate of the current feature point according to a longitude and latitude coordinate of the current feature point.
Similarly, if the longitude and latitude coordinate of the current feature point is pm={xm,ymFor example, the polar coordinates of the point to be determined are:
and then, calculating a polar coordinate difference value according to the polar coordinate of the point to be determined and the polar coordinate of the current characteristic point. If the polar coordinate of the point to be determined is p'n(ρn,θn) Polar coordinates of current feature point are p'm(ρm,θm) Then the polar difference is:
in step S103, the computing device substitutes the polar coordinate difference (i.e., the polar diameter difference and the polar angle difference) obtained in step S102 into the polar diameter and polar angle variables in the preset feature function, respectively, and computes a feature value.
It should be noted that, in the embodiment of the present invention, different feature functions may cause different convergence trends and sensitivities of different determination points, so that different compression effects may be achieved by selecting different feature functions, and a person skilled in the art may select a specific feature function according to actual needs, which is not limited specifically here.
The characteristic functions applicable to the embodiment of the present invention include, but are not limited to, the following two types: the characteristic function T ═ Δ ρ × sin Δ θ, characteristic function
Specifically, if the characteristic function is T ═ Δ ρ × sin Δ θ, the polar diameter difference and the polar angle difference in the polar coordinate difference may be substituted into the Δ ρ and Δ θ variables in the characteristic function, respectively. If the characteristic function is selected
Then, the polar diameter difference and the polar angle difference in the polar coordinate difference are subjected to dimensionless normalization processing respectively to obtain Δ ρ 'and Δ θ', and then are substituted into corresponding variables.
In step S104, if the computing device determines that the calculated feature value is greater than the preset threshold TtdAnd taking the point to be determined as the current characteristic point and reserving the point to be determined so as to execute subsequent processing. If the calculated characteristic value is less than the preset threshold value TtdAnd deleting the point to be determined from the vector space curve to be compressed.
In the embodiment of the invention, for the same characteristic function, different preset thresholds correspond to different compression ratios. Different feature functions are respectively corresponding to preset thresholds, and the preset thresholds corresponding to the different feature functions may have a large difference in numerical value or magnitude, so that a person skilled in the art specifically sets the preset thresholds according to the selected feature function and the required compression rate, and the setting is not specifically limited herein.
In the embodiment of the present invention, the steps S101 to S104 specifically describe a processing procedure of a point to be determined (i.e., a currently processed vector space point) on a spatial curve to be compressed, that is, after compression processing, the point to be determined is retained or deleted. If the feature value is calculated to determine that the point to be determined is reserved, the point to be determined is used as a new current feature point, that is, in the process of processing a certain vector space point after the determination point, if no other vector space point exists between the vector space point and the point to be determined, or other vector space points between the vector space point and the point to be determined are deleted, the point to be determined is used as the current feature point which is used as a comparison reference in step S102.
In an actual application scenario, the computing device defaults the start point and the end point on the vector space curve to be compressed as feature points to be reserved, and for other vector space points on the vector space curve to be compressed except the start point and the end point, the computing device sequentially takes the vector space points as the points to be determined in the above steps S101 to S104 according to the extending direction of the vector space curve to be compressed, and executes the above steps to determine whether the vector space points are reserved on the compressed vector space curve.
That is, after the computing device has finished processing a certain point to be determined by executing the above steps S101 to S104, it will return to step S101 to use the next vector space point that is continuous after the point to be determined as a new point to be determined, and execute the above steps S101 to S104 until all vector space points on the vector space curve to be compressed are processed in sequence, and further, the computing device will use the vector space curve formed by the start point and the end point of the vector space curve to be compressed and the remaining vector space points as the compressed vector space curve.
The data compression method in the embodiment of the invention is insensitive to historical data, when any vector space point on a vector space curve to be compressed is processed, only the data of the feature point closest to the vector space point is needed to be utilized, the data of other vector space points are not needed to be involved, and whether the vector space point is the feature point needing to be reserved can be determined only by calculating once, so that the time complexity and the space complexity are very low.
It should be emphasized that the data compression method in the embodiment of the present invention can be applied to both a non-real-time computing environment and a real-time computing environment. For example, in a real-time operation scenario, such as in an automotive GPS navigation application, each vector space point on a vector space curve to be compressed, which records an automobile driving track, is calculated in real time by a GPS satellite and sent to a navigation device, so that the navigation device also sends each data point to a computing device one by one during a process of acquiring data points in real time, and then the computing device sequentially compresses each data point received in real time. However, in the various data compression methods in the prior art, since calculation is required according to all data of the curve, the methods can only be applied in a non-real-time computing environment, that is, a compression process can only be triggered after all data on a vector space curve to be compressed are received.
Table 1 exemplarily shows time-consuming data obtained by compressing the same vector space curve to be compressed by using the douglas pock algorithm in the prior art and the data compression method in the embodiment of the present invention respectively under the condition of different compression rates.
Compression ratio
|
Time consuming of the Douglas pock algorithm(s)
|
Time consumption(s) of the data compression method in the embodiment of the present invention
|
49%
|
0.02
|
0.03
|
46%
|
0.03
|
0.03
|
40%
|
0.05
|
0.03
|
23%
|
0.27
|
0.03
|
17%
|
0.58
|
0.03
|
9%
|
1.30
|
0.03
|
6%
|
1.59
|
0.03
|
2%
|
4.17
|
0.03
|
1.50%
|
6.93
|
0.03
|
0.50%
|
13.56
|
0.03
|
0.30%
|
22.08
|
0.03 |
TABLE 1 time consuming comparison of data for Douglas Puck algorithm and data compression method of the present invention
It should be noted that the compression ratio in table 1 is inversely proportional to the compression degree, that is, the higher the compression ratio, the lower the compression degree, the greater the number of feature points retained on the vector space curve to be compressed, and vice versa.
Fig. 2 is a schematic diagram comparing compression time consumption plotted with a compression rate as an abscissa and time consumption as an ordinate according to the data in table 1, as can be seen from table 1 and fig. 2, when the compression rate is larger, the compression time consumption of the douglas-pock algorithm is still closer to that of the data compression method in the embodiment of the present invention, but as the compression rate is gradually reduced, the compression time consumption of the douglas-pock algorithm is significantly increased, while the compression time consumption of the data compression method in the embodiment of the present invention is still smaller and remains stable, and the data compression method in the embodiment of the present invention has the same compression speed under different compression rates.
In addition, the embodiment of the invention has high flexibility and sensitivity because various characteristic functions can be selected. Therefore, before the compression processing is carried out on the space curve to be compressed, the sensitivity judgment of the distribution of the characteristic points can be realized by adjusting the characteristic function and the threshold value when different application characteristics are applied, so that the compression precision is improved.
Based on the same inventive concept, an embodiment of the present invention further provides a computing device, fig. 3 is a schematic structural diagram of the computing device provided in the embodiment of the present invention, and as shown in fig. 3, the computing device 300 includes:
an obtaining module 301, configured to obtain a point to be determined; the point to be judged is a vector space point on a vector space curve to be compressed;
the calculating module 302 is configured to calculate a polar coordinate of the point to be determined according to the longitude and latitude coordinates of the point to be determined; calculating a polar coordinate difference value according to the polar coordinate of the point to be judged and the polar coordinate of the current characteristic point; calculating a characteristic value according to the polar coordinate difference value and a preset characteristic function; the current characteristic point is a vector space point which is closest to the point to be determined on the vector space curve to be compressed and is reserved after compression processing;
and the processing module 303 is configured to, if it is determined that the feature value is greater than a preset threshold, use the point to be determined as the current feature point, and otherwise remove the point to be determined from the vector space curve to be compressed.
Optionally, the obtaining module 301 is specifically configured to:
according to the extending direction of the vector space curve to be compressed, vector space points except a starting point and an end point on the vector space curve to be compressed are sequentially used as the points to be determined;
the processing module 303 is further configured to:
returning to the step of acquiring the points to be judged until all the points to be judged are processed;
and taking the vector space curve formed by the starting point and the end point of the vector space curve to be compressed and the reserved vector space point as the compressed vector space curve.
Optionally, the characteristic function is:
T=Δρ*sinΔθ
wherein, T is the characteristic value, Δ ρ is a difference between the polar diameter of the point to be determined and the polar diameter of the current characteristic point, and Δ θ is a difference between the polar angle of the point to be determined and the polar angle of the current characteristic point.
Optionally, the characteristic function is:
wherein, T is the characteristic value, Δ ρ 'is a value obtained by normalizing a polar diameter difference between the polar diameter of the point to be determined and the polar diameter of the current characteristic point, and Δ θ' is a value obtained by normalizing a polar angle difference between the polar angle of the point to be determined and the polar angle of the current characteristic point.
Based on the same inventive concept, the embodiment of the present invention further provides another computing device, which may specifically be a desktop computer, a portable computer, a smart phone, a tablet computer, a Personal Digital Assistant (PDA), and the like. The computing device may include a Central Processing Unit (CPU), memory, input/output devices, etc., the input devices may include a keyboard, mouse, touch screen, etc., and the output devices may include a Display device, such as a Liquid Crystal Display (LCD), a Cathode Ray Tube (CRT), etc.
The memory may include Read Only Memory (ROM) and Random Access Memory (RAM), and provides the processor with program instructions and data stored in the memory. In an embodiment of the present invention, the memory may be used to store a program of the above-described vector space-based data compression method.
The processor is used for executing the vector space-based data compression method according to the obtained program instructions by calling the program instructions stored in the memory.
Based on the same inventive concept, embodiments of the present invention provide a computer storage medium for storing computer program instructions for the above-mentioned computing device, which includes a program for executing the above-mentioned vector space-based data compression method.
The computer storage media may be any available media or data storage device that can be accessed by a computer, including, but not limited to, magnetic memory (e.g., floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc.), optical memory (e.g., CDs, DVDs, BDs, HVDs, etc.), and semiconductor memory (e.g., ROMs, EPROMs, EEPROMs, non-volatile memory (NAND FLASH), Solid State Disks (SSDs)), etc.
From the above, it can be seen that:
the data compression method applied to the vector space in the embodiment of the invention comprises the steps of obtaining a point to be judged; calculating to obtain the polar coordinates of the point to be judged according to the longitude and latitude coordinates of the point to be judged; calculating a polar coordinate difference value according to the polar coordinate of the point to be judged and the polar coordinate of the current characteristic point; calculating a characteristic value according to the polar coordinate difference value and a preset characteristic function; and if the characteristic value is determined to be larger than a preset threshold value, taking the point to be determined as the current characteristic point, otherwise, removing the point to be determined from the vector space curve to be compressed. Therefore, for each point to be judged on the vector space curve to be compressed, whether the point to be judged is reserved or not is judged only according to the characteristic value obtained by calculation of the polar coordinate difference between the point to be judged and the current characteristic point closest to the point to be judged, the algorithm is simple, and the time complexity and the space complexity are low, so that the calculated amount in the data compression processing process is greatly reduced. In addition, as other vector space points except the current characteristic point on the vector space curve to be compressed do not need to be involved in the calculation process of any point to be determined on the vector space curve to be compressed, the data compression method provided by the embodiment of the invention is not only suitable for a non-real-time operation scene in which all vector space points on the vector space curve to be compressed are obtained integrally and then processed, but also suitable for a real-time operation scene in which all vector space points on the vector space curve to be compressed are obtained and processed one by one.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart block or blocks and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.