Data Compression Method, Device, System and Storage Medium
By dynamically compressing the perceived data in a wireless sensor network and determining the compression length using preset scenarios and resolution thresholds, the high power consumption and inefficient transmission problems caused by sensor data redundancy are solved, and more efficient data transmission is achieved.
Patent Information
- Application Number
- CN202211564908.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2042-12-07
AI Technical Summary
There is a lot of redundancy in the data frequently sent by sensors in wireless sensor networks, which leads to an increase in the power consumption of nodes and affects the data transmission efficiency.
By obtaining the perceived data sequence of the preset scene, based on the preset resolution threshold of the perceived data sequence and the preset scene matching, the target compression length is dynamically determined, the perceived data is compressed, and the compressed sequence is obtained and sent.
It effectively reduces the power consumption of sensor transmission in wireless sensor networks, improves data transmission efficiency, and reduces the power consumption of cluster nodes.
Smart Images

Figure CN115941806B_ABST
Abstract
Description
Technical Field
[0001] This application relates to, but is not limited to, the field of data transmission, and in particular, to a data compression method, apparatus, system, and storage medium. Background Art
[0002] In the application process of a Wireless Sensor Network (WSN), sensors in the wireless sensor network frequently send data. There is a correlation in time among the data sent by the sensors, resulting in a large amount of redundancy among the data, and the amount of data sent is relatively large, increasing the power consumption of the nodes. Summary of the Invention
[0003] In view of this, embodiments of this application at least provide a data compression method, apparatus, system, and storage medium.
[0004] In a first aspect, an embodiment of this application provides a data compression method, and the method includes:
[0005] Obtain a sequence of sensed data of a preset scenario;
[0006] Based on the sequence of sensed data and a preset resolution threshold matching the preset scenario, determine a target compression length;
[0007] Based on the target compression length, compress each sensed data in the sequence of sensed data to obtain a compressed sequence;
[0008] Send the compressed sequence.
[0009] In a second aspect, an embodiment of this application provides a data compression method, and the method includes:
[0010] Receive a compressed sequence from a sending end; wherein, the compressed sequence is obtained by compressing a sequence of sensed data of a preset scenario based on a target compression length;
[0011] In the compressed sequence, parse a flag bit and a maximum sensed data of the parsed sequence;
[0012] Based on the flag bit, determine the target compression length of the compressed sequence and the data type of the preset scenario;
[0013] Based on the target compression length, determine each estimated value in the parsed sequence to obtain a sequence of estimated values;
[0014] Based on the data type and the maximum sensed data, recover the sequence of estimated values to obtain a sequence of sensed data corresponding to the sequence of estimated values.
[0015] In a third aspect, an embodiment of the present application provides a data compression device, where the data compression device includes:
[0016] A first acquisition module, configured to acquire a sequence of sensed data of a preset scenario;
[0017] A first determination module, configured to determine a target compression length based on the sequence of sensed data and a preset resolution threshold matching the preset scenario;
[0018] A first compression module, configured to compress each sensed data in the sequence of sensed data based on the target compression length to obtain a compressed sequence;
[0019] A first sending module, configured to send the compressed sequence.
[0020] In a fourth aspect, an embodiment of the present application provides a data compression device, where the data compression device includes:
[0021] A first receiving module, configured to receive a compressed sequence from a sending end; wherein, the compressed sequence is obtained by compressing a sequence of sensed data of a preset scenario based on a target compression length;
[0022] A first parsing module, configured to parse a flag bit and a maximum sensed data of the parsed sequence in the compressed sequence;
[0023] A second determination module, configured to determine a target compression length of the compressed sequence and a data type of the preset scenario based on the flag bit;
[0024] A third determination module, configured to determine each estimated value in the parsed sequence based on the target compression length to obtain an estimated value sequence;
[0025] A first recovery module, configured to recover the estimated value sequence based on the data type and the maximum sensed data to obtain a sequence of sensed data corresponding to the estimated value sequence.
[0026] In a fifth aspect, an embodiment of the present application provides a data compression system, where the data compression system includes a sending end and a receiving end; wherein, the sending end is configured to execute the method described in the first aspect above; the receiving end is configured to execute the method described in the second aspect above.
[0027] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented.
[0028] An embodiment of the present application provides a computer program, including computer-readable code. When the computer-readable code runs in a computer device, a processor in the computer device executes to implement some or all of the steps in the above method.
[0029] An embodiment of the present application provides a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, some or all of the steps in the above method are implemented.
[0030] In an embodiment of the present application, a sending end obtains a sequence of sensed data in a preset scenario, combines the preset scenario with a preset discrimination threshold and the sequence of sensed data to determine a target compression length for compressing the sequence of compressive sensed data. In this way, when the preset scenario or the sequence of sensed data is different, the determined target compression length will also be different, so that different sequences of sensed data can be compressed with different lengths, making the compression of the sequence of sensed data more targeted. Then, each sensed data in the sequence of sensed data is compressed according to the target compression length to obtain a compressed sequence, and the compressed sequence is sent to a receiving end. In this way, after obtaining the sequence of sensed data in the preset scenario, different target compression lengths are used to compress different sequences of sensed data, so that the obtained sequence of sensed data can be dynamically compressed and the compressed sequence can be sent to the receiving end, thereby reducing the power consumption of the acquisition sensors sent in the wireless sensor network, and reducing the power consumption of the cluster nodes at the sending end and improving the data transmission efficiency.
[0031] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and do not limit the technical solutions of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings herein are incorporated into the specification and form a part of this specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, are used to explain the technical solutions of the present application.
[0033] Figure 1 It is a schematic flowchart of the implementation of a data compression method provided by an embodiment of the present application;
[0034] Figure 2 It is another schematic flowchart of the implementation of a data compression method provided by an embodiment of the present application;
[0035] Figure 3 It is still another schematic flowchart of the implementation of a data compression method provided by an embodiment of the present application;
[0036] Figure 4Another schematic diagram of the implementation process of the data compression method provided by the embodiments of the present application;
[0037] Figure 5 Schematic diagram of the composition structure of a data compression device provided by the embodiments of the present application;
[0038] Figure 6 Schematic diagram of the composition structure of a data compression device provided by the embodiments of the present application;
[0039] Figure 7 Schematic diagram of a hardware entity of an electronic device for data compression in the embodiments of the present application. Detailed implementation manners
[0040] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be further elaborated in detail below in conjunction with the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.
[0041] In the following description, "some embodiments" are involved, which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0042] The terms "first / second / third" involved are only used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence when permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs. The terms used herein are only for the purpose of describing the present application and are not intended to limit the present application.
[0044] Before further elaborating on the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained first. The nouns and terms involved in the embodiments of the present application are applicable to the following explanations.
[0045] 1) A Wireless Sensor Network (WSN) is a distributed sensing network, and the terminals are sensors that can sense the monitoring area. The wireless sensor network sends the collected information to the gateway in a certain way to achieve the monitoring of the objects in the target area. A wireless sensor network is a wireless network composed of a large number of stationary or mobile sensors in an ad-hoc and multi-hop manner. The purpose is to collaboratively detect, process, and transmit the monitoring information of the sensed objects within the network coverage area and report it to the user.
[0046] 2) A sensor node is the basic functional unit of a wireless sensor network. The basic component modules of a sensor node include: a sensing unit, a processing unit, a communication unit, and a power supply part. The processor module is the core of the sensor node, responsible for device control, task allocation and scheduling, data integration and transmission, etc. of the entire node. In the embodiments of the present application, the sensor node can be the sending end that obtains the sensed data sequence.
[0047] Based on this, the embodiments of the present application provide a data compression method, which is applicable to a wireless sensor network. By dynamically compressing the obtained sensed data sequence and sending the compressed sensed data sequence to the receiving end, the power consumption of the collecting sensors in the wireless sensor network can be reduced, and the data transmission efficiency can be improved. In the embodiments of the present application, this data compression method can be executed by the processor of a computer device. Figure 1 The following is a schematic flowchart of the implementation of a data compression method provided by the embodiments of the present application. This method can be implemented by the sending end, as Figure 1 shown. This method includes the following steps S101 to step S104:
[0048] Step S101, obtain the sensed data sequence of a preset scenario.
[0049] Here, the preset scenario can be any type of scenario that requires data collection. For example, the scenario type of the preset scenario can be an agricultural scenario that needs to monitor the temperature or humidity in a vegetable greenhouse, an environmental protection scenario that needs to monitor air quality, a medical monitoring scenario that needs to measure the physical condition of a patient, an intelligent transportation scenario that needs to detect vehicle traffic, a logistics management scenario that needs to detect the number of items, etc.
[0050] In some possible implementation manners, the sending end collects data at different times for a preset scenario, first adjusts the data types of the collected data according to the data types in the preset scenario, and then optimizes the abnormal data in the adjusted data sequence to obtain the sensed data sequence. The sending end may be a sensor that collects data for the preset scenario, such as a temperature sensor, a humidity sensor, etc. In a specific example, if the preset scenario is an agricultural scenario, then the sensed data sequence is the temperature or humidity at different times; if the preset scenario is an environmental protection scenario, then the sensed data sequence may be the air quality at different times; if the preset scenario is a medical monitoring scenario, then the sensed data sequence is the parameters of the patient's physical condition at different times, such as blood glucose, blood pressure, etc. at different times; if the preset scenario is an intelligent transportation scenario, then the sensed data sequence is the number of passing vehicles at different times; if the preset scenario is a logistics management scenario, then the sensed data sequence is the number of items at different times. The sending end for obtaining the sensed data sequence may be a sensor that collects data in the preset scenario, such as a temperature sensor, a humidity sensor, etc.
[0051] Step S102: Determine a target compression length based on the sensed data sequence and a preset discrimination threshold matched with the preset scenario.
[0052] Here, the target compression length is the number of compression bits for each sensed data in the sensed data sequence at the sending end, and this target compression length represents the number of binary bits of each sensed data in the compressed sequence. For example, if the target compression length is 2, then each sensed data in the compressed sequence is represented by two bits; if the target compression length is 5, then each sensed data in the compressed sequence is represented by 5 bits.
[0053] In some possible implementation manners, in the process of obtaining the sensed data sequence, the mean value of the initial data sequence is calculated, and the error value between each initial sensed sequence in the initial data sequence and the mean value is further determined to obtain an error value sequence. Then, the maximum value in the error value sequence is compared with the preset discrimination threshold, and the target compression length is set according to the comparison result. In this way, the target compression length can be dynamically adjusted according to different sensed data sequences.
[0054] Step S103: Compress each sensed data in the sensed data sequence based on the target compression length to obtain a compressed sequence.
[0055] Here, the target compression length can represent the number of binary bits of the sensed data in the compressed sequence. By converting the difference between each sensed data in the sensed data sequence and the maximum sensed data into binary data with the number of bits being the target compression length, the compression of each sensed data in the sensed data sequence is achieved, and the compressed sequence is obtained.
[0056] In some possible implementation manners, through the target compression length, the difference between each sensed data in the sensed data sequence and the maximum sensed data is subjected to binary conversion. And according to the data type matched by the preset scenario and the flag bits set in the preset scenario in the compressed sequence, the flag bits, the binary form of the maximum sensed data, and the difference between each sensed data in binary form and the maximum sensed data are concatenated, and thus the compressed sequence can be obtained. In this way, for a sensed data sequence with a multi-byte data volume, the difference between each sensed data in the sensed data sequence and the maximum sensed data is compressed into binary data with the number of bits being the target compression length through the target compression length, so that the compressed sequence is represented by the binary data, and the data volume of the compressed sequence is smaller than the data volume of the sensed data sequence.
[0057] Step S104, send the compressed sequence.
[0058] Here, after the sensed data sequence is compressed at the sending end, the obtained compressed sequence is sent to the receiving end, so that the receiving end can parse the compressed sequence and recover the sensed data sequence.
[0059] In the embodiments of the present application, the sending end determines the target compression length for compressing the sensed data sequence through the preset resolution threshold matched by the preset scenario and the sensed data sequence; in this way, in the case of different preset scenarios or sensed data sequences, the determined target compression lengths are also different, so that different sensed data sequences can be compressed with different lengths, making the compression of the sensed data sequence more targeted. After obtaining the sensed data sequence of the preset scenario, for different sensed data sequences, different target compression lengths are used to compress the sensed data sequence, so that the obtained sensed data sequence can be dynamically compressed, and the compressed sequence is sent to the receiving end, thereby being able to reduce the power consumption of the acquisition sensor sent in the wireless sensor network, and being able to reduce the power consumption of the cluster nodes at the sending end and improve the data transmission efficiency.
[0060] In some embodiments, by replacing the outliers with the mean value of the sensed data sequence in the initial data sequence, a sensed data sequence with more accurate values can be obtained, that is, the above step S101 can be achieved through Figure 2 the steps shown as follows:
[0061] Step S201, perform perception data collection on the preset scenario to obtain an initial data sequence.
[0062] Here, the initial data sequence is obtained by collecting data through sensors and saving it according to the data type matched by the preset scenario. For example, if the preset scenario is an indoor scenario where temperature needs to be monitored, then the indoor temperature is collected by a temperature sensor at regular time intervals (for example, once every 5 minutes), so as to obtain temperature values at different times. The data type of this temperature value is the form of data output by the temperature sensor itself. For example, if the data output by the sensor has two decimal places, then the obtained temperature value also has two decimal places. However, in this preset scenario, for the convenience of temperature statistics, the data type matched by the preset scenario is to retain 1 decimal place. In this way, by rounding the obtained temperature value with two decimal places to retain 1 decimal place, the initial data sequence is obtained.
[0063] In some possible implementation manners, to make the initial data sequence better match the preset scenario, the collected data is adjusted according to the data type of the preset scenario, that is, the above step S201 can be implemented through the following steps S211 and S212 (not shown in the figure):
[0064] Step S211, perform perception data collection on the preset scenario to obtain a sampling data sequence.
[0065] Here, the sensors in the preset scenario are used to collect data in the preset scenario to obtain a sampling data sequence. That is, the sampling data sequence can be directly obtained by collecting data in the preset scenario through sensors, and the data type of the sampling data sequence is the data type of the output of the sensors. For example, if the data type of the sensor output is two decimal places, then the data type of the sampling perception data in this sampling data sequence is two decimal places.
[0066] Step S212, adjust the data type of the sampling data sequence to the data type matched by the preset scenario to obtain the initial data sequence.
[0067] Here, when processing data according to a preset scenario, the data type required for the data is determined, and the data type matching the preset scenario is determined. The data type is used to characterize the form of the data, and the data type includes: floating-point type or integer type, etc. In a specific example, if the preset scenario is a scenario that needs to monitor the indoor temperature, in order to improve the accuracy of temperature detection and reduce the computational amount of subsequent data processing, the data type matching the preset scenario is a temperature value with one decimal place. If the preset scenario is to monitor the number of items in a logistics station, then the data type matching the preset scenario is an integer type. By using the data type matching the preset scenario, the sampled perception data in the sampled data sequence is saved to obtain an initial data sequence. During the process of saving the sampled perception data, if the data type matching the preset scenario is a floating-point type with one decimal place, and the sampled data sequence is a two-decimal place number, then it can be saved by rounding, or it can also be saved by rounding up. In this way, by using the data type matching the preset scenario to save the sampled data sequence, the data type of the sampled data sequence meets the requirements of the preset scenario, so that the initial data sequence can be conveniently applied in the preset scenario.
[0068] Step S202, determine the mean value of the initial data sequence.
[0069] Here, by taking the average of each initial perception data in the initial data sequence, the mean value of the initial data sequence can be obtained.
[0070] Step S203, in the initial data sequence, determine the error value between each initial perception data and the mean value to obtain an error value sequence.
[0071] Here, in the initial data sequence, each initial perception data is subtracted from the mean value to obtain the error value of each initial perception data, thereby forming an error value sequence.
[0072] Step S204, in the error value sequence, determine the abnormal error value that is greater than the preset resolution threshold matching the preset scenario.
[0073] Here, the preset resolution threshold matching the preset scenario can be determined by the data type matching the preset scenario. The preset resolution threshold is used to characterize the minimum unit of the data type matching the preset scenario. For example, if the data type is a floating-point type with one decimal place reserved, then the preset resolution threshold is 0.1; if the data type is an integer type, then the preset resolution threshold is 1. In the error value sequence, the error values greater than the preset resolution threshold are screened out, indicating that the initial perception data corresponding to the error value differs greatly from the mean value and is not accurate enough. Therefore, this error value is used as the abnormal error value.
[0074] Step S205: In the initial data sequence, replace the initial sensed data corresponding to the abnormal error value with the mean value to obtain the sensed data sequence.
[0075] Here, for the initial sensed data corresponding to the abnormal error value, it indicates that this initial sensed data is an outlier in the initial data sequence. Therefore, to make the data in the sensed data sequence more accurate, the mean value is used to replace the initial sensed data corresponding to the abnormal error value.
[0076] In the embodiment of the present application, by collecting sensed data for a preset scenario and replacing the abnormal data with a large error value in the initial sensed data sequence with the mean value of the initial sensed data sequence, a sensed data sequence with more accurate and reasonable sensed data can be obtained.
[0077] In some embodiments, by determining the difference between the sensed data and the maximum sensed data and analyzing the relationship between the difference and the preset discrimination threshold, the target compression length is set. That is, the above step S103 can be implemented through Figure 3 the steps shown as follows:
[0078] Step S301: In the sensed data sequence, determine the difference between each sensed data and the maximum sensed data to obtain a sensed difference sequence.
[0079] Here, in the sensed data sequence, first determine the maximum sensed data, and then subtract each sensed data from the maximum sensed data to obtain the sensed difference corresponding to each sensed data, thereby obtaining the sensed difference sequence.
[0080] Step S302: Based on the sensed difference sequence and the preset discrimination threshold, determine the target compression length.
[0081] Here, the maximum perceived difference in the perceived difference sequence is compared with a preset resolution threshold, and the target compression length is set according to the comparison result. Different comparison results between the maximum perceived difference and the preset resolution threshold result in different set target compression lengths, so that different perceived data sequences can be dynamically compressed according to different target compression lengths. In some possible implementation manners, if the maximum perceived difference is less than the preset resolution threshold, the target compression length is set to 0, that is, when the maximum perceived difference in the perceived difference sequence is greater than or equal to 0 and less than the preset resolution threshold, the target compression length is determined to be 0. In this way, if the maximum perceived difference is greater than or equal to 0 and less than the preset resolution threshold, it indicates that the sizes of the perceived data at different times in the perceived data sequence are very close to the average value, and further indicates that the difference between the maximum perceived data and other perceived data in the perceived data sequence is extremely small. Based on this, the target compression length is set to 0. Therefore, other perceived data can be represented by a maximum perceived data, and there is no need to compress the perceived data sequence and transmit the entire perceived data sequence. Only the maximum perceived data can be transmitted, which can not only reduce the data volume of data transmission but also transmit accurate perceived data.
[0082] In the embodiments of the present application, after obtaining the perceived difference sequence between each perceived data and the maximum perceived data, the perceived difference sequence is combined with a preset resolution threshold to dynamically set the target compression length, so that the perceived data sequence can be more targeted compressed through the target compression length.
[0083] In some embodiments, if the maximum perceived difference in the perceived difference sequence is greater than or equal to the preset resolution threshold, the target compression length is determined according to the expression of the value range set by an unknown compression length and the maximum perceived difference, that is, the above step S302 can be implemented through the following steps S321 and S322 (not shown in the figure):
[0084] Step S321, when the maximum perceived difference in the perceived difference sequence is greater than or equal to the preset resolution threshold, an expression of the value range of the maximum perceived difference is determined by using an unknown compression length and the preset resolution threshold.
[0085] Here, when the maximum perceived difference in the perceived difference sequence is greater than or equal to the preset resolution threshold, the compression length is used as an unknown, and the unknown is combined with the preset resolution threshold to set an expression of the value range. The expression of the value range can include two formulas, one as the maximum value of the maximum perceived difference and the other as the minimum value of the maximum perceived difference. Both of these two formulas have only one unknown, that is, the unknown compression length.
[0086] In some possible implementation manners, by taking the unknown compression length as an unknown, setting a maximum boundary parameter and a minimum boundary parameter, and thus representing an expression of a value range through the maximum boundary parameter and the minimum boundary parameter, that is, the above step S321 can be implemented through the following process:
[0087] First step, when the maximum perceived difference is greater than or equal to the preset resolution threshold, based on the unknown compression length, the preset fixed value, and the preset resolution threshold, determine an expression of the minimum boundary of the maximum perceived difference.
[0088] Here, the preset fixed value can be 1. First, find the difference between the unknown compression length and the preset fixed value as the exponent with base 2; then, take the difference between this exponent and 1 as the numerator, and take the reciprocal of the preset resolution threshold (for example, if the preset resolution threshold is 0.1, the reciprocal of the preset resolution threshold is 10) as the denominator, and the quotient obtained is the expression of the minimum boundary.
[0089] Second step, based on the unknown compression length and the preset resolution threshold, determine an expression of the maximum boundary of the maximum perceived difference.
[0090] Here, first take the unknown compression length as the exponent with base 2; then, take the difference between this exponent and 1 as the numerator, and take the reciprocal of the preset resolution threshold (for example, if the preset resolution threshold is 0.1, the reciprocal of the preset resolution threshold is 10) as the denominator, and the quotient obtained is the expression of the maximum boundary.
[0091] Third step, use the expression of the maximum boundary and the expression of the minimum boundary to represent the expression of the value range.
[0092] Here, the expression of the maximum boundary represents the maximum value of the value range, that is, represents the maximum value of the maximum perceived difference; the expression of the minimum boundary represents the minimum value of the value range, that is, represents the minimum value of the maximum perceived difference. In this way, the range formed by the expression of the maximum boundary and the expression of the minimum boundary is the value range. Take the expression that the maximum perceived difference is greater than the expression of the minimum boundary and less than or equal to the expression of the maximum boundary as the expression of this value range. In this way, by the unknown compression length, the preset fixed value, and the preset resolution threshold, set the first boundary parameter and the second boundary parameter, and thus set the expression of this value range through the first boundary parameter and the second boundary parameter; in this way, there is only one unknown in the expression of this value range, that is, the unknown compression length, so that different values of the compression length can be accurately obtained through different maximum perceived differences, that is, obtain the dynamic target compression length.
[0093] Step S322: Based on the maximum perception difference and the expression of the value range, determine the value of the unknown compression length to obtain the target compression length.
[0094] Here, since the maximum perception difference is a known value, and there is only one unknown in the expression of the value range, that is, the unknown compression length. Therefore, substituting the specific value of the maximum perception difference into the expression with the unknown can obtain the value of the unknown compression length, that is, obtain the target compression length. In this way, by using the expression of the value range of the maximum error value set by the unknown compression length, since the maximum perception difference is known, combining this expression with the maximum perception difference can determine the value of the unknown compression length in this expression, that is, accurately obtain the target compression length.
[0095] In some embodiments, the compression of the perception data sequence is realized through a flag bit, the perception difference in binary form, and the maximum perception data to obtain a compressed sequence. That is, the above step S103 can be realized through Figure 4 the steps shown as follows:
[0096] Step S401: Based on the preset scenario and the target compression length, determine a flag bit that meets the preset number of bits.
[0097] Here, the preset number of bits can be defined by the developer. In the embodiments of the present application, the preset number of bits can be set to 8, that is, the flag bit is 8 bits. Different bits in the flag bit are set respectively through the scenario type (such as building scenario, agricultural scenario, medical scenario, etc.), data type of the preset scenario, and the target compression length. In some possible implementation manners, specific bits in the flag bit can be set through the preset scenario, other bits in the flag bit can be set through the target compression length, at least two consecutive bits in the flag bit can be set through the target compression length, for example, three consecutive bits in the flag bit are set. Bits other than the at least two consecutive bits in the flag bit are set through the scenario type and data type of the preset scenario.
[0098] In some embodiments, each bit in the flag bit is set through the target compression length and the preset scenario. That is, the above step S401 can be realized through the following steps S411 and S412 (not shown in the figure):
[0099] Step S411: Based on the preset scenario, determine the highest bit and the reserved bit of the flag bit according to the preset number of bits.
[0100] Here, the highest bit of the flag bit is determined according to the corresponding data type in the preset scenario and the preset bit position. For example, when the data type is integer, the highest bit is 0; when the data type is floating-point, the highest bit is 1. The reserved bit positions in the flag bit are set according to the scenario type of the preset scenario and the number of the preset bit positions. The reserved bit positions are used to represent the scenario type of the preset scenario, and can be at least two consecutive or non-consecutive bit positions in the flag bit. For example, the reserved bit positions are the three consecutive low bits in an 8-bit flag bit, or can be at least two non-consecutive bit positions at any positions. Different scenario types have different binary values of the reserved bit positions, that is, different scenario types are represented by the reserved bit positions with different values. For example, when the scenario type is an agricultural scenario, the reserved bit positions can take the value of 001; when the scenario type is a medical scenario, the reserved bit positions can take the value of 010; when the scenario type is a construction scenario, the reserved bit positions can take the value of 110, etc.
[0101] Step S412: Determine the adjustment bits in the flag bit except for the highest bit and the reserved bit positions based on the target compression length.
[0102] Here, the adjustment bits can be at least two consecutive bits in the flag bit. The flag bit includes: the highest bit, the reserved bit positions, and the adjustment bits. The value of the target compression length is represented by the bits in the flag bit except for the highest bit and the reserved bit positions. Since the value of the target compression length has been determined, the binary form of the target compression length, that is, the value of the adjustment bits, can be obtained by converting the data format of the value of the target compression length. In some possible implementation manners, if the reserved bit positions are the three consecutive low bits, that is, bit3 to bit0, then the binary value of the target compression length is represented by bit6 to bit4, that is, the adjustment bits. In this way, the highest bit and the reserved bit positions of the flag bit are set through the preset scenario, so that after receiving the compressed sequence, the receiving end can determine the preset scenario to which the compressed sequence belongs by parsing the flag bit; the adjustment bits in the flag bit are set through the target compression length; in this way, after receiving the compressed sequence, the receiving end can determine the target compression length according to the adjustment bits by parsing the flag bit, so that the compressed sequence can be quickly decompressed according to the target compression length.
[0103] Step S402: Determine the binary perception difference corresponding to each perception difference in the perception difference sequence of the perception data sequence based on the target compression length and the data type of the perception data sequence.
[0104] Here, the value of the target compression length can represent the number of binary bits. Each perception difference is converted into a binary perception difference according to the number of the binary bits and the data type of the perception data sequence.
[0105] In some embodiments, by representing the estimated value of each perceptual difference as a binary number according to the target compression length, the binary perceptual difference corresponding to each estimated value is obtained; that is, the above step S402 can be implemented by the following steps S421 to S423 (not shown in the figure):
[0106] Step S421, based on the data type of the perceptual data sequence, determine the multiple between data.
[0107] Here, the multiple between data represents the multiple between each perceptual difference and the corresponding estimated value. Take the reciprocal of the minimum unit of the data type as the multiple between data. For example, if the data type is a floating-point type with one decimal place reserved, then the minimum unit of the data type is 0.1, and the multiple between data is 10. If the data type is an integer type, then the minimum unit of the data type is 1, and the multiple between data is 1.
[0108] Step S422, based on the multiple between data and each perceptual difference, determine the estimated value of each perceptual difference to obtain an estimated value sequence.
[0109] Here, multiply each perceptual difference by the multiple between data to obtain the estimated value of the perceptual difference; for example, if the perceptual difference is 1.9 and the multiple between data is 10, then the estimated value corresponding to the perceptual difference is 19; thus, by determining the estimated value of each perceptual difference, the estimated value sequence corresponding to the perceptual difference sequence is obtained.
[0110] Step S423, with the target compression length as the number of binary bits, convert each estimated value in the estimated value sequence into a binary number that meets the number of binary bits to obtain the binary perceptual difference corresponding to each estimated value.
[0111] Here, take the value of the target compression length as the number of binary bits. For example, if the target compression length is 5, then a five-bit binary number is used to represent the estimated value to obtain the binary perceptual difference corresponding to the estimated value. Taking the above example, the perceptual difference is 1.9, the multiple between data is 10, the estimated value corresponding to the perceptual difference is 19, and the binary perceptual difference is 10011. Thus, through the data type of the perceptual data sequence, the estimated value of each perceptual data is determined, and with the target compression length as the number of binary bits, each estimated value is converted into a binary number with the number of binary bits. In this way, each estimated value is represented as a binary number with the number of binary bits equal to the target compression length. The data volume of this binary number is smaller than the corresponding perceptual data in the perceptual data sequence. Therefore, taking the obtained binary number as the binary perceptual difference corresponding to the estimated value can reduce the data volume of the compressed sequence, thereby reducing the power consumption of data transmission.
[0112] Step S403: Determine the compressed sequence based on the flag bit, the maximum sensed data in the sensed data sequence, and the binary sensed difference corresponding to each sensed difference.
[0113] Here, first, represent the maximum sensed data with the same number of binary bits as the flag bit to obtain the binary maximum sensed data. For example, if the flag bit has 8 bits, then use 8 - bit binary bits to represent the maximum sensed data. Then, connect the flag bit, the binary maximum sensed data, and the binary sensed difference corresponding to each sensed difference in sequence to form an array, obtaining the compressed sequence. That is, the form of the compressed sequence can be {flag bit, binary maximum sensed data, binary sensed difference corresponding to each sensed difference}.
[0114] In the embodiments of the present application, each bit in the flag bit is set through a preset scenario and a target compression length. In this way, the receiving end can determine the preset scenario and the target compression length by parsing the flag bit; and obtain the binary sensed difference corresponding to each sensed difference according to the target compression length and the data type of the sensed data sequence, and form the compressed sequence with the flag bit, the maximum sensed data in the sensed data sequence, and the binary sensed difference corresponding to each sensed difference. In this way, each sensed data is compressed into a binary sensed difference through the compression length, combined with the flag bit and the maximum sensed data, to form the compressed sequence, so that the data volume of the compressed sequence is significantly smaller than that of the sensed data sequence, thereby reducing data transmission and saving node power consumption.
[0115] The embodiments of the present application provide a data compression method, which is applied to the receiving end and can be implemented through the following steps:
[0116] The first step: Receive the compressed sequence from the sending end.
[0117] Here, the compressed sequence is obtained by compressing the sensed data sequence of the preset scenario based on the target compression length. The sending end is a device capable of decompressing the compressed sequence and processing the decompressed sensed data sequence. The sending end can be a device with data - processing capabilities such as a server, a laptop computer, a tablet computer, a desktop computer, a smart TV, a set - top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable game device), etc.
[0118] The second step: In the compressed sequence, parse the flag bit and the maximum sensed data of the parsed sequence.
[0119] Here, when the receiving end decompresses the compressed sequence, it can obtain the first 8 bits of the highest bit, that is, the flag bit, and the 8 bits adjacent to the first 8 bits, that is, the binary maximum sensed data.
[0120] In the third step, based on the flag bit, determine the target compression length of the compressed sequence and the data type of the preset scenario.
[0121] Here, since the highest bit in the flag bit represents the data type in the preset scenario, after the receiving end parses the compressed sequence, the data type of the preset scenario can be obtained through the highest bit in the flag bit. Since the adjustment bit in the flag bit is obtained by converting the target compression length into binary, after the receiving end parses the flag bit, by converting the binary value of the adjustment bit in the flag bit, the target compression length can be obtained.
[0122] In the fourth step, based on the target compression length, determine each estimated value in the parsed sequence to obtain an estimated value sequence.
[0123] Here, since the value of the target compression length represents the number of binary bits of the estimated value, after the compressed sequence is decompressed, the highest 8 bits are the flag bit, and the adjacent 8 bits are the maximum perceived data in binary; then, with the number of binary bits of the target compression length, the binary perceived difference corresponding to each estimated value can be obtained. By converting the binary perceived difference corresponding to each estimated value into a decimal value, each estimated value can be obtained.
[0124] In the fifth step, based on the data type and the maximum perceived data, recover the estimated value sequence to obtain the perceived data sequence corresponding to the estimated value sequence.
[0125] Here, since the estimated value is determined by the difference between the maximum perceived data and the perceived data, and the data type, for example, the difference between the maximum perceived data and the perceived data is divided by the minimum unit of the data type to obtain the estimated value. Therefore, by determining the data type in the flag bit, determining the maximum perceived data through the adjacent 8 bits of binary in the flag bit, and combining the obtained estimated value, the perceived data corresponding to the estimated value can be recovered, so as to determine the perceived data sequence corresponding to the estimated value sequence.
[0126] In the embodiment of the present application, after the receiving end decompresses the compressed sequence, according to the binary value in the flag bit, the data type, the maximum perceived data, and the target compression length are determined, so that the perceived data sequence can be quickly and accurately recovered; and since the compressed sequence is obtained by compressing the original perceived data sequence, the receiving end can reduce data reception and save power consumption.
[0127] Next, the application of the data compression method provided by the embodiment of the present application in an actual scenario will be described, taking a dynamic data compression applicable to a wireless sensor network as an example.
[0128] In some embodiments, the data compression method may be implemented through the following steps:
[0129] In the first step, after the sending end compresses the collected sensed data sequence, it sends it to the receiving end.
[0130] In some possible implementation manners, the above first step may be implemented through the following steps:
[0131] Step 1, the sending end node collects sensed data and constructs a sampled data sequence.
[0132] Here, the time series TS = {(t1, α1), (t2, α2), …, (t n , α n )}, where α i is the sensed data at time t i . n is the sequence length, t is the sampling time point, and α is the sensed data. In some possible implementation manners, the sensor samples temperature, etc., and obtains temperature data as the sensed data.
[0133] Step 2, calculate the average value error value δ i , if |δ i | > ε, regard α i as abnormal data, and use to replace α i in the sensed data sequence TS.
[0134] Here, calculate the average value of the sampled sensed data sequence Calculate the error value of each sampled data ε is the error threshold acceptable to the user. If |δ i | > ε, regard α i as abnormal data, and use to replace α i in TS.
[0135] Step 3, determine the maximum sensed data α max in the sensed data sequence TS, and the difference γ max between α i and α i .
[0136] Here, calculate the maximum sensed data α n in the sensed data sequence α1, α2, α3, …, α max = MAX{α1, α2, α3, …, α n}, and determine the sensed difference γ1 = α max - α1, γ2 = αmax -α2, …, γ n = α max -α n . In this way, the sensed data obtained from n samplings can be simplified to TS′ = {flag, α max , γ′1, γ′2, …, γ′ n}, where the high 8 bits (bit) in TS′ represent the flag bit, and the next 8 bits represent α max , γ′ i is the representation form of γ i in TS′.
[0137] Step 4: Calculate the target compression length p value. If p ≥ 1, go to Step 5; otherwise, go to Step 6.
[0138] In some possible implementation manners, by dynamically adjusting the target compression length p of γ i , the compression of the sensed data sequence can be achieved, and it can be realized through the following process:
[0139] The first case: First, if the precision of the sensed data collected has decimal places, the error resolution value τ = 0.1.
[0140] Secondly, if MAX{|γ i |} < τ, that is, the absolute error values of all sampling data are less than 0.1, p takes the minimum value of 0, that is, data fusion is not required, and the data sent is TS′ = {flag, α max}, greatly reducing data transmission and greatly saving node power consumption. Among them, the adjustment situation of the target compression length p value is as follows:
[0141] If 0 ≤ MAX{|γ i |} < 0.1, p takes the value of 0, that is, do not perform data fusion, and γ′ is not included in the sent TS′ i ;
[0142] If 0.1 ≤ MAX{|γ i |} ≤ 0.1, p takes the value of 1, that is, only 1 bit is used to represent γ i ′;
[0143] If 0.1 < MAX{|γ i |} ≤ 0.3, p takes the value of 2, that is, only 2 bits are used to represent γ i ′;
[0144] If 0.3 < MAX{|γ i |} ≤ 0.7, p takes the value of 3, that is, only 3 bits are used to represent γ i ′;
[0145] Finally, adjust the value of p according to MAX{|γ i |}, and the value of p can be calculated by formula (1) according to the above situation:
[0146] 0.(2 p-1 -1) < MAX{|γ i |} ≤ 0.(2 p -1) (1);
[0147] The second case: First, if the accuracy of the collected perception data has no decimal places, the error resolution value τ = 1.
[0148] Secondly, if MAX{|γ i |} < τ, that is, the absolute error values of all sampled data are less than 1, p takes the minimum value of 0, that is, data fusion is not required, and the data sent is TS′ = {flag, α max}, which greatly reduces data transmission and greatly saves node power consumption. Among them, the adjustment of the p value is as follows:
[0149] If 0 ≤ MAX{|γ i |} < 1, p takes the value of 0, that is, do not perform data fusion, and γ i ′ does not exist in the sent TS′;
[0150] If 1 ≤ MAX{|γ i |} ≤ 1, p takes the value of 1, that is, only 1 bit is used to represent γ i ′;
[0151] If 1 < MAX{|γ i |} ≤ 3, p takes the value of 2, that is, only 2 bits are used to represent γ i ′;
[0152] If 3 < MAX{|γ i |} ≤ 7, p takes the value of 3, that is, only 3 bits are used to represent γ i ′;
[0153] Finally, adjust the value of p according to MAX{|γ i |}, and the value of p can be calculated by formula (2) according to the above situation:
[0154] (2 p-1 -1) < MAX{|γ i |} ≤ (2 p -1) (2);
[0155] Step 5, if the bit 7 of flag is 1, then γ i ′ = γ i *10, TS′ = {flag, α max , γ1′, γ2′, …, γn '}, otherwise, γ i ' = γ i , TS' = {flag, α max , γ1, γ2, …, γ n}.
[0156] Step 6, when p = 0, TS' = {flag, α max}.
[0157] In some possible implementation manners, the highest bit 7 of flag being 0 indicates that γ i ' has no decimal places, that is, γ1', γ2', …, γ n ' are positive integers. The highest bit 7 of flag being 1 indicates that γ i ' has decimal places and only 1 decimal place. Bits 6 to 4 represent the error value γ i In the number of bits p represented by TS', for example, three bits of bit 6-bit 4, the value range is 0 to 7. For example, 000 represents p = 0, 001 represents p = 1, ···, 111 represents p = 7. That is, γ can be represented by 0 to 7 digits in TS' i ; bits 3-bit 0 are reserved bits. The 8 bits immediately following flag are used to represent α max , with a valid range of 0 to 255; γ i is represented by p bits, and p can be set according to the specific actual application scenario.
[0158] For example: If bit 7 of flag is 1 and the value of bit 6-bit 4 is p, that is, p bits form a γ i data , accurate to 1 decimal place, γ i ' = γ i * 10, p bits form a γ i ', and the minimum error value is 0.1; if bit 7 of flag is 0 and the value of bit 6-bit 4 is p, that is, p bits form a γ i data. γ i ∈ [0, (2 p - 1)], γ i ' = γ i , p bits form a γ i ', and the minimum error value is 1. In this way, for data of x byte size, x ≥ 10, the data volume is bits, in the embodiments of the present application, this data can be represented by 16 + px bits. In this way, the compression ratio can reach p ∈ [0, 7]. In the embodiments of the present application, by dynamically adjusting the target compression length p, the data to be sent can be fused, reducing data transmission and node power consumption.
[0159] In the second step, the receiving end processes the received compressed sequence.
[0160] Here, after receiving the compressed sequence, first read the 8-bit flag, then analyze the flag, and restore the TS′ sequence to the original value according to the values of each bit in the flag.
[0161] In some possible implementation manners, the above second step can be implemented through the following steps:
[0162] Step 1: Take out the flag of the first 8 bits of the received data. The values of bit6-bit4 are p. Take out the 8-bit data α after the flag. max .
[0163] Step 2: If p≥1, go to Step 3; otherwise, go to Step 7.
[0164] Step 3: Take values respectively according to p bits, which are the estimated value sequences γ1′, γ2′, …, γ′.
[0165] Step 4: If bit7 of the flag is 1, go to Step 5; otherwise, go to Step 6.
[0166] Step 5: Calculate the original sensed data: Then {α1′, α2′, …, α n ′} is the original sensed data collected by the sensor.
[0167] For example, if bit7 of the flag is 1, the values of bit6 to bit4 are p, that is, γ i ′ is composed of p bits. Take out the 8-bit data α after the flag. max , and then take values respectively according to p bits, which are the estimated value sequences γ1′, γ2′, …, γ′. Then
[0168] Step 6: Calculate the original sensed data: α1′ = α max - γ1′, α2′ = α max - γ2′, ···, α n ′ = α max - γ n ′. Then
[0169] Here, if bit7 of the flag is 0; the values of bit6 to bit4 are p, that is, γ i ′ is composed of p bits. Take out the 8-bit data α after the flag. max , and then take values respectively according to p bits, which are the estimated value sequences γ1′, γ2′, …, γ′. Then α1′ = αmax -γ1′, α2′ = α max -γ2′, ···, α n ′ = α max -γ n ′.
[0170] Step 7. When p = 0, that is, there is no compressed data, and the original data is n αs max .
[0171] In the embodiments of the present application, in the case where the fluctuation range of the sensed data is relatively small, the sensed data is dynamically compressed by dynamically adjusting the data compression ratio, and the compression ratio is large, which can reduce data transmission and save node power consumption; in addition, the cluster node can reduce data reception and save power consumption, and the terminal device can restore the original data collected by the sampling node and adjust the data accuracy for different test environments and test objects.
[0172] Based on the foregoing embodiments, the embodiments of the present application provide a data compression device, which includes each unit included and each module included in each unit, and can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0173] The embodiments of the present application provide a data compression device, Figure 5 is a schematic structural diagram of a data compression device provided by the embodiments of the present application. As Figure 5 shown, the data compression device 500 includes:
[0174] A first acquisition module 501, configured to acquire a sensed data sequence of a preset scenario;
[0175] A first determination module 502, configured to determine a target compression length based on the sensed data sequence and a preset resolution threshold matching the preset scenario;
[0176] A first compression module 503, configured to compress each sensed data in the sensed data sequence based on the target compression length to obtain a compressed sequence;
[0177] A first sending module 504, configured to send the compressed sequence.
[0178] In some embodiments, the first acquisition module 501 includes:
[0179] A first acquisition sub-module, configured to collect perception data of the preset scenario to obtain an initial data sequence;
[0180] A first determination sub-module, configured to determine the mean value of the initial data sequence;
[0181] A second determination sub-module, configured to determine, in the initial data sequence, an error value between each initial perception data and the mean value to obtain an error value sequence;
[0182] A third determination sub-module, configured to determine, in the error value sequence, an abnormal error value greater than a preset resolution threshold for matching the preset scenario;
[0183] A first replacement sub-module, configured to replace, in the initial data sequence, the initial perception data corresponding to the abnormal error value with the mean value to obtain the perception data sequence.
[0184] In some embodiments, the first acquisition sub-module includes:
[0185] A first acquisition unit, configured to collect perception data of the preset scenario to obtain a sampling data sequence;
[0186] A first adjustment unit, configured to adjust the data type of the sampling data sequence to a data type matching the preset scenario to obtain the initial data sequence.
[0187] In some embodiments, the first determination module 502 includes:
[0188] A fourth determination sub-module, configured to determine, in the perception data sequence, a difference between each perception data and the maximum perception data to obtain a perception difference sequence;
[0189] A fifth determination sub-module, configured to determine the target compression length based on the perception difference sequence and the preset resolution threshold.
[0190] In some embodiments, the fifth determination sub-module includes:
[0191] A first determination unit, configured to, when the maximum perception difference in the perception difference sequence is greater than or equal to the preset resolution threshold, use an unknown compression length and the preset resolution threshold to determine an expression for the value range of the maximum perception difference;
[0192] A second determination unit, configured to determine the value of the unknown compression length based on the maximum perception difference and the expression for the value range to obtain the target compression length.
[0193] In some embodiments, the first determination unit includes:
[0194] A first determination subunit, configured to, when the maximum perception difference is greater than or equal to the preset resolution threshold, determine an expression of the minimum boundary of the maximum perception difference based on the unknown compression length, the preset fixed value, and the preset resolution threshold;
[0195] A second determination subunit, configured to determine an expression of the maximum boundary of the maximum perception difference based on the unknown compression length and the preset resolution threshold;
[0196] A first representation subunit, configured to represent an expression of the value range by using the expression of the maximum boundary and the expression of the minimum boundary.
[0197] In some embodiments, the fifth determination sub-module is further configured to: when the maximum perception difference in the perception difference sequence is greater than or equal to 0 and less than the preset resolution threshold, determine that the target compression length is 0.
[0198] In some embodiments, the first compression module 503 includes:
[0199] A sixth determination sub-module, configured to determine a flag bit that meets the preset number of bits based on the preset scenario and the target compression length;
[0200] A seventh determination sub-module, configured to determine a binary perception difference corresponding to each perception difference in the perception difference sequence of the perception data sequence based on the target compression length and the data type of the perception data sequence;
[0201] An eighth determination sub-module, configured to determine the compressed sequence based on the flag bit, the maximum perception data in the perception data sequence, and the binary perception difference corresponding to each perception difference.
[0202] In some embodiments, the sixth determination sub-module includes:
[0203] A third determination unit, configured to determine the highest bit and the reserved bits of the flag bit according to the preset number of bits based on the preset scenario;
[0204] A fourth determination unit, configured to determine the adjustment bits of the flag bit except for the highest bit and the reserved bits based on the target compression length; wherein the flag bit includes: the highest bit, the reserved bits, and the adjustment bits.
[0205] In some embodiments, the seventh determination sub-module includes:
[0206] A fifth determination unit, configured to determine a multiple between data based on the data type of the perception data sequence; wherein, the multiple between data represents the multiple between each perception difference and the corresponding estimated value;
[0207] A sixth determination unit, configured to determine an estimated value of each perception difference based on the multiple between data and each perception difference, to obtain an estimated value sequence;
[0208] Using the target compression length as the number of binary bits, convert each estimated value in the estimated value sequence into a binary number that satisfies the number of binary bits, to obtain a binary perception difference corresponding to each estimated value.
[0209] Another data compression device is provided in an embodiment of the present application. Figure 6 It is a schematic structural diagram of a composition of a data compression device provided in an embodiment of the present application. As Figure 6 shown, the data compression device 600 includes: a first receiving module 601, configured to receive a compressed sequence from a sending end; wherein, the compressed sequence is obtained by compressing a perception data sequence of a preset scenario based on a target compression length; a first parsing module 602, configured to parse a flag bit and a maximum perception data of the parsed sequence in the compressed sequence; a second determination module 603, configured to determine the target compression length of the compressed sequence and the data type of the preset scenario based on the flag bit; a third determination module 604, configured to determine each estimated value in the parsed sequence based on the target compression length, to obtain an estimated value sequence; a first recovery module 605, configured to recover the estimated value sequence based on the data type and the maximum perception data, to obtain a perception data sequence corresponding to the estimated value sequence.
[0210] A data compression system is provided in an embodiment of the present application. The data compression system includes a sending end and a receiving end; wherein, the sending end is configured to execute the solutions corresponding to each module in the above data compression device 500; the receiving end is configured to execute the solutions corresponding to each module in the data compression device 600.
[0211] The description of the above device embodiments is similar to the description of the above method embodiments, and has beneficial effects similar to those of the method embodiments. In some embodiments, the functions or modules included in the device provided in the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments. For the technical details not disclosed in the device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
[0212] It should be noted that in the embodiments of the present application, if the above data compression method is implemented in the form of software functional modules and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the related technology, can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes such as USB flash drives, external hard drives, read-only memories (ROMs), magnetic disks, or optical discs. In this way, the embodiments of the present application are not limited to any specific hardware, software, or firmware, or any combination among hardware, software, and firmware.
[0213] The embodiments of the present application provide a computer device, including a memory and a processor. The memory stores a computer program that can run on the processor, and when the processor executes the program, it implements some or all of the steps in the above method.
[0214] The embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements some or all of the steps in the above method. The computer-readable storage medium can be transient or non-transient.
[0215] The embodiments of the present application provide a computer program, including computer-readable code. When the computer-readable code runs in a computer device, the processor in the computer device executes to implement some or all of the steps in the above method.
[0216] The embodiments of the present application provide a computer program product. The computer program product includes a non-transient computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above method. The computer program product can be specifically implemented in a manner of hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium. In other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0217] It should be noted here that: the descriptions of the above embodiments tend to emphasize the differences between the embodiments, and their similarities can be referred to each other. The descriptions of the above embodiments of the device, storage medium, computer program and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects to the method embodiments. For the technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of the present application, please refer to the descriptions of the method embodiments of the present application for understanding.
[0218] It should be noted that Figure 7 is a schematic diagram of a hardware entity of an electronic device for data compression in an embodiment of the present application. As Figure 7 shown, the hardware entity of the electronic device 700 includes: a processor 701, a communication interface 702, and a memory 703, where:
[0219] The processor 701 generally controls the overall operation of the computer device 700.
[0220] The communication interface 702 can enable the computer device to communicate with other terminals or servers through a network.
[0221] The memory 703 is configured to store instructions and applications executable by the processor 701, and can also cache data to be processed or already processed by the processor 701 and each module in the computer device 700 (for example, image data, audio data, voice communication data, and video communication data), and can be implemented by flash memory (FLASH) or random access memory (Random Access Memory, RAM). Data transmission can be performed between the processor 701, the communication interface 702, and the memory 703 through a bus 704.
[0222] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures, or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the "in one embodiment" or "in an embodiment" that appears throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial numbers of the above steps / processes does not mean the order of execution, and the order of execution of each step / process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. The serial numbers of the embodiments of the present application above are only for description and do not represent the advantages or disadvantages of the embodiments.
[0223] It should be noted that in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the process, method, article or device comprising such element.
[0224] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. Additionally, the couplings, direct couplings, or communication connections between the various components shown or discussed may be through some interfaces. The indirect couplings or communication connections of devices or units can be electrical, mechanical, or other forms.
[0225] The units described above as separate components may or may not be physically separated. The components shown as units may or may not be physical units. They can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0226] In addition, in each embodiment of this application, the various functional units can all be integrated in one processing unit, or each unit can be separately a unit alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.
[0227] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments. The foregoing storage medium includes various media that can store program codes, such as removable storage devices, read-only memory (ROM), magnetic disks, or optical discs.
[0228] Alternatively, if the above integrated units of the present application are implemented in the form of software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the related technology can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the various embodiments of the present application. The foregoing storage medium includes: various media that can store program codes, such as removable storage devices, ROMs, magnetic disks, or optical discs.
[0229] As described above, the above are only the implementation manners of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the present application.
Claims
1. A data compression method, characterized in that, The method includes: Obtaining a sequence of sensed data of a preset scenario; In the sequence of sensed data, determining the difference between each sensed data and the maximum sensed data to obtain a sequence of sensed differences; Based on the sequence of sensed differences and a preset resolution threshold matched with the preset scenario, determining a target compression length; Based on the target compression length, compressing each sensed data in the sequence of sensed data to obtain a compressed sequence; Sending the compressed sequence; Wherein, the determining the target compression length based on the sequence of sensed differences and a preset resolution threshold matched with the preset scenario includes: When the maximum sensed difference in the sequence of sensed differences is greater than or equal to 0 and less than the preset resolution threshold, determining the target compression length to be 0; When the maximum sensed difference is greater than or equal to the preset resolution threshold, based on an unknown compression length, a preset fixed value, and the preset resolution threshold, determining an expression for the minimum boundary of the maximum sensed difference; based on the unknown compression length and the preset resolution threshold, determining an expression for the maximum boundary of the maximum sensed difference; using the expression for the maximum boundary and the expression for the minimum boundary to determine an expression for the value range of the maximum sensed difference; based on the maximum sensed difference and the expression for the value range, determining the value of the unknown compression length to obtain the target compression length.
2. The method according to claim 1, characterized in that, The obtaining a sequence of sensed data of a preset scenario includes: Performing sensed data acquisition on the preset scenario to obtain an initial data sequence; Determining the mean value of the initial data sequence; In the initial data sequence, determining the error value between each initial sensed data and the mean value to obtain a sequence of error values; In the sequence of error values, determining abnormal error values greater than the preset resolution threshold matched with the preset scenario; In the initial data sequence, replacing the initial sensed data corresponding to the abnormal error values with the mean value to obtain the sequence of sensed data.
3. The method according to claim 2, characterized in that, The performing sensed data acquisition on the preset scenario to obtain an initial data sequence includes: Performing sensed data acquisition on the preset scenario to obtain a sampling data sequence; Adjusting the data type of the sampling data sequence to the data type matched with the preset scenario to obtain the initial data sequence.
4. The method according to any one of claims 1 to 3, characterized in that, The compressing each sensed data in the sequence of sensed data based on the target compression length to obtain a compressed sequence includes: Based on the preset scenario and the target compression length, determining a flag bit that meets a preset number of bits; Based on the target compression length and the data type of the sequence of sensed data, determining the binary sensed difference corresponding to each sensed difference in the sequence of sensed differences of the sequence of sensed data; Based on the flag bit, the maximum sensed data in the sequence of sensed data, and the binary sensed difference corresponding to each sensed difference, determining the compressed sequence.
5. The method according to claim 4, characterized in that, The determining a flag bit that meets a preset number of bits based on the preset scenario and the target compression length includes: Based on the preset scenario, determining the highest bit and the reserved bits of the flag bit according to the preset number of bits; Based on the target compression length, determine the adjustment bit positions in the flag bits except the highest bit and the reserved bit positions; wherein, the flag bits include: the highest bit, the reserved bit positions, and the adjustment bit positions.
6. The method according to claim 4, characterized in that, The determining the binary perceptual difference corresponding to each perceptual difference in the perceptual difference sequence of the perceptual data sequence based on the target compression length and the data type of the perceptual data sequence includes: Based on the data type of the perceptual data sequence, determine the multiple between data; wherein, the multiple between data represents the multiple between each perceptual difference and the corresponding estimated value; Based on the multiple between data and each perceptual difference, determine the estimated value of each perceptual difference to obtain an estimated value sequence; Using the target compression length as the number of binary bits, convert each estimated value in the estimated value sequence into a binary number that satisfies the number of binary bits to obtain the binary perceptual difference corresponding to each estimated value.
7. A data compression method, characterized in that, The method includes: Receiving a compressed sequence from a sending end; wherein, the compressed sequence is obtained by compressing the perceptual data sequence of a preset scenario based on a target compression length, and the target compression length is determined by the method described in Claim 1; In the compressed sequence, parse the flag bits and the maximum perceptual data of the parsed sequence; the parsed sequence is obtained by decompressing the compressed sequence; Based on the flag bits, determine the target compression length of the compressed sequence and the data type of the preset scenario; Based on the target compression length, determine each estimated value in the parsed sequence to obtain an estimated value sequence; Based on the data type and the maximum perceptual data, recover the estimated value sequence to obtain the perceptual data sequence corresponding to the estimated value sequence.
8. A data compression device, characterized in that, The data compression device includes: A first acquisition module, configured to acquire the perceptual data sequence of a preset scenario; A first determination module, configured to, in the perceptual data sequence, determine the difference between each perceptual data and the maximum perceptual data to obtain a perceptual difference sequence; and determine the target compression length based on the perceptual difference sequence and a preset resolution threshold matched with the preset scenario; A first compression module, configured to compress each perceptual data in the perceptual data sequence based on the target compression length to obtain a compressed sequence; A first sending module, configured to send the compressed sequence; The first determination module is specifically configured to determine that the target compression length is 0 when the maximum perception difference in the perception difference sequence is greater than or equal to 0 and less than the preset resolution threshold; when the maximum perception difference is greater than or equal to the preset resolution threshold, based on the unknown compression length, the preset fixed value, and the preset resolution threshold, determine an expression for the minimum boundary of the maximum perception difference; based on the unknown compression length and the preset resolution threshold, determine an expression for the maximum boundary of the maximum perception difference; use the expression for the maximum boundary and the expression for the minimum boundary to determine an expression for the value range of the maximum perception difference; based on the maximum perception difference and the expression for the value range, determine the value of the unknown compression length to obtain the target compression length.
9. A data compression device, characterized in that, The data compression device includes: A first receiving module, configured to receive a compressed sequence from a sending end; wherein, the compressed sequence is obtained by compressing a perception data sequence of a preset scenario based on a target compression length, and the target compression length is determined by the method described in claim 1. A first parsing module, configured to parse a flag bit and the maximum perception data of a parsed sequence in the compressed sequence; the parsed sequence is obtained by decompressing the compressed sequence. A second determination module, configured to determine the target compression length of the compressed sequence and the data type of the preset scenario based on the flag bit. A third determination module, configured to determine each estimated value in the parsed sequence based on the target compression length to obtain an estimated value sequence. A first recovery module, configured to recover the estimated value sequence based on the data type and the maximum perception data to obtain a perception data sequence corresponding to the estimated value sequence.
10. A data compression system, characterized in that, The data compression system includes a sending end and a receiving end; wherein, the sending end is configured to execute the method described in any one of claims 1 to 6 above; the receiving end is configured to execute the method described in claim 7 above.
11. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 6, or, when the computer program is executed by a processor, it implements the method described in claim 7.
Citation Information
Patent Citations
A data compression and storage processing device and method
CN109787638A
Data compression method and device, equipment and medium
CN114490547A