WO2020006753A1 - Data compression method and apparatus - Google Patents

Data compression method and apparatus Download PDF

Info

Publication number
WO2020006753A1
WO2020006753A1 PCT/CN2018/094835 CN2018094835W WO2020006753A1 WO 2020006753 A1 WO2020006753 A1 WO 2020006753A1 CN 2018094835 W CN2018094835 W CN 2018094835W WO 2020006753 A1 WO2020006753 A1 WO 2020006753A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
row
line
difference
compressed
Prior art date
Application number
PCT/CN2018/094835
Other languages
French (fr)
Chinese (zh)
Inventor
余常文
宋小福
Original Assignee
深圳市汇顶科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市汇顶科技股份有限公司 filed Critical 深圳市汇顶科技股份有限公司
Priority to PCT/CN2018/094835 priority Critical patent/WO2020006753A1/en
Priority to CN201880000946.4A priority patent/CN109074669A/en
Publication of WO2020006753A1 publication Critical patent/WO2020006753A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • G06T9/005Statistical coding, e.g. Huffman, run length coding

Definitions

  • the present application relates to the field of data processing technologies, and in particular, to a data compression method and device.
  • Run-length coding is suitable for situations where there are many repeated bits in the bit stream. For data with a large number of short run-lengths, space can only be saved if the run-length is greater than the length required for binary representation data.
  • the Huffman compression algorithm uses a binary description to replace each character. Its length is determined by the frequency of characters. The higher the frequency of characters, the shorter the encoding length. However, the Huffman compression algorithm requires character description tables and Huffman trees for decoding. When the amount of data is small and the data repetition rate is low, the algorithm performs poorly.
  • the LZW compression algorithm can effectively use the frequency of character frequency redundancy to compress, and adaptively generate a dictionary based on the content of the compressed data, but usually cannot effectively use the position redundancy.
  • the invention provides a data compression method and device, so as to realize the lossless compression processing of data with a small amount of data. After compression, the data length is significantly reduced, and the transmission time of compressed data is effectively shortened.
  • the present invention provides a data compression method, including:
  • performing the same bit compression processing or the segment compression processing on each row of data of the data frame includes:
  • a previous line of data is used as a reference line of an adjacent subsequent data line to perform a difference operation to obtain a difference data line, and the difference data line is subjected to the same-bit compression processing or segment compression processing.
  • performing the same-bit compression processing on the reference line includes:
  • the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
  • performing segment compression processing on the reference line includes:
  • the previous row of data is used as the reference row of the adjacent next row of data to perform the difference operation to obtain the difference data row, including:
  • the current line of data is the j + 1th line of data
  • the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , ..., A j + 1, n
  • the previous row of data of the current row of data is the j-th row of data
  • the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ;
  • j 1, 2, 3 ..., N-1
  • N is the total number of rows of the data frame;
  • performing the same-bit compression processing on the difference data line includes:
  • performing segment compression processing on the difference data line includes:
  • the present invention provides a data compression device, including:
  • a receiving module configured to receive a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data;
  • a compression module configured to perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data
  • a sending module configured to send the compressed data to an external terminal.
  • the compression module is specifically configured to:
  • a previous line of data is used as a reference line of an adjacent subsequent data line to perform a difference operation to obtain a difference data line, and the difference data line is subjected to the same-bit compression processing or segment compression processing.
  • performing the same-bit compression processing on the reference line includes:
  • the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
  • performing segment compression processing on the reference line includes:
  • the previous row of data is used as the reference row of the adjacent next row of data to perform the difference operation to obtain the difference data row, including:
  • the current line of data is the j + 1th line of data
  • the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , ..., A j + 1, n
  • the previous row of data of the current row of data is the j-th row of data
  • the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ;
  • j 1, 2, 3 ..., N-1
  • N is the total number of rows of the data frame;
  • performing the same-bit compression processing on the difference data line includes:
  • performing segment compression processing on the difference data line includes:
  • the present invention provides a data compression device, including:
  • a processor configured to execute the program stored in the memory, and when the program is executed, the processor is configured to execute the method according to any one of the first aspects.
  • the present invention provides a computer-readable storage medium storing instructions that, when run on a computer, cause the computer to execute the method of any of the first aspects.
  • the data compression method and device provided by the present invention receive a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data; each line of data in the data frame is subjected to the same bit compression processing or Segment compression processing to obtain compressed data; and send the compressed data to an external terminal.
  • lossless compression processing of data with a small amount of data is realized, and the length of the compressed data is significantly reduced, which effectively shortens the transmission time of the compressed data.
  • FIG. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • Embodiment 2 is a method flowchart of a data compression method provided by Embodiment 1 of the present invention
  • FIG. 3 is a flowchart of a method of step S102 in Embodiment 1 of the present invention.
  • FIG. 4 is a schematic structural diagram of compressing a reference line by using the same-bit compression processing method
  • FIG. 5 is a structural schematic diagram of compressing a reference row by using a segmented compression processing method
  • FIG. 6 is a schematic structural diagram of compressing a difference data line by using a segmented compression processing method
  • FIG. 7 is a schematic structural diagram of a data compression device according to a second embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a data compression device according to a third embodiment of the present invention.
  • Sensor refers to a device or device that senses various measured quantities and converts them into useful signals according to certain rules. Common sensors are: photoelectric sensors, piezoelectric sensors, piezoresistive sensors, electromagnetic sensors, pyroelectric sensors, optical fiber sensors, and so on.
  • a fingerprint sensor (also known as a fingerprint sensor) is a sensing device, which belongs to the optical fingerprint sensor and a semiconductor fingerprint sensor, and is a key device for automatic fingerprint collection.
  • Microcontroller Unit also known as Single Chip Microcomputer or Single Chip Microcomputer, is to reduce the frequency and specifications of the Central Processing Unit (CPU) appropriately and reduce the memory ( memory), counter (Timer), universal serial bus (USB), analog to digital conversion (A / D), universal asynchronous transceiver (Universal Receiver / Transmitter), programmable logic Peripheral interfaces such as controller (Programmable Logic Controller, PLC), and even the driving circuit of Liquid Crystal Display (LCD) are integrated on a single chip to form a chip-level computer for different combinations of control for different applications.
  • CPU Central Processing Unit
  • memory memory
  • counter timer
  • USB universal serial bus
  • a / D analog to digital conversion
  • Universal Receiver / Transmitter Universal Receiver / Transmitter
  • programmable logic Peripheral interfaces such as controller (Programmable Logic Controller, PLC), and even the driving circuit of Liquid Crystal Display (LCD) are integrated on a single chip to form a chip-level computer for different combinations of
  • the data compression method provided by the present invention aims to solve the problems existing in the prior art.
  • the data compression method and system provided in the embodiments of the present application can be applied to electronic devices with sensors, such as smart phones, tablet computers, notebook computers, and other mobile terminals or electronic devices.
  • the above-mentioned sensors may include a fingerprint sensor.
  • the sensor may be a traditional capacitive fingerprint sensor provided on the front or back of the electronic device, or an under-screen fingerprint sensor such as an optical fingerprint sensor or an ultrasonic fingerprint sensor, which is provided below the display screen of the electronic device, which is not specifically limited in this application.
  • the data compression method and system provided in this application can also be applied to other data compression.
  • the compression of data collected by the fingerprint sensor is only a specific embodiment and should not be considered as a limitation of the application scenario of this application.
  • FIG. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • the electronic device may use an optical fingerprint sensor for user fingerprint collection and verification, and the optical fingerprint sensor may be disposed below a display screen. A partial area or an entire area, thereby forming an under-display optical fingerprint recognition system.
  • the electronic device can apply the data compression method provided by the embodiment of the present invention.
  • the electronic device 100 includes a display screen 120 and an optical fingerprint sensor 130, wherein the optical fingerprint sensor 130 is disposed in a part below the display screen 120. region.
  • the optical fingerprint sensor 130 includes a sensing array having a plurality of optical sensing units, and an area where the sensing array is located is a fingerprint detection area 103 of the optical fingerprint sensor 130.
  • the optical fingerprint sensor 130 may be attached to the lower surface of the display screen 120 or fixed under the display screen 120 by other means.
  • the optical fingerprint sensor 130 may be fixed under the display screen 120 through a mounting bracket, such as being mounted to a middle frame of the electronic device 100, and fixed to the display through the middle frame.
  • a mounting bracket such as being mounted to a middle frame of the electronic device 100, and fixed to the display through the middle frame.
  • Under the screen 120 so as to have a certain gap with the display screen 120, that is, it does not contact the lower surface of the display screen 120, so it is beneficial to be able to separate when the display screen 120 or the optical fingerprint sensor 130 is damaged Replace or repair damaged parts.
  • the fingerprint detection area may also be extended to other positions of the display area 102 or even the entire display screen 120 through optical design, and is not limited to the location where the optical fingerprint sensor 130 is located. position.
  • the optical fingerprint sensor 130 may be disposed in an edge region of the electronic device 100, that is, the optical fingerprint sensor 130 is not located or is only partially located within the display area 102, but the optical path design makes the optical fingerprint sensor 130
  • the fingerprint detection area 103 of the fingerprint sensor 130 still covers at least a part of the display area 102 of the display screen 120.
  • the fingerprint detection area 103 is located in the display area 102 of the display screen 120. Therefore, when the user needs to unlock the electronic device or perform other fingerprint verification, the user only Fingers need to be pressed on the fingerprint detection area 103 located on the display screen 120 to implement fingerprint input. Since fingerprint detection and fingerprint recognition can be implemented in the screen, the terminal device 100 adopting the above structure does not need a special reserved space on the front side to set fingerprint keys (such as the Home key), so that a full-screen solution can be adopted, that is, the display screen 120
  • the display area 102 can be substantially extended to the front of the entire electronic device 100.
  • the display screen 120 may be a display screen with a self-luminous display unit, such as an organic light emitting diode (OLED) display or a micro-light emitting diode (Micro-LED) display.
  • OLED organic light emitting diode
  • Micro-LED micro-light emitting diode
  • the optical fingerprint sensor 130 may use a display unit (ie, an OLED light source) of the display 120 located in the fingerprint detection area 103 as an excitation light source for optical fingerprint detection; however, it should be understood that The optical fingerprint sensor 130 may also be provided with an additional excitation light source (such as an infrared light source) for fingerprint detection and identification.
  • OLED organic light emitting diode
  • Micro-LED micro-light emitting diode
  • the sensing array of the optical fingerprint sensor 130 is specifically a photo detector (PD) array, which includes a plurality of photo detectors distributed in an array.
  • the photo detectors can be used as the optical sensors described above. unit.
  • the light emitted from the display unit of the fingerprint detection area 103 reflects and forms reflected light on the fingerprint of the finger surface, wherein the reflected light of the ridge and valley of the finger fingerprint is different
  • the reflected light is received from the display screen 120 and received by the light detector array and converted into a corresponding electrical signal, that is, a fingerprint detection signal. Based on the fingerprint detection signal, a fingerprint image of a user's finger can be obtained for fingerprint matching verification, thereby implementing an optical fingerprint recognition function in the electronic device 100.
  • the electronic device 100 further includes a transparent protective cover 110, which may be a glass cover or a sapphire cover, which is located above the display screen 120 and covers all The front of the terminal device 100 is described. Since the cover plate 110 covers the surface of the display screen 120, in the embodiment of the present application, the so-called finger pressing on the display screen 120 may actually refer to the cover plate 110 pressed above the display screen 120. Or, when a user attaches a protective layer on the surface of the cover 110, the so-called finger pressing on the display screen 120 may actually mean pressing the protective layer on the surface of the cover 110.
  • the optical fingerprint sensor 130 includes a light detection portion 134 and an optical component 132, wherein the light detection portion 134 may include the sensing array and the sensor array.
  • the readout circuit and other auxiliary circuits electrically connected to the array can be fabricated on a chip by a semiconductor process.
  • the optical component 132 may be disposed above the sensing array of the light detection portion 134, and may specifically include a light guide member, a filter layer, and other optical elements.
  • the light guiding component is mainly used for guiding the reflected light reflected from the finger surface to the sensing array for optical detection. For example, it may use a lens to focus the reflected light on the sensing of the light detecting part 134.
  • the filter layer may be used to filter out ambient light penetrating a finger to prevent the light detection portion 134 from being interfered by strong external light.
  • the filter layer may be an infrared filter layer to filter out sunlight. Or other wavelengths of the ambient light penetrating the finger and entering the light detection portion 134.
  • a circuit board 150 such as a flexible circuit board, may be provided below the optical fingerprint sensor 130.
  • the optical fingerprint sensor 130 may be electrically connected to other functional modules of the electronic device 100 through the circuit board 150 And signal transmission.
  • the display screen 120 may also be a non-self-illuminating display screen, such as a backlit liquid crystal display screen; in this case, the optical fingerprint sensor 130 cannot use the display screen 120
  • the display unit is used as an excitation light source. Therefore, an excitation light source can be integrated inside the optical fingerprint sensor 130 or an excitation light source can be set outside to implement optical fingerprint detection. The detection principle is consistent with the above description.
  • the optical fingerprint sensor 130 After the optical fingerprint sensor 130 obtains a fingerprint image, it needs to transmit the fingerprint image to a processing unit of the electronic device 100, such as a central processing unit (CPU) or an application processor (AP) for fingerprint matching verification. Therefore, it is generally necessary to compress the fingerprint image obtained by the optical fingerprint sensor 130 in the fingerprint module through a microprocessor (MCU), and then provide the data to the processing unit of the electronic device 100 for fingerprint matching identification and perform the matching based on the matching identification result
  • MCU microprocessor
  • Corresponding application operations such as device unlocking, mobile payment, system settings, or application installation / removal.
  • FIG. 2 is a method flowchart of a data compression method provided in Embodiment 1 of the present invention. As shown in FIG. 2, the method in this embodiment may include:
  • S101 Receive a data frame uploaded by a sensor within a preset period, where the data frame includes at least one line of data.
  • the execution subject of this embodiment may be a micro control unit MCU, a single-chip microcomputer, a micro processor, and other devices having data processing capabilities.
  • MCU micro control unit
  • a single-chip microcomputer a micro processor
  • other devices having data processing capabilities.
  • an MCU is used as an example for detailed description, but the specific device type for executing the method in this embodiment is not limited.
  • the MCU may be integrated with the sensor into a module, or may be an independent module electrically connected to the sensor.
  • the MCU receives the data frames uploaded by the sensor in a preset period (usually a collection period) (can be one frame or multiple frames, and the data processing method of multiple frames is similar to that of one frame); Include at least 1 row of data.
  • a preset period usually a collection period
  • the data format of the default data frame in this embodiment is stored on a row basis, and the amount of data contained in each row of data is not limited.
  • S102 Perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data.
  • the same-bit compression processing refers to setting the number of compressed bits of each data in each line of data to be the same, and performing compression processing on each line of data according to the number of compressed bits.
  • Segmented compression processing refers to dividing line data into two or more sections; setting the compression bit number of data in each section separately; compressing the data in the section according to the corresponding compression bit number , And the compression bit number of two adjacent sections is different.
  • FIG. 3 is a flowchart of a method of step S102 in Embodiment 1 of the present invention. As shown in FIG. 3, in an optional embodiment, step S102 may include:
  • the reference line includes n data, which are denoted as a 0 , a 1 , a 2 , ..., an n , a 0 is used as the basic data, and the value of a i minus a i-1 is used to replace the reference.
  • the data a i in the rows, to obtain the reference row after the difference operation, where i 1, 2, 3 ..., n.
  • Then determine the maximum value of the data other than the basic data in the reference row after the difference operation, and set the number of compressed bits according to the maximum value; Perform the same bit compression processing to obtain the compressed data corresponding to the reference line.
  • FIG. 4 is a schematic structural diagram of compressing a reference line by using the same bit compression processing method.
  • the reference line includes n data, which are denoted as a 0 , a 1 , a 2 , ..., an n , and are reserved.
  • the basic data a 0 is unchanged.
  • Replace the data a i in the reference line with the value of a i minus a i-1 , where i 1, 2, 3 ..., n; get the reference line after the difference operation, and record them separately.
  • a 0 , a 2 -a 1 , a 3 -a 2 , ..., an n -a n-1 are a 0 , a 2 -a 1 , a 3 -a 2 , ..., an n -a n-1 .
  • m_bit represents a value obtained by compressing m bits of data a 2 -a 1 , and other values are sequentially deduced by analogy, and the explanation is not repeated.
  • the basic data a 0 is not compressed. Assuming that the actual number of bits of the basic data a 0 is 12, it is stored in 2 Bytes.
  • the data compression information compressed by the same bit compression processing method is stored in the head (data header).
  • Head m indicates that the data is compressed by m bits.
  • the head m contains the minimum data value, the number of compressed bits, and the overall data length information. .
  • the value of m is determined based on the largest data in the reference row after the difference calculation.
  • the reference line includes n data, which are denoted as a 0 , a 1 , a 2 , ..., an n , a 0 is used as the basic data, and the value of a i minus a i-1 is used to replace the reference.
  • the data a i in the rows, to obtain the reference row after the difference operation, where i 1, 2, 3 ..., n.
  • the reference row after the difference operation is divided into two or more sections according to a preset rule; each section is set separately.
  • the number of compressed bits of the data; the data in the section is compressed according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; wherein the compressed bits of two adjacent sections are different.
  • FIG. 5 is a structural schematic diagram of compressing a reference line by using a segmented compression processing method.
  • the reference line includes n data, which are respectively denoted as a 0 , a 1 , a 2 , ..., an n , and are retained.
  • the same basic data a 0, a i by subtracting a i-1 data to the replacement reference value of a i in the row, calculating a difference obtained after the reference line, denoted as a 0, a 2 -a 1, a 3 -a 2 , ..., an n -a n-1 .
  • the reference row after the difference operation is divided into two or more sections according to a preset rule.
  • the first sector uses m bits to compress data
  • the second sector uses P bits to compress data.
  • the values of P and m are not equal.
  • p_bit represents a value obtained by compressing P bits of data a x + 1 -a x , and other values are deduced by analogy, and the explanation is not repeated.
  • the reference line after the difference calculation is divided into two or more sections according to a preset rule, and the number of bytes after compression needs to be reduced as much as possible.
  • the basic data a 0 is not compressed. Assuming that the actual number of bits of the basic data a 0 is 12, it is stored in 2 Bytes.
  • the data compression information compressed by the same bit compression processing method is stored in the head (data header).
  • Head m indicates that the data is compressed by m bits.
  • the head m contains the minimum data value, the number of compressed bits, and the overall data length information.
  • Head p indicates that P bits are used to compress the data. Head p contains the minimum value of the data, the number of compressed bits, and the overall length of the data.
  • the current row of data is the j + 1th row of data
  • the j + 1th row of data includes n data, which are respectively recorded as: a j + 1,0 , a j + 1 , 1 , and a j +1,2 , ..., a j + 1, n
  • the data in the previous row of the current row of data is the j-th row of data
  • the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ;
  • j 1 , 2 , 3 ..., N-1
  • N is the total number of rows of the data frame.
  • a maximum value in the data of the difference data line is first determined, and the number of compressed bits is set according to the maximum value; then, the difference data line is processed according to the number of compressed bits. Same bit compression processing to obtain compressed data corresponding to the difference data line.
  • the difference data line is divided into two or more sections according to a preset rule; the number of compressed bits of data in each section is set separately; according to the corresponding compressed bit The number of bits compresses the data in the segment to obtain the compressed data corresponding to the difference data line; wherein the number of compressed bits of two adjacent segments is different.
  • FIG. 6 is a schematic structural diagram of compressing a difference data line by using a segmented compression processing method.
  • head u_bit represents a data header of a sector with a compression bit number of u
  • head v_bit represents a compression bit number Is the data header of the section of v
  • d 1_u_bit represents the first difference data in the current collection line data is compressed by u bits
  • d x_u_bit represents the x-th difference data in the current collection line data.
  • u bit compressed value As shown in FIG. 6, head u_bit represents a data header of a sector with a compression bit number of u, and head v_bit represents a compression bit number Is the data header of the section of v
  • d 1_u_bit represents the first difference data in the current collection line data is compressed by u bits, and so on
  • d x_u_bit represents the x-th difference data in the current collection line data.
  • d x + 1_v_bit represents the value of the x + 1th difference data in the current collection line data after v bit compression
  • d y_v_bit represents the yth difference data in the previous collection line data after v bit compression Value.
  • the head u_bit is adjacent to the section corresponding to the head v_bit , so u and v have different values. Compress the data of each section in turn, and combine the compressed values of all the difference data of the current row data into byte / int / word and other data.
  • the MCU can send the compressed data to the external terminal in real time (that is, the compressed data is sent directly to the external terminal), or it can be sent to the external terminal at one time after all the data frames are compressed.
  • the external terminal may be a computer device, a portable device (such as a mobile phone, a tablet computer, a smart watch, etc.) having a data processing function.
  • a data frame uploaded by a sensor within a preset period is received, where the data frame includes at least one line of data; each line of data in the data frame is subjected to the same-bit compression processing or segment compression processing to obtain Compressing data; sending the compressed data to an external terminal.
  • FIG. 7 is a schematic structural diagram of a data compression apparatus according to Embodiment 2 of the present invention. As shown in FIG. 7, the apparatus in this embodiment may include:
  • the receiving module 10 is configured to receive a data frame uploaded by a sensor within a preset period, where the data frame includes at least one line of data;
  • a compression module 20 configured to perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data
  • the sending module 30 is configured to send the compressed data to an external terminal.
  • the compression module 30 is specifically configured to:
  • a previous line of data is used as a reference line of an adjacent subsequent data line to perform a difference operation to obtain a difference data line, and the difference data line is subjected to the same-bit compression processing or segment compression processing.
  • performing the same-bit compression processing on the reference line includes:
  • the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
  • performing segment compression processing on the reference line includes:
  • the previous row of data is used as the reference row of the adjacent next row of data to perform the difference operation to obtain the difference data row, including:
  • the current line of data is the j + 1th line of data
  • the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , ..., A j + 1, n
  • the previous row of data of the current row of data is the j-th row of data
  • the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ;
  • j 1, 2, 3 ..., N-1
  • N is the total number of rows of the data frame;
  • performing the same-bit compression processing on the difference data line includes:
  • performing segment compression processing on the difference data line includes:
  • the data compression apparatus in this embodiment may execute the method shown in FIG. 2.
  • FIG. 2 For specific implementation processes and technical principles, refer to related descriptions in the method shown in FIG. 2, and details are not described herein again.
  • FIG. 8 is a schematic structural diagram of a data compression device provided in Embodiment 3 of the present invention. As shown in FIG. 8, the data compression device 40 in this embodiment includes:
  • the processor 41 and the memory 42 are The processor 41 and the memory 42;
  • the memory 42 is configured to store executable instructions, and the memory may also be a flash (flash memory).
  • the processor 41 is configured to execute executable instructions stored in a memory to implement each step in the method according to the foregoing embodiment. For details, refer to related descriptions in the foregoing method embodiments.
  • the memory 42 may be independent or integrated with the processor 41.
  • the data compression device 40 may further include:
  • the bus 43 is configured to connect the memory 42 and the processor 41.
  • an embodiment of the present application further provides a computer-readable storage medium.
  • the computer-readable storage medium stores computer execution instructions.
  • the user equipment executes the foregoing various possibilities. Methods.
  • the computer-readable medium includes a computer storage medium and a communication medium, and the communication medium includes any medium that facilitates transfer of a computer program from one place to another.
  • a storage media may be any available media that can be accessed by a general purpose or special purpose computer.
  • An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium.
  • the storage medium may also be an integral part of the processor.
  • the processor and the storage medium may reside in an application-specific integrated circuit (ASIC).
  • ASIC application-specific integrated circuit
  • the application specific integrated circuit may be located in a user equipment.
  • the processor and the storage medium may also exist as discrete components in a communication device.
  • a person of ordinary skill in the art may understand that all or part of the steps of implementing the foregoing method embodiments may be implemented by a program instructing related hardware.
  • the aforementioned program may be stored in a computer-readable storage medium.
  • the steps including the foregoing method embodiments are executed; and the foregoing storage medium includes: a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, which can store program code. medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

Provided by the present invention are a data compression method and apparatus. The method comprises: receiving a data frame that is uploaded by a sensor within a preset period, the data frame comprising at least one line of data; performing bit-by-bit compression or segmentation compression on each line of data in the data frame to obtain compressed data; and sending the compressed data to an external terminal. Thus, the lossless compression of a small amount of data is achieved, and the length of the data after compression is obviously reduced, thus effectively reducing the transmission time of the compressed data.

Description

数据压缩方法和装置Data compression method and device 技术领域Technical field
本申请涉及数据处理技术领域,尤其涉及一种数据压缩方法和装置。The present application relates to the field of data processing technologies, and in particular, to a data compression method and device.
背景技术Background technique
随着信息技术的快速发展,数据量不断的增加,对数据的存储效率的需求也不断提高;为了节约存储成本,尽可能在有限的存储空间内存放较多的数据,通常会将数据压缩后进行存储,以减小数据占用的空间。With the rapid development of information technology, the amount of data continues to increase, and the demand for data storage efficiency continues to increase. In order to save storage costs, as much data as possible is stored in a limited storage space, and the data is usually compressed. Store to reduce the space occupied by the data.
目前,常见的压缩算法包括:游程编码(Run Length Encoding,RLE)、霍夫曼压缩(Huffman Coding)、LZW压缩(Lempel Ziv Welch,LZW)。游程编码适用于比特流中重复比特较多情形,对于含有大量短游程数据,只有在游程长度大于二进制表示数据所需长度时,才能节省空间。霍夫曼压缩算法使用二进制描述来替换每一个字符,其长度由字符出现的频率决定,频率出现越高的字符,编码长度越短。但是,霍夫曼压缩算法解码时,需要字符描述表和霍夫曼树,当数据量较小、数据重复率低时,该算法效果较差。LZW压缩算法能有效的利用字符出现频率冗余度进行压缩,且根据压缩数据内容,自适应地生成字典,但是通常不能有效地利用位置冗余度。At present, common compression algorithms include: Run Length Encoding (RLE), Huffman Coding, LZW Compression (Lempel Ziv Welch, LZW). Run-length coding is suitable for situations where there are many repeated bits in the bit stream. For data with a large number of short run-lengths, space can only be saved if the run-length is greater than the length required for binary representation data. The Huffman compression algorithm uses a binary description to replace each character. Its length is determined by the frequency of characters. The higher the frequency of characters, the shorter the encoding length. However, the Huffman compression algorithm requires character description tables and Huffman trees for decoding. When the amount of data is small and the data repetition rate is low, the algorithm performs poorly. The LZW compression algorithm can effectively use the frequency of character frequency redundancy to compress, and adaptively generate a dictionary based on the content of the compressed data, but usually cannot effectively use the position redundancy.
综上,现有上述压缩算法较为复杂,不适用于对数据量较小的数据进行无损压缩。In summary, the existing compression algorithms described above are relatively complicated and are not suitable for lossless compression of data with a small amount of data.
发明内容Summary of the invention
本发明提供一种数据压缩方法和装置,以实现对数据量较小的数据的无损压缩处理,压缩后数据长度明显减少,有效缩短压缩数据的传输时间。The invention provides a data compression method and device, so as to realize the lossless compression processing of data with a small amount of data. After compression, the data length is significantly reduced, and the transmission time of compressed data is effectively shortened.
第一方面,本发明提供一种数据压缩方法,包括:In a first aspect, the present invention provides a data compression method, including:
接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;Receiving a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data;
对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到 压缩数据;Performing the same-bit compression processing or segment compression processing on each row of data of the data frame to obtain compressed data;
将所述压缩数据发送给外部终端。Sending the compressed data to an external terminal.
可选地,对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,包括:Optionally, performing the same bit compression processing or the segment compression processing on each row of data of the data frame includes:
将所述数据帧的第一行数据作为基准行,对所述基准行进行同比特压缩处理或者分段压缩处理;Using the first line of data in the data frame as a reference line, and performing same-bit compression processing or segment compression processing on the reference line;
当数据帧包括2行及以上数据时;When the data frame includes 2 or more lines of data;
从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,对所述差值数据行进行同比特压缩处理或者分段压缩处理。Starting from the second line of data, a previous line of data is used as a reference line of an adjacent subsequent data line to perform a difference operation to obtain a difference data line, and the difference data line is subjected to the same-bit compression processing or segment compression processing.
可选地,对所述基准行进行同比特压缩处理,包括:Optionally, performing the same-bit compression processing on the reference line includes:
假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
确定差值运算后的基准行中除基础数据以外的数据中的最大值,按照所述最大值设置压缩比特位数;Determining the maximum value in the data other than the basic data in the reference row after the difference operation, and setting the number of compressed bits according to the maximum value;
按照所述压缩比特位数,对基准行中除基础数据以外的数据进行同比特压缩处理,得到基准行对应的压缩数据。According to the compression bit number, the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
可选地,对所述基准行进行分段压缩处理,包括:Optionally, performing segment compression processing on the reference line includes:
假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段;Divide the reference line after difference calculation into two or more sections according to the size of data other than the basic data in the reference line after difference calculation;
分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到基准行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each segment separately; compress the data in the segment according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; of which the compressed bits of two adjacent segments The number is different.
可选地,从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,包括:Optionally, starting from the second row of data, the previous row of data is used as the reference row of the adjacent next row of data to perform the difference operation to obtain the difference data row, including:
假设当前行数据为第j+1行数据,所述第j+1行数据包括n个数据,分别记为:a j+1,0、a j+1,1、a j+1,2、…、a j+1,n;当前行数据的前一行数据为第j行数据, 所述第j行数据包括n个数据,分别记为:a j,0、a j,1、a j,2、…、a j,n;其中j=1,2,3…,N-1;N为所述数据帧的总行数; Assume that the current line of data is the j + 1th line of data, and the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , …, A j + 1, n ; the previous row of data of the current row of data is the j-th row of data, and the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ; where j = 1, 2, 3 ..., N-1; N is the total number of rows of the data frame;
将第j+1行数据中的值减去第j行数据中对应的值,得到差值数据行,所述差值数据行记为:a j+1,0-a j,0、a j+1,1-a j,1、a j+1,2-a j,2、…、a j+1,n-a j,nSubtract the corresponding value in the jth row of data from the value in the j + 1th row of data to obtain a difference data row, where the difference data row is recorded as: a j + 1,0 -a j, 0 , a j +1,1 -a j, 1 , a j + 1,2 -a j, 2 , ..., a j + 1, n -a j, n .
可选地,对所述差值数据行进行同比特压缩处理,包括:Optionally, performing the same-bit compression processing on the difference data line includes:
确定所述差值数据行的数据中的最大值,根据所述最大值设置压缩比特位数;Determining a maximum value in the data of the difference data line, and setting the number of compressed bits according to the maximum value;
按照所述压缩比特位数,对所述差值数据行进行同比特压缩处理,得到所述差值数据行对应的压缩数据。Performing the same-bit compression processing on the difference data line according to the number of compressed bits, to obtain compressed data corresponding to the difference data line.
可选地,对所述差值数据行进行分段压缩处理,包括:Optionally, performing segment compression processing on the difference data line includes:
按照预设规则将所述差值数据行划分为2个或者2个以上的区段;Dividing the difference data line into two or more sections according to a preset rule;
分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到所述差值数据行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each section separately; compress the data in the section according to the corresponding number of compressed bits to obtain the compressed data corresponding to the difference data line; where two adjacent sections are compressed The number of compressed bits is different.
第二方面,本发明提供一种数据压缩装置,包括:In a second aspect, the present invention provides a data compression device, including:
接收模块,用于接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;A receiving module, configured to receive a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data;
压缩模块,用于对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据;A compression module, configured to perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data;
发送模块,用于将所述压缩数据发送给外部终端。A sending module, configured to send the compressed data to an external terminal.
可选地,所述压缩模块,具体用于:Optionally, the compression module is specifically configured to:
将所述数据帧的第一行数据作为基准行,对所述基准行进行同比特压缩处理或者分段压缩处理;Using the first line of data in the data frame as a reference line, and performing same-bit compression processing or segment compression processing on the reference line;
当数据帧包括2行及以上数据时;When the data frame includes 2 or more lines of data;
从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,对所述差值数据行进行同比特压缩处理或者分段压缩处理。Starting from the second line of data, a previous line of data is used as a reference line of an adjacent subsequent data line to perform a difference operation to obtain a difference data line, and the difference data line is subjected to the same-bit compression processing or segment compression processing.
可选地,对所述基准行进行同比特压缩处理,包括:Optionally, performing the same-bit compression processing on the reference line includes:
假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
确定差值运算后的基准行中除基础数据以外的数据中的最大值,按照所述最大值设置压缩比特位数;Determining the maximum value in the data other than the basic data in the reference row after the difference operation, and setting the number of compressed bits according to the maximum value;
按照所述压缩比特位数,对基准行中除基础数据以外的数据进行同比特压缩处理,得到基准行对应的压缩数据。According to the compression bit number, the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
可选地,对所述基准行进行分段压缩处理,包括:Optionally, performing segment compression processing on the reference line includes:
假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段;Divide the reference line after difference calculation into two or more sections according to the size of data other than the basic data in the reference line after difference calculation;
分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到基准行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each segment separately; compress the data in the segment according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; of which the compressed bits of two adjacent segments The number is different.
可选地,从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,包括:Optionally, starting from the second row of data, the previous row of data is used as the reference row of the adjacent next row of data to perform the difference operation to obtain the difference data row, including:
假设当前行数据为第j+1行数据,所述第j+1行数据包括n个数据,分别记为:a j+1,0、a j+1,1、a j+1,2、…、a j+1,n;当前行数据的前一行数据为第j行数据,所述第j行数据包括n个数据,分别记为:a j,0、a j,1、a j,2、…、a j,n;其中j=1,2,3…,N-1;N为所述数据帧的总行数; Assume that the current line of data is the j + 1th line of data, and the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , …, A j + 1, n ; the previous row of data of the current row of data is the j-th row of data, and the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ; where j = 1, 2, 3 ..., N-1; N is the total number of rows of the data frame;
将第j+1行数据中的值减去第j行数据中对应的值,得到差值数据行,所述差值数据行记为:a j+1,0-a j,0、a j+1,1-a j,1、a j+1,2-a j,2、…、a j+1,n-a j,nSubtract the corresponding value in the jth row of data from the value in the j + 1th row of data to obtain a difference data row, where the difference data row is recorded as: a j + 1,0 -a j, 0 , a j +1,1 -a j, 1 , a j + 1,2 -a j, 2 , ..., a j + 1, n -a j, n .
可选地,对所述差值数据行进行同比特压缩处理,包括:Optionally, performing the same-bit compression processing on the difference data line includes:
确定所述差值数据行的数据中的最大值,根据所述最大值设置压缩比特位数;Determining a maximum value in the data of the difference data line, and setting the number of compressed bits according to the maximum value;
按照所述压缩比特位数,对所述差值数据行进行同比特压缩处理,得到所述差值数据行对应的压缩数据。Performing the same-bit compression processing on the difference data line according to the number of compressed bits, to obtain compressed data corresponding to the difference data line.
可选地,对所述差值数据行进行分段压缩处理,包括:Optionally, performing segment compression processing on the difference data line includes:
按照预设规则将所述差值数据行划分为2个或者2个以上的区段;Dividing the difference data line into two or more sections according to a preset rule;
分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到所述差值数据行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each section separately; compress the data in the section according to the corresponding number of compressed bits to obtain the compressed data corresponding to the difference data line; where two adjacent sections are compressed The number of compressed bits is different.
第三方面,本发明提供一种数据压缩设备,包括:In a third aspect, the present invention provides a data compression device, including:
存储器,用于存储程序;Memory for storing programs;
处理器,用于执行所述存储器存储的所述程序,当所述程序被执行时,所述处理器用于执行第一方面中任一所述的方法。A processor, configured to execute the program stored in the memory, and when the program is executed, the processor is configured to execute the method according to any one of the first aspects.
第四方面,本发明提供一种计算机可读存储介质,存储有指令,当其在计算机上运行时,使得计算机执行第一方面中任一所述的方法。In a fourth aspect, the present invention provides a computer-readable storage medium storing instructions that, when run on a computer, cause the computer to execute the method of any of the first aspects.
本发明提供的数据压缩方法和装置,通过接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据;将所述压缩数据发送给外部终端。从而实现对数据量较小的数据的无损压缩处理,压缩后数据长度明显减少,有效缩短压缩数据的传输时间。The data compression method and device provided by the present invention receive a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data; each line of data in the data frame is subjected to the same bit compression processing or Segment compression processing to obtain compressed data; and send the compressed data to an external terminal. As a result, lossless compression processing of data with a small amount of data is realized, and the length of the compressed data is significantly reduced, which effectively shortens the transmission time of the compressed data.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without paying creative labor.
图1为本发明实施例提供的一电子设备的结构示意图;FIG. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
图2为本发明实施例一提供的数据压缩方法的方法流程图;2 is a method flowchart of a data compression method provided by Embodiment 1 of the present invention;
图3为本发明实施例一中步骤S102的方法流程图;3 is a flowchart of a method of step S102 in Embodiment 1 of the present invention;
图4为采用同比特压缩处理方式压缩基准行的结构示意图;FIG. 4 is a schematic structural diagram of compressing a reference line by using the same-bit compression processing method; FIG.
图5为采用分段压缩处理方式压缩基准行的结构示意图;FIG. 5 is a structural schematic diagram of compressing a reference row by using a segmented compression processing method; FIG.
图6为采用分段压缩处理方式压缩差值数据行的结构示意图;6 is a schematic structural diagram of compressing a difference data line by using a segmented compression processing method;
图7为本发明实施例二提供的数据压缩装置的结构示意图;FIG. 7 is a schematic structural diagram of a data compression device according to a second embodiment of the present invention; FIG.
图8为本发明实施例三提供的数据压缩设备的结构示意图。FIG. 8 is a schematic structural diagram of a data compression device according to a third embodiment of the present invention.
通过上述附图,已示出本公开明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本公开构思的范围,而是通过参考特定实施例为本领域技术人员说明本公开的概念。Through the above drawings, a clear embodiment of the present disclosure has been shown, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the concept of the present disclosure in any way, but rather to explain the concepts of the present disclosure to those skilled in the art by referring to specific embodiments.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part, but not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例,例如能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", and the like (if present) in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects without using Used to describe a specific order or sequence. It should be understood that the data used in this way are interchangeable under appropriate circumstances so that the embodiments of the invention described herein can be implemented in an order other than those illustrated or described herein, for example. Furthermore, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that contains a series of steps or units need not be limited to those explicitly listed Those steps or units may instead include other steps or units not explicitly listed or inherent to these processes, methods, products or equipment.
下面以具体地实施例对本发明的技术方案进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例不再赘述。The technical solutions of the present invention will be described in detail in the following specific examples. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
以下,对本申请中的部分用语进行解释说明,以便于本领域技术人员理解。In the following, some terms in this application are explained so as to facilitate understanding by those skilled in the art.
1)传感器(sensor),是指感受规定的被测量的各种量并按一定规律将其转换为有用信号的器件或装置。常见的传感器有:光电式传感器、压电传感器、压阻式传感器、电磁式传感器、热电式传感器、光导纤维传感器等。1) Sensor (sensor) refers to a device or device that senses various measured quantities and converts them into useful signals according to certain rules. Common sensors are: photoelectric sensors, piezoelectric sensors, piezoresistive sensors, electromagnetic sensors, pyroelectric sensors, optical fiber sensors, and so on.
2)指纹传感器(又称指纹Sensor),是一种传感装置,属于光学指纹传感器半导体指纹传感器一种,是实现指纹自动采集的关键器件。2) A fingerprint sensor (also known as a fingerprint sensor) is a sensing device, which belongs to the optical fingerprint sensor and a semiconductor fingerprint sensor, and is a key device for automatic fingerprint collection.
3)微控制单元(Microcontroller Unit,MCU),又称单片微型计算机(Single Chip Microcomputer)或者单片机,是把中央处理器(Central Process Unit,CPU)的频率与规格做适当缩减,并将内存(memory)、计数器(Timer)、通用串行总线(Universal Serial Bus,USB)、模拟数字转换(analog to digital converte,A/D)、通用异步收发传输器(Universal Asynchronous Receiver/Transmitter)、可编程逻辑控制器(Programmable Logic Controller,PLC)等周边接口,甚至液晶显示器(Liquid Crystal Display,LCD)的驱动电路都整合在单一芯片上,形成芯片级的计算机,为不同的应用场合做不同组合控制。3) Microcontroller Unit (MCU), also known as Single Chip Microcomputer or Single Chip Microcomputer, is to reduce the frequency and specifications of the Central Processing Unit (CPU) appropriately and reduce the memory ( memory), counter (Timer), universal serial bus (USB), analog to digital conversion (A / D), universal asynchronous transceiver (Universal Receiver / Transmitter), programmable logic Peripheral interfaces such as controller (Programmable Logic Controller, PLC), and even the driving circuit of Liquid Crystal Display (LCD) are integrated on a single chip to form a chip-level computer for different combinations of control for different applications.
当传感器采集的数据量增加时,需要传输给处理器(主机host)的数据量也会相应增加,此时若不对传感器采集的数据进行压缩处理,则会造成数据传输延时,影响整个系统的工作效率。由于传感器侧配备的微控制单元MCU的处理能力有限,而现有的压缩算法较为复杂,因此不适合在MCU中对数据量较小的数据进行无损压缩处理。When the amount of data collected by the sensor increases, the amount of data that needs to be transmitted to the processor (host) will increase accordingly. At this time, if the data collected by the sensor is not compressed, it will cause a delay in data transmission and affect the entire system. Work efficiency. Because the processing capacity of the MCU on the sensor side is limited, and the existing compression algorithm is more complicated, it is not suitable for lossless compression processing of data with a small amount of data in the MCU.
本发明提供的数据压缩方法,旨在解决现有技术中存在的问题。The data compression method provided by the present invention aims to solve the problems existing in the prior art.
下面以具体地实施例对本发明的技术方案以及本申请的技术方案如何解决上述技术问题进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。下面将结合附图,对本发明的实施例进行描述。The following specifically describes the technical solutions of the present invention and how the technical solutions of the present application solve the above technical problems with specific embodiments. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below with reference to the drawings.
本申请实施例提供的数据压缩方法和系统可以适用在具有传感器的电子设备,例如智能手机、平板电脑、笔记本电脑以及其他移动终端或者电子设备,具体地,上述传感器可以包括指纹传感器,所述指纹传感器可以是传统设置在电子设备正面或者背面的电容式指纹传感器,也可以设置在电子设备的显示屏下方的屏下指纹传感器,比如光学指纹传感器或者超声波指纹传感器,本申请对此并不作特殊限定。当然,本申请提供的数据压缩方法和系统也可以适用于其他数据的压缩,指纹传感器采集数据的压缩仅是一种具体实施例,不应当认为是本申请应用场景的限制。The data compression method and system provided in the embodiments of the present application can be applied to electronic devices with sensors, such as smart phones, tablet computers, notebook computers, and other mobile terminals or electronic devices. Specifically, the above-mentioned sensors may include a fingerprint sensor. The sensor may be a traditional capacitive fingerprint sensor provided on the front or back of the electronic device, or an under-screen fingerprint sensor such as an optical fingerprint sensor or an ultrasonic fingerprint sensor, which is provided below the display screen of the electronic device, which is not specifically limited in this application. . Of course, the data compression method and system provided in this application can also be applied to other data compression. The compression of data collected by the fingerprint sensor is only a specific embodiment and should not be considered as a limitation of the application scenario of this application.
图1为本发明实施例提供的一电子设备的结构示意图,如图1所示,所述电子设备可以采用光学指纹传感器进行用户指纹采集和验证,所述光学指纹传感器可以设置在显示屏下方的局部区域或者全部区域,从而形成屏下(Under-display)光学指纹识别系统。该电子设备可以应用本发明实施例提供的数据压缩方法,具体地,所述电子设备100包括显示屏120和光学指纹传感器130,其中所述光学指纹传感器130设置在所述显示屏120下方的局部区域。所述光学指纹传感器130包括具有多个光学感应单元的感应阵列,所述感应阵列所在区域为所述光学指纹传感器130的指纹检测区域103。FIG. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. As shown in FIG. 1, the electronic device may use an optical fingerprint sensor for user fingerprint collection and verification, and the optical fingerprint sensor may be disposed below a display screen. A partial area or an entire area, thereby forming an under-display optical fingerprint recognition system. The electronic device can apply the data compression method provided by the embodiment of the present invention. Specifically, the electronic device 100 includes a display screen 120 and an optical fingerprint sensor 130, wherein the optical fingerprint sensor 130 is disposed in a part below the display screen 120. region. The optical fingerprint sensor 130 includes a sensing array having a plurality of optical sensing units, and an area where the sensing array is located is a fingerprint detection area 103 of the optical fingerprint sensor 130.
其中,所述光学指纹传感器130可以贴附到所述显示屏120的下表面或者通过其他方式固定在所述显示屏120的下方。作为一种优选的实施方案,所述光学指纹传感器130可以通过安装架在所述显示屏120下方进行安装固定,比如安装到所述电子设备100的中框,并通过中框固定到所述显示屏120的下方,从而与所述显示屏120之间具有一定间隙,即不与所述显示屏120 的下表面接触,因此有利于在所述显示屏120或者光学指纹传感器130损坏时可以进行单独对损坏部件进行更换或者维修。The optical fingerprint sensor 130 may be attached to the lower surface of the display screen 120 or fixed under the display screen 120 by other means. As a preferred embodiment, the optical fingerprint sensor 130 may be fixed under the display screen 120 through a mounting bracket, such as being mounted to a middle frame of the electronic device 100, and fixed to the display through the middle frame. Under the screen 120 so as to have a certain gap with the display screen 120, that is, it does not contact the lower surface of the display screen 120, so it is beneficial to be able to separate when the display screen 120 or the optical fingerprint sensor 130 is damaged Replace or repair damaged parts.
不过应当理解,在其他替代实现方案中,所述指纹检测区域也可以通过光学设计扩展到所述显示区域102的其他位置甚至整个显示屏120,而并不局限在所述光学指纹传感器130所在的位置。或者,所述光学指纹传感器130可以设置在所述电子设备100的边缘区域,即所述光学指纹传感器130并不位于或者只是部分位于所述显示区域102之内,但通过光路设计使得所述光学指纹传感器130的指纹检测区域103仍至少覆盖所述显示屏120的部分显示区域102。However, it should be understood that, in other alternative implementations, the fingerprint detection area may also be extended to other positions of the display area 102 or even the entire display screen 120 through optical design, and is not limited to the location where the optical fingerprint sensor 130 is located. position. Alternatively, the optical fingerprint sensor 130 may be disposed in an edge region of the electronic device 100, that is, the optical fingerprint sensor 130 is not located or is only partially located within the display area 102, but the optical path design makes the optical fingerprint sensor 130 The fingerprint detection area 103 of the fingerprint sensor 130 still covers at least a part of the display area 102 of the display screen 120.
在如图1所示电子设备100中,所述指纹检测区域103位于所述显示屏120的显示区域102之中,因此,用户在需要对所述电子设备进行解锁或者其他指纹验证的时候,只需要将手指按压在位于所述显示屏120的指纹检测区域103,便可以实现指纹输入。由于指纹检测和指纹识别可以在屏内实现,因此采用上述结构的终端设备100无需其正面专门预留空间来设置指纹按键(比如Home键),从而可以采用全面屏方案,即所述显示屏120的显示区域102可以基本扩展到整个电子设备100的正面。In the electronic device 100 shown in FIG. 1, the fingerprint detection area 103 is located in the display area 102 of the display screen 120. Therefore, when the user needs to unlock the electronic device or perform other fingerprint verification, the user only Fingers need to be pressed on the fingerprint detection area 103 located on the display screen 120 to implement fingerprint input. Since fingerprint detection and fingerprint recognition can be implemented in the screen, the terminal device 100 adopting the above structure does not need a special reserved space on the front side to set fingerprint keys (such as the Home key), so that a full-screen solution can be adopted, that is, the display screen 120 The display area 102 can be substantially extended to the front of the entire electronic device 100.
作为一种优选的实施例中,所述显示屏120可以采用具有自发光显示单元的显示屏,比如有机发光二极管(OLED)显示屏或者微型发光二极管(Micro-LED)显示屏。以采用OLED显示屏为例,所述光学指纹传感器130可以利用所述显示屏120位于所述指纹检测区域103的显示单元(即OLED光源)来作为光学指纹检测的激励光源;不过应当理解,所述光学指纹传感器130也可以设置额外的激励光源(比如红外光源)来进行指纹检测和识别。并且,所述光学指纹传感器130的感应阵列具体为光探测器(Photo Detector,PD)阵列,其包括多个呈阵列式分布的光探测器,所述光探测器可以作为如上所述的光学感应单元。当手指按压在所述指纹检测区域103时,所述指纹检测区域103的显示单元发出的光线在手指表面的指纹发生反射并形成反射光,其中所述手指指纹的脊和谷的反射光是不同的,反射光从所述显示屏120并被所述光探测器阵列所接收并转换为相应的电信号,即指纹检测信号。基于所述指纹检测信号便可以得到用户手指的指纹图像,以进行指纹匹配验证,从而在所述电子设备100实现光学指纹识别功能。As a preferred embodiment, the display screen 120 may be a display screen with a self-luminous display unit, such as an organic light emitting diode (OLED) display or a micro-light emitting diode (Micro-LED) display. Taking an OLED display as an example, the optical fingerprint sensor 130 may use a display unit (ie, an OLED light source) of the display 120 located in the fingerprint detection area 103 as an excitation light source for optical fingerprint detection; however, it should be understood that The optical fingerprint sensor 130 may also be provided with an additional excitation light source (such as an infrared light source) for fingerprint detection and identification. In addition, the sensing array of the optical fingerprint sensor 130 is specifically a photo detector (PD) array, which includes a plurality of photo detectors distributed in an array. The photo detectors can be used as the optical sensors described above. unit. When a finger is pressed on the fingerprint detection area 103, the light emitted from the display unit of the fingerprint detection area 103 reflects and forms reflected light on the fingerprint of the finger surface, wherein the reflected light of the ridge and valley of the finger fingerprint is different The reflected light is received from the display screen 120 and received by the light detector array and converted into a corresponding electrical signal, that is, a fingerprint detection signal. Based on the fingerprint detection signal, a fingerprint image of a user's finger can be obtained for fingerprint matching verification, thereby implementing an optical fingerprint recognition function in the electronic device 100.
应当理解的是,在具体实现上,所述电子设备100还包括透明保护盖板 110,所述盖板110可以为玻璃盖板或者蓝宝石盖板,其位于所述显示屏120的上方并覆盖所述终端设备100的正面。由于所述盖板110覆盖在所述显示屏120的表面,因此本申请实施例中,所谓的手指按压在所述显示屏120实际上可以是指按压在所述显示屏120上方的盖板110,或者当用户在所述盖板110表面贴附有保护层时,所谓的手指按压在所述显示屏120实际上可以是指按压所述盖板110表面的保护层。It should be understood that, in specific implementation, the electronic device 100 further includes a transparent protective cover 110, which may be a glass cover or a sapphire cover, which is located above the display screen 120 and covers all The front of the terminal device 100 is described. Since the cover plate 110 covers the surface of the display screen 120, in the embodiment of the present application, the so-called finger pressing on the display screen 120 may actually refer to the cover plate 110 pressed above the display screen 120. Or, when a user attaches a protective layer on the surface of the cover 110, the so-called finger pressing on the display screen 120 may actually mean pressing the protective layer on the surface of the cover 110.
作为一种可选的实现方式,如图1所示,所述光学指纹传感器130包括光检测部分134和光学组件132,其中,所述光检测部分134可以包括所述感应阵列以及与所述感应阵列电性连接的读取电路及其他辅助电路,其可以在通过半导体工艺制作在一个芯片(Die)。所述光学组件132可以设置在所述光检测部分134的感应阵列的上方,其可以具体包括导光部件、滤光层(Filter)以及其他光学元件。所述导光部件主要用于从手指表面反射回来的反射光导引至所述感应阵列进行光学检测,比如,其可以采用透镜(Lens)来将反射光汇聚在所述光检测部分134的感应阵列或者采用准直器(Collimator)来限制所述感应阵列的各个光学感应单元只接收到来自其上方的手指部分的反射光。所述滤光层可以用于滤除穿透手指的环境光以避免所述光检测部分134受到外部强光干扰,比如,所述滤光层可以为红外滤光层,用来滤除太阳光或者其他环境光中穿透手指的进入所述光检测部分134的波段。另外,所述光学指纹传感器130下方还可以设置有电路板150,比如软性电路板,所述光学指纹传感器130可以通过所述电路板150与所述电子设备100的其他功能模块进行电性连接和信号传输。As an optional implementation manner, as shown in FIG. 1, the optical fingerprint sensor 130 includes a light detection portion 134 and an optical component 132, wherein the light detection portion 134 may include the sensing array and the sensor array. The readout circuit and other auxiliary circuits electrically connected to the array can be fabricated on a chip by a semiconductor process. The optical component 132 may be disposed above the sensing array of the light detection portion 134, and may specifically include a light guide member, a filter layer, and other optical elements. The light guiding component is mainly used for guiding the reflected light reflected from the finger surface to the sensing array for optical detection. For example, it may use a lens to focus the reflected light on the sensing of the light detecting part 134. An array or a collimator is used to limit each optical sensing unit of the sensing array to receive only the reflected light from the finger part above it. The filter layer may be used to filter out ambient light penetrating a finger to prevent the light detection portion 134 from being interfered by strong external light. For example, the filter layer may be an infrared filter layer to filter out sunlight. Or other wavelengths of the ambient light penetrating the finger and entering the light detection portion 134. In addition, a circuit board 150, such as a flexible circuit board, may be provided below the optical fingerprint sensor 130. The optical fingerprint sensor 130 may be electrically connected to other functional modules of the electronic device 100 through the circuit board 150 And signal transmission.
在其他替代实现方式中,所述显示屏120也可以采用非自发光的显示屏,比如采用背光的液晶显示屏;在这种情况下,所述光学指纹传感器130便无法采用所述显示屏120的显示单元作为激励光源,因此可以在所述光学指纹传感器130内部集成激励光源或者在其外部设置激励光源来实现光学指纹检测,其检测原理与上面描述内容是一致的。In other alternative implementations, the display screen 120 may also be a non-self-illuminating display screen, such as a backlit liquid crystal display screen; in this case, the optical fingerprint sensor 130 cannot use the display screen 120 The display unit is used as an excitation light source. Therefore, an excitation light source can be integrated inside the optical fingerprint sensor 130 or an excitation light source can be set outside to implement optical fingerprint detection. The detection principle is consistent with the above description.
所述光学指纹传感器130获取到指纹图像之后,需要把所述指纹图像传输给所述电子设备100的处理单元,比如中央处理器(CPU)或者应用处理器(AP)进行指纹匹配验证。因此,通常需要在指纹模组通过微处理器(MCU)将所述光学指纹传感器130获取的指纹图像进行数据压缩,然后再提供给电子设备100的处理单元进行指纹匹配识别并根据匹配识别结果进行相应的应 用操作,比如设备解锁、移动支付、系统设置或者应用安装/删除等。After the optical fingerprint sensor 130 obtains a fingerprint image, it needs to transmit the fingerprint image to a processing unit of the electronic device 100, such as a central processing unit (CPU) or an application processor (AP) for fingerprint matching verification. Therefore, it is generally necessary to compress the fingerprint image obtained by the optical fingerprint sensor 130 in the fingerprint module through a microprocessor (MCU), and then provide the data to the processing unit of the electronic device 100 for fingerprint matching identification and perform the matching based on the matching identification result Corresponding application operations, such as device unlocking, mobile payment, system settings, or application installation / removal.
图2为本发明实施例一提供的数据压缩方法的方法流程图,如图2所示,本实施例中的方法可以包括:FIG. 2 is a method flowchart of a data compression method provided in Embodiment 1 of the present invention. As shown in FIG. 2, the method in this embodiment may include:
S101、接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据。S101. Receive a data frame uploaded by a sensor within a preset period, where the data frame includes at least one line of data.
实际应用中,本实施例的执行主体可以为微控制单元MCU、单片机、微型处理器等具备数据处理能力的器件。本实施例中以MCU为例进行详细说明,但不限定执行本实施例中方法的具体器件类型。In practical applications, the execution subject of this embodiment may be a micro control unit MCU, a single-chip microcomputer, a micro processor, and other devices having data processing capabilities. In this embodiment, an MCU is used as an example for detailed description, but the specific device type for executing the method in this embodiment is not limited.
本实施例中,MCU可以与传感器集成为一个模块,也可以是与传感器电连接的独立模块。首先MCU接收传感器在预设周期(一般是一个采集周期)内上传的数据帧(可以是一帧也可以是多帧,多帧的数据处理方式与一帧的数据处理方式类似);数据帧中包括至少1行数据。需要说明的是,本实施例中默认数据帧的数据形式为按行存储,并且对每行数据中所包含的数据数量不予限定。In this embodiment, the MCU may be integrated with the sensor into a module, or may be an independent module electrically connected to the sensor. First, the MCU receives the data frames uploaded by the sensor in a preset period (usually a collection period) (can be one frame or multiple frames, and the data processing method of multiple frames is similar to that of one frame); Include at least 1 row of data. It should be noted that the data format of the default data frame in this embodiment is stored on a row basis, and the amount of data contained in each row of data is not limited.
S102、对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据。S102. Perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data.
本实施例中,同比特压缩处理是指设置每行数据中每个数据的压缩比特数相同,并按照该压缩比特数对每行数据进行压缩处理。分段压缩处理是指将行数据划分为2个或者2个以上的区段;分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,且相邻两个区段的压缩比特位数不同。In this embodiment, the same-bit compression processing refers to setting the number of compressed bits of each data in each line of data to be the same, and performing compression processing on each line of data according to the number of compressed bits. Segmented compression processing refers to dividing line data into two or more sections; setting the compression bit number of data in each section separately; compressing the data in the section according to the corresponding compression bit number , And the compression bit number of two adjacent sections is different.
图3为本发明实施例一中步骤S102的方法流程图,如图3所示,在一种可选的实施方式中,步骤S102可以包括:FIG. 3 is a flowchart of a method of step S102 in Embodiment 1 of the present invention. As shown in FIG. 3, in an optional embodiment, step S102 may include:
S1021、将所述数据帧的第一行数据作为基准行,对所述基准行进行同比特压缩处理或者分段压缩处理。S1021. Using the first line of data in the data frame as a reference line, perform the same-bit compression process or the segment compression process on the reference line.
本实施例中,假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n。然后确定差值运算后的基准行中除基础数据以外的数据中的最大值,按照所述最大值设置压缩比特位数;按照所述压缩比特位数,对基准行中除基础数据以外的数据进行同比特压缩处理,得到基准行对应的压缩数据。 In this embodiment, it is assumed that the reference line includes n data, which are denoted as a 0 , a 1 , a 2 , ..., an n , a 0 is used as the basic data, and the value of a i minus a i-1 is used to replace the reference. The data a i in the rows, to obtain the reference row after the difference operation, where i = 1, 2, 3 ..., n. Then determine the maximum value of the data other than the basic data in the reference row after the difference operation, and set the number of compressed bits according to the maximum value; Perform the same bit compression processing to obtain the compressed data corresponding to the reference line.
具体地,图4为采用同比特压缩处理方式压缩基准行的结构示意图,如图4所示,基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,保留基础数据a 0不变,用a i减去a i-1的值替换基准行中的数据a i,其中i=1,2,3…,n;得到差值运算后的基准行,分别记为a 0、a 2-a 1、a 3-a 2、…、a n-a n-1。设置压缩比特位数为m,即用m个比特来压缩差值运算后的基准行中除基础数据以外的数据。如图4所示,(a 2-a 1) m_bit表示对数据a 2-a 1采用m个比特压缩后的值,其他数值依次类推,不再重复解释。本实施例中,不对基础数据a 0进行压缩,假设基础数据a 0的实际比特位数为12,则用2Byte存储。采用同比特压缩处理方式压缩后的数据压缩信息存储在head(数据头)中,head m表示用m个比特来压缩数据,head m中包含有数据最小值、压缩比特数,以及数据总体长度信息。m的值根据差值运算后的基准行中最大的数据来确定。 Specifically, FIG. 4 is a schematic structural diagram of compressing a reference line by using the same bit compression processing method. As shown in FIG. 4, the reference line includes n data, which are denoted as a 0 , a 1 , a 2 , ..., an n , and are reserved. The basic data a 0 is unchanged. Replace the data a i in the reference line with the value of a i minus a i-1 , where i = 1, 2, 3 ..., n; get the reference line after the difference operation, and record them separately. Are a 0 , a 2 -a 1 , a 3 -a 2 , ..., an n -a n-1 . Set the number of compressed bits to m, that is, m bits are used to compress the data in the reference row after the difference operation, except the basic data. As shown in FIG. 4, (a 2 -a 1 ) m_bit represents a value obtained by compressing m bits of data a 2 -a 1 , and other values are sequentially deduced by analogy, and the explanation is not repeated. In this embodiment, the basic data a 0 is not compressed. Assuming that the actual number of bits of the basic data a 0 is 12, it is stored in 2 Bytes. The data compression information compressed by the same bit compression processing method is stored in the head (data header). Head m indicates that the data is compressed by m bits. The head m contains the minimum data value, the number of compressed bits, and the overall data length information. . The value of m is determined based on the largest data in the reference row after the difference calculation.
本实施例中,假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n。然后根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段;分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到基准行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。 In this embodiment, it is assumed that the reference line includes n data, which are denoted as a 0 , a 1 , a 2 , ..., an n , a 0 is used as the basic data, and the value of a i minus a i-1 is used to replace the reference. The data a i in the rows, to obtain the reference row after the difference operation, where i = 1, 2, 3 ..., n. Then, according to the size of the data other than the basic data in the reference row after the difference operation, the reference row after the difference operation is divided into two or more sections according to a preset rule; each section is set separately. The number of compressed bits of the data; the data in the section is compressed according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; wherein the compressed bits of two adjacent sections are different.
具体地,图5为采用分段压缩处理方式压缩基准行的结构示意图,如图5所示,基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,保留基础数据a 0不变,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,分别记为a 0、a 2-a 1、a 3-a 2、…、a n-a n-1。根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段。参见图5,第一个区段采用m个比特来压缩数据,第二个区段采用P个比特来压缩数据,P和m的值不相等。如图5所示,(a x+1-a x) p_bit表示对数据a x+1-a x采用P个比特压缩后的值,其他数值依次类推,不再重复解释。 Specifically, FIG. 5 is a structural schematic diagram of compressing a reference line by using a segmented compression processing method. As shown in FIG. 5, the reference line includes n data, which are respectively denoted as a 0 , a 1 , a 2 , ..., an n , and are retained. the same basic data a 0, a i by subtracting a i-1 data to the replacement reference value of a i in the row, calculating a difference obtained after the reference line, denoted as a 0, a 2 -a 1, a 3 -a 2 , ..., an n -a n-1 . According to the size of data other than the basic data in the reference row after the difference operation, the reference row after the difference operation is divided into two or more sections according to a preset rule. Referring to FIG. 5, the first sector uses m bits to compress data, and the second sector uses P bits to compress data. The values of P and m are not equal. As shown in FIG. 5, (a x + 1-a x ) p_bit represents a value obtained by compressing P bits of data a x + 1 -a x , and other values are deduced by analogy, and the explanation is not repeated.
可选地,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段,需要尽可能减少压缩后的byte数。假设同比特压缩处理方式设置的压缩比特位数为7,而分段压缩处理方式中,第一区段的压缩比特位数为7,第二区段的压缩比特位数为3,其中,第二区段中有4个数据(对应区段长度 为4),那么采用分段压缩处理方式可以节约的比特数为4*(7-3)=16,对应的节约的byte数为2(节约的比特数除以8后取整)。Optionally, the reference line after the difference calculation is divided into two or more sections according to a preset rule, and the number of bytes after compression needs to be reduced as much as possible. Assume that the number of compression bits set in the same-bit compression processing method is 7, and in the segmented compression processing method, the number of compression bits in the first section is 7 and the number of compression bits in the second section is 3, where the first There are 4 data in the second section (the corresponding section length is 4), then the number of bits that can be saved by using the segment compression processing method is 4 * (7-3) = 16, and the corresponding number of saved bytes is 2 (savings The number of bits divided by 8 and rounded).
具体地,在设置分段按照预设规则将差值运算后的基准行进行区段划分的时,可以参考如下的参考公式:节约的byte数>数据头的长度+区段压缩后的长度,来设置区段数以及每个区段的压缩比特位数。Specifically, when setting the segmentation to divide the reference line after the difference calculation according to a preset rule into sections, refer to the following reference formula: the number of bytes saved> the length of the data header + the length of the section after compression, To set the number of sections and the number of compressed bits for each section.
本实施例中,不对基础数据a 0进行压缩,假设基础数据a 0的实际比特位数为12,则用2Byte存储。采用同比特压缩处理方式压缩后的数据压缩信息存储在head(数据头)中,head m表示用m个比特来压缩数据,head m中包含有数据最小值、压缩比特数,以及数据总体长度信息。Head p表示用P个比特来压缩数据,head p中包含有数据最小值、压缩比特数,以及数据总体长度信息。 In this embodiment, the basic data a 0 is not compressed. Assuming that the actual number of bits of the basic data a 0 is 12, it is stored in 2 Bytes. The data compression information compressed by the same bit compression processing method is stored in the head (data header). Head m indicates that the data is compressed by m bits. The head m contains the minimum data value, the number of compressed bits, and the overall data length information. . Head p indicates that P bits are used to compress the data. Head p contains the minimum value of the data, the number of compressed bits, and the overall length of the data.
S1022当数据帧包括2行及以上数据时;从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,对所述差值数据行进行同比特压缩处理或者分段压缩处理。S1022 When the data frame includes 2 or more rows of data; starting from the second row of data, the previous row of data is used as a reference row of the adjacent next row of data to perform a difference operation to obtain a row of difference data, and the difference data is The lines are subjected to the same bit compression processing or the segment compression processing.
本实施例中,假设当前行数据为第j+1行数据,所述第j+1行数据包括n个数据,分别记为:a j+1,0、a j+1,1、a j+1,2、…、a j+1,n;当前行数据的前一行数据为第j行数据,所述第j行数据包括n个数据,分别记为:a j,0、a j,1、a j,2、…、a j,n;其中j=1,2,3…,N-1;N为所述数据帧的总行数。然后将第j+1行数据中的值减去第j行数据中对应的值,得到差值数据行,所述差值数据行记为:a j+1,0-a j,0、a j+1,1-a j,1、a j+1,2-a j,2、…、a j+1,n-a j,nIn this embodiment, it is assumed that the current row of data is the j + 1th row of data, and the j + 1th row of data includes n data, which are respectively recorded as: a j + 1,0 , a j + 1 , 1 , and a j +1,2 , ..., a j + 1, n ; the data in the previous row of the current row of data is the j-th row of data, and the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ; where j = 1 , 2 , 3 ..., N-1; N is the total number of rows of the data frame. Then subtract the corresponding value in the jth row of data from the value in the j + 1th row of data to obtain a difference data row, where the difference data row is recorded as: a j + 1,0 -a j, 0 , a j + 1,1 -a j, 1 , a j + 1,2 -a j, 2 , ..., a j + 1, n -a j, n .
在一种实施方式中,首先确定所述差值数据行的数据中的最大值,根据所述最大值设置压缩比特位数;然后按照所述压缩比特位数,对所述差值数据行进行同比特压缩处理,得到所述差值数据行对应的压缩数据。In an implementation manner, a maximum value in the data of the difference data line is first determined, and the number of compressed bits is set according to the maximum value; then, the difference data line is processed according to the number of compressed bits. Same bit compression processing to obtain compressed data corresponding to the difference data line.
在另一种实施方式中,按照预设规则将所述差值数据行划分为2个或者2个以上的区段;分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到所述差值数据行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。In another embodiment, the difference data line is divided into two or more sections according to a preset rule; the number of compressed bits of data in each section is set separately; according to the corresponding compressed bit The number of bits compresses the data in the segment to obtain the compressed data corresponding to the difference data line; wherein the number of compressed bits of two adjacent segments is different.
具体地,图6为采用分段压缩处理方式压缩差值数据行的结构示意图,如图6所示,head u_bit表示压缩比特位数为u的区段的数据头,head v_bit表示压缩比特位数为v的区段的数据头,d 1_u_bit表示当前采集行数据中第1个差值数据采用u个比特压缩后的值,依次类推,d x_u_bit表示当前采集行数据中第x个 差值数据采用u个比特压缩后的值。d x+1_v_bit表示当前采集行数据中第x+1个差值数据采用v个比特压缩后的值,依次类推,d y_v_bit表示前采集行数据中第y个差值数据采用v个比特压缩后的值。head u_bit与head v_bit所对应的区段相邻,因此u与v的值不同。依次压缩每一个区段的数据,将当前行数据的所有差值数据的压缩值组成byte/int/word等形式的数据。 Specifically, FIG. 6 is a schematic structural diagram of compressing a difference data line by using a segmented compression processing method. As shown in FIG. 6, head u_bit represents a data header of a sector with a compression bit number of u, and head v_bit represents a compression bit number Is the data header of the section of v, d 1_u_bit represents the first difference data in the current collection line data is compressed by u bits, and so on, and d x_u_bit represents the x-th difference data in the current collection line data. u bit compressed value. d x + 1_v_bit represents the value of the x + 1th difference data in the current collection line data after v bit compression, and so on, d y_v_bit represents the yth difference data in the previous collection line data after v bit compression Value. The head u_bit is adjacent to the section corresponding to the head v_bit , so u and v have different values. Compress the data of each section in turn, and combine the compressed values of all the difference data of the current row data into byte / int / word and other data.
S103、将所述压缩数据发送给外部终端。S103. Send the compressed data to an external terminal.
本实施例中,MCU可以实时将压缩数据发送给外部终端(即每压缩一行数据就直接发送给外部终端),也可以在将数据帧全部压缩好之后一次性发送给外部终端。外部终端可以是具有数据处理功能的计算机设备、便携式设备(例如手机、平板电脑、智能手表等等)。In this embodiment, the MCU can send the compressed data to the external terminal in real time (that is, the compressed data is sent directly to the external terminal), or it can be sent to the external terminal at one time after all the data frames are compressed. The external terminal may be a computer device, a portable device (such as a mobile phone, a tablet computer, a smart watch, etc.) having a data processing function.
本实施例,通过接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据;将所述压缩数据发送给外部终端。从而实现对数据量较小的数据的无损压缩处理,压缩后数据长度明显减少,有效缩短压缩数据的传输时间。In this embodiment, a data frame uploaded by a sensor within a preset period is received, where the data frame includes at least one line of data; each line of data in the data frame is subjected to the same-bit compression processing or segment compression processing to obtain Compressing data; sending the compressed data to an external terminal. As a result, lossless compression processing of data with a small amount of data is realized, and the length of the compressed data is significantly reduced, which effectively shortens the transmission time of the compressed data.
图7为本发明实施例二提供的数据压缩装置的结构示意图,如图7所示,本实施例中的装置可以包括:FIG. 7 is a schematic structural diagram of a data compression apparatus according to Embodiment 2 of the present invention. As shown in FIG. 7, the apparatus in this embodiment may include:
接收模块10,用于接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;The receiving module 10 is configured to receive a data frame uploaded by a sensor within a preset period, where the data frame includes at least one line of data;
压缩模块20,用于对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据;A compression module 20, configured to perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data;
发送模块30,用于将所述压缩数据发送给外部终端。The sending module 30 is configured to send the compressed data to an external terminal.
可选地,所述压缩模块30,具体用于:Optionally, the compression module 30 is specifically configured to:
将所述数据帧的第一行数据作为基准行,对所述基准行进行同比特压缩处理或者分段压缩处理;Using the first line of data in the data frame as a reference line, and performing same-bit compression processing or segment compression processing on the reference line;
当数据帧包括2行及以上数据时;When the data frame includes 2 or more lines of data;
从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,对所述差值数据行进行同比特压缩处理或者分段压缩处理。Starting from the second line of data, a previous line of data is used as a reference line of an adjacent subsequent data line to perform a difference operation to obtain a difference data line, and the difference data line is subjected to the same-bit compression processing or segment compression processing.
可选地,对所述基准行进行同比特压缩处理,包括:Optionally, performing the same-bit compression processing on the reference line includes:
假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础 数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
确定差值运算后的基准行中除基础数据以外的数据中的最大值,按照所述最大值设置压缩比特位数;Determining the maximum value in the data other than the basic data in the reference row after the difference operation, and setting the number of compressed bits according to the maximum value;
按照所述压缩比特位数,对基准行中除基础数据以外的数据进行同比特压缩处理,得到基准行对应的压缩数据。According to the compression bit number, the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
可选地,对所述基准行进行分段压缩处理,包括:Optionally, performing segment compression processing on the reference line includes:
假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段;Divide the reference line after difference calculation into two or more sections according to the size of data other than the basic data in the reference line after difference calculation;
分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到基准行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each segment separately; compress the data in the segment according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; of which the compressed bits of two adjacent segments The number is different.
可选地,从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,包括:Optionally, starting from the second row of data, the previous row of data is used as the reference row of the adjacent next row of data to perform the difference operation to obtain the difference data row, including:
假设当前行数据为第j+1行数据,所述第j+1行数据包括n个数据,分别记为:a j+1,0、a j+1,1、a j+1,2、…、a j+1,n;当前行数据的前一行数据为第j行数据,所述第j行数据包括n个数据,分别记为:a j,0、a j,1、a j,2、…、a j,n;其中j=1,2,3…,N-1;N为所述数据帧的总行数; Assume that the current line of data is the j + 1th line of data, and the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , …, A j + 1, n ; the previous row of data of the current row of data is the j-th row of data, and the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ; where j = 1, 2, 3 ..., N-1; N is the total number of rows of the data frame;
将第j+1行数据中的值减去第j行数据中对应的值,得到差值数据行,所述差值数据行记为:a j+1,0-a j,0、a j+1,1-a j,1、a j+1,2-a j,2、…、a j+1,n-a j,nSubtract the corresponding value in the jth row of data from the value in the j + 1th row of data to obtain a difference data row, where the difference data row is recorded as: a j + 1,0 -a j, 0 , a j +1,1 -a j, 1 , a j + 1,2 -a j, 2 , ..., a j + 1, n -a j, n .
可选地,对所述差值数据行进行同比特压缩处理,包括:Optionally, performing the same-bit compression processing on the difference data line includes:
确定所述差值数据行的数据中的最大值,根据所述最大值设置压缩比特位数;Determining a maximum value in the data of the difference data line, and setting the number of compressed bits according to the maximum value;
按照所述压缩比特位数,对所述差值数据行进行同比特压缩处理,得到所述差值数据行对应的压缩数据。Performing the same-bit compression processing on the difference data line according to the number of compressed bits, to obtain compressed data corresponding to the difference data line.
可选地,对所述差值数据行进行分段压缩处理,包括:Optionally, performing segment compression processing on the difference data line includes:
按照预设规则将所述差值数据行划分为2个或者2个以上的区段;Dividing the difference data line into two or more sections according to a preset rule;
分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对 区段内的数据进行压缩,得到所述差值数据行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each section separately; compress the data in the section according to the corresponding number of compressed bits to obtain the compressed data corresponding to the difference data line; where two adjacent sections are compressed The number of compressed bits is different.
本实施例中的数据压缩装置可以执行图2所示的方法,其具体实现过程和技术原理参见图2所示方法中的相关描述,此处不再赘述。The data compression apparatus in this embodiment may execute the method shown in FIG. 2. For specific implementation processes and technical principles, refer to related descriptions in the method shown in FIG. 2, and details are not described herein again.
图8为本发明实施例三提供的数据压缩设备的结构示意图,如图8所示,本实施例中的数据压缩设备40包括:FIG. 8 is a schematic structural diagram of a data compression device provided in Embodiment 3 of the present invention. As shown in FIG. 8, the data compression device 40 in this embodiment includes:
处理器41以及存储器42;其中:The processor 41 and the memory 42;
存储器42,用于存储可执行指令,该存储器还可以是flash(闪存)。The memory 42 is configured to store executable instructions, and the memory may also be a flash (flash memory).
处理器41,用于执行存储器存储的可执行指令,以实现上述实施例涉及的方法中的各个步骤。具体可以参见前面方法实施例中的相关描述。The processor 41 is configured to execute executable instructions stored in a memory to implement each step in the method according to the foregoing embodiment. For details, refer to related descriptions in the foregoing method embodiments.
可选地,存储器42既可以是独立的,也可以跟处理器41集成在一起。Optionally, the memory 42 may be independent or integrated with the processor 41.
当所述存储器42是独立于处理器41之外的器件时,所述数据压缩设备40还可以包括:When the memory 42 is a device independent of the processor 41, the data compression device 40 may further include:
总线43,用于连接所述存储器42和处理器41。The bus 43 is configured to connect the memory 42 and the processor 41.
此外,本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,当用户设备的至少一个处理器执行该计算机执行指令时,用户设备执行上述各种可能的方法。In addition, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores computer execution instructions. When at least one processor of the user equipment executes the computer execution instructions, the user equipment executes the foregoing various possibilities. Methods.
其中,计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于应用专用集成电路(ASIC)中。另外,该应用专用集成电路可以位于用户设备中。当然,处理器和存储介质也可以作为分立组件存在于通信设备中。The computer-readable medium includes a computer storage medium and a communication medium, and the communication medium includes any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be an integral part of the processor. The processor and the storage medium may reside in an application-specific integrated circuit (ASIC). In addition, the application specific integrated circuit may be located in a user equipment. Of course, the processor and the storage medium may also exist as discrete components in a communication device.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:只读存储器(ROM)、随机存取存储器(RAM)、磁碟或者光盘等各种可以存储程序代码的介质。A person of ordinary skill in the art may understand that all or part of the steps of implementing the foregoing method embodiments may be implemented by a program instructing related hardware. The aforementioned program may be stored in a computer-readable storage medium. When the program is executed, the steps including the foregoing method embodiments are executed; and the foregoing storage medium includes: a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, which can store program code. medium.
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本 公开的其它实施方案。本发明旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求书指出。Those skilled in the art will readily contemplate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variation, use, or adaptive change of the present disclosure. These variations, uses, or adaptive changes follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed by the present disclosure. . It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求书来限制。It should be understood that the present disclosure is not limited to the precise structure that has been described above and illustrated in the drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the disclosure is limited only by the following claims.

Claims (16)

  1. 一种数据压缩方法,其特征在于,包括:A data compression method, comprising:
    接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;Receiving a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data;
    对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据;Performing the same-bit compression processing or segment compression processing on each row of data of the data frame to obtain compressed data;
    将所述压缩数据发送给外部终端。Sending the compressed data to an external terminal.
  2. 根据权利要求1所述的方法,其特征在于,对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,包括:The method according to claim 1, wherein performing the same bit compression processing or the segment compression processing on each row of data of the data frame comprises:
    将所述数据帧的第一行数据作为基准行,对所述基准行进行同比特压缩处理或者分段压缩处理;Using the first line of data in the data frame as a reference line, and performing same-bit compression processing or segment compression processing on the reference line;
    当数据帧包括2行及以上数据时;从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,对所述差值数据行进行同比特压缩处理或者分段压缩处理。When the data frame includes 2 or more rows of data; starting from the second row of data, the previous row of data is used as the reference row of the next subsequent row of data to perform a difference operation to obtain a difference data row, and the difference data row Perform the same-bit compression process or the segment compression process.
  3. 根据权利要求2所述的方法,其特征在于,对所述基准行进行同比特压缩处理,包括:The method according to claim 2, wherein performing the same-bit compression processing on the reference line comprises:
    假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
    确定差值运算后的基准行中除基础数据以外的数据中的最大值,按照所述最大值设置压缩比特位数;Determining the maximum value in the data other than the basic data in the reference row after the difference operation, and setting the number of compressed bits according to the maximum value;
    按照所述压缩比特位数,对基准行中除基础数据以外的数据进行同比特压缩处理,得到基准行对应的压缩数据。According to the compression bit number, the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
  4. 根据权利要求2所述的方法,其特征在于,对所述基准行进行分段压缩处理,包括:The method according to claim 2, wherein performing segment compression processing on the reference line comprises:
    假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
    根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段;Divide the reference line after difference calculation into two or more sections according to the size of data other than the basic data in the reference line after difference calculation;
    分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到基准行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each segment separately; compress the data in the segment according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; of which the compressed bits of two adjacent segments The number is different.
  5. 根据权利要求2所述的方法,其特征在于,从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,包括:The method according to claim 2, characterized in that starting from the second line of data, performing a difference operation on the previous line of data as a reference line of an adjacent subsequent data line to obtain the difference data line, comprising:
    假设当前行数据为第j+1行数据,所述第j+1行数据包括n个数据,分别记为:a j+1,0、a j+1,1、a j+1,2、…、a j+1,n;当前行数据的前一行数据为第j行数据,所述第j行数据包括n个数据,分别记为:a j,0、a j,1、a j,2、…、a j,n;其中j=1,2,3…,N-1;N为所述数据帧的总行数; Assume that the current line of data is the j + 1th line of data, and the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , …, A j + 1, n ; the previous row of data of the current row of data is the j-th row of data, and the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ; where j = 1, 2, 3 ..., N-1; N is the total number of rows of the data frame;
    将第j+1行数据中的值减去第j行数据中对应的值,得到差值数据行,所述差值数据行记为:a j+1,0-a j,0、a j+1,1-a j,1、a j+1,2-a j,2、…、a j+1,n-a j,nSubtract the corresponding value in the jth row of data from the value in the j + 1th row of data to obtain a difference data row, where the difference data row is recorded as: a j + 1,0 -a j, 0 , a j +1,1 -a j, 1 , a j + 1,2 -a j, 2 , ..., a j + 1, n -a j, n .
  6. 根据权利要求2-5中任一项所述的方法,其特征在于,对所述差值数据行进行同比特压缩处理,包括:The method according to any one of claims 2-5, wherein performing the same-bit compression processing on the difference data line comprises:
    确定所述差值数据行的数据中的最大值,根据所述最大值设置压缩比特位数;Determining a maximum value in the data of the difference data line, and setting the number of compressed bits according to the maximum value;
    按照所述压缩比特位数,对所述差值数据行进行同比特压缩处理,得到所述差值数据行对应的压缩数据。Performing the same-bit compression processing on the difference data line according to the number of compressed bits, to obtain compressed data corresponding to the difference data line.
  7. 根据权利要求2-5中任一项所述的方法,其特征在于,对所述差值数据行进行分段压缩处理,包括:The method according to any one of claims 2-5, wherein performing segment compression processing on the difference data line comprises:
    按照预设规则将所述差值数据行划分为2个或者2个以上的区段;Dividing the difference data line into two or more sections according to a preset rule;
    分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到所述差值数据行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each section separately; compress the data in the section according to the corresponding number of compressed bits to obtain the compressed data corresponding to the difference data line; where two adjacent sections are compressed The number of compressed bits is different.
  8. 一种数据压缩装置,其特征在于,包括:A data compression device, comprising:
    接收模块,用于接收传感器在预设周期内上传的数据帧,其中,所述数据帧包括至少1行数据;A receiving module, configured to receive a data frame uploaded by a sensor within a preset period, wherein the data frame includes at least one line of data;
    压缩模块,用于对所述数据帧的每行数据进行同比特压缩处理或者分段压缩处理,得到压缩数据;A compression module, configured to perform same-bit compression processing or segment compression processing on each row of data in the data frame to obtain compressed data;
    发送模块,用于将所述压缩数据发送给外部终端。A sending module, configured to send the compressed data to an external terminal.
  9. 根据权利要求8所述的装置,其特征在于,所述压缩模块,具体用于:The apparatus according to claim 8, wherein the compression module is specifically configured to:
    将所述数据帧的第一行数据作为基准行,对所述基准行进行同比特压缩处理或者分段压缩处理;Using the first line of data in the data frame as a reference line, and performing same-bit compression processing or segment compression processing on the reference line;
    当数据帧包括2行及以上数据时;从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,对所述差值数据行进行同比特压缩处理或者分段压缩处理。When the data frame includes 2 or more rows of data; starting from the second row of data, the previous row of data is used as the reference row of the next subsequent row of data to perform a difference operation to obtain a difference data row, and the difference data row Perform the same-bit compression process or the segment compression process.
  10. 根据权利要求9所述的装置,其特征在于,对所述基准行进行同比特压缩处理,包括:The apparatus according to claim 9, wherein performing the same-bit compression processing on the reference line comprises:
    假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
    确定差值运算后的基准行中除基础数据以外的数据中的最大值,按照所述最大值设置压缩比特位数;Determining the maximum value in the data other than the basic data in the reference row after the difference operation, and setting the number of compressed bits according to the maximum value;
    按照所述压缩比特位数,对基准行中除基础数据以外的数据进行同比特压缩处理,得到基准行对应的压缩数据。According to the compression bit number, the same-bit compression processing is performed on the data in the reference line other than the basic data to obtain the compressed data corresponding to the reference line.
  11. 根据权利要求9所述的装置,其特征在于,对所述基准行进行分段压缩处理,包括:The apparatus according to claim 9, wherein performing segment compression processing on the reference line comprises:
    假设基准行包括n个数据,分别记为a 0、a 1、a 2、…、a n,将a 0作为基础数据,用a i减去a i-1的值替换基准行中的数据a i,得到差值运算后的基准行,其中i=1,2,3…,n; Hypothetical reference line comprises n data, are referred to as a 0, a 1, a 2 , ..., a n, a 0 as the basic data, data a i a i-1 by subtracting the reference value replacement in a row i to get the reference line after the difference operation, where i = 1,2,3 ..., n;
    根据差值运算后的基准行中除基础数据以外的数据的大小,按照预设规则将差值运算后的基准行划分为2个或者2个以上的区段;Divide the reference line after difference calculation into two or more sections according to the size of data other than the basic data in the reference line after difference calculation;
    分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到基准行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each segment separately; compress the data in the segment according to the corresponding number of compressed bits to obtain the compressed data corresponding to the reference row; of which the compressed bits of two adjacent segments The number is different.
  12. 根据权利要求9所述的装置,其特征在于,从第二行数据开始,以前一行数据作为相邻的后一数据行的基准行进行差值运算,得到差值数据行,包括:The device according to claim 9, characterized in that starting from the second line of data, performing a difference operation on the previous line of data as a reference line of an adjacent subsequent data line to obtain a difference data line, comprising:
    假设当前行数据为第j+1行数据,所述第j+1行数据包括n个数据,分别记为:a j+1,0、a j+1,1、a j+1,2、…、a j+1,n;当前行数据的前一行数据为第j行数据,所述第j行数据包括n个数据,分别记为:a j,0、a j,1、a j,2、…、a j,n;其中j=1,2,3…,N-1;N为所述数据帧的总行数; Assume that the current line of data is the j + 1th line of data, and the j + 1th line of data includes n data, which are recorded as: a j + 1,0 , a j + 1,1 , a j + 1,2 , …, A j + 1, n ; the previous row of data of the current row of data is the j-th row of data, and the j-th row of data includes n data, which are recorded as: a j, 0 , a j, 1 , a j, 2 , ..., a j, n ; where j = 1, 2, 3 ..., N-1; N is the total number of rows of the data frame;
    将第j+1行数据中的值减去第j行数据中对应的值,得到差值数据行,所述差值数据行记为:a j+1,0-a j,0、a j+1,1-a j,1、a j+1,2-a j,2、…、a j+1,n-a j,nSubtract the corresponding value in the jth row of data from the value in the j + 1th row of data to obtain a difference data row, where the difference data row is recorded as: a j + 1,0 -a j, 0 , a j +1,1 -a j, 1 , a j + 1,2 -a j, 2 , ..., a j + 1, n -a j, n .
  13. 根据权利要求9-12中任一项所述的装置,其特征在于,对所述差值数据行进行同比特压缩处理,包括:The apparatus according to any one of claims 9-12, wherein performing the same-bit compression processing on the difference data line comprises:
    确定所述差值数据行的数据中的最大值,根据所述最大值设置压缩比特位数;Determining a maximum value in the data of the difference data line, and setting the number of compressed bits according to the maximum value;
    按照所述压缩比特位数,对所述差值数据行进行同比特压缩处理,得到所述差值数据行对应的压缩数据。Performing the same-bit compression processing on the difference data line according to the number of compressed bits, to obtain compressed data corresponding to the difference data line.
  14. 根据权利要求9-12中任一项所述的装置,其特征在于,对所述差值数据行进行分段压缩处理,包括:The apparatus according to any one of claims 9-12, wherein performing segment compression processing on the difference data line comprises:
    按照预设规则将所述差值数据行划分为2个或者2个以上的区段;Dividing the difference data line into two or more sections according to a preset rule;
    分别设置每个区段内数据的压缩比特位数;按照对应的压缩比特位数对区段内的数据进行压缩,得到所述差值数据行对应的压缩数据;其中,相邻两个区段的压缩比特位数不同。Set the number of compressed bits of data in each section separately; compress the data in the section according to the corresponding number of compressed bits to obtain the compressed data corresponding to the difference data line; where two adjacent sections are compressed The number of compressed bits is different.
  15. 一种数据压缩设备,其特征在于,包括:A data compression device, comprising:
    存储器,用于存储程序;Memory for storing programs;
    处理器,用于执行所述存储器存储的所述程序,当所述程序被执行时,所述处理器用于执行如权利要求1-7中任一所述的数据压缩方法。A processor, configured to execute the program stored in the memory, and when the program is executed, the processor is configured to execute the data compression method according to any one of claims 1-7.
  16. 一种计算机可读存储介质,其特征在于,存储有指令,当其在计算机上运行时,使得计算机执行如权利要求1-7中任一所述的数据压缩方法。A computer-readable storage medium, characterized in that it stores instructions that, when run on a computer, causes the computer to execute the data compression method according to any one of claims 1-7.
PCT/CN2018/094835 2018-07-06 2018-07-06 Data compression method and apparatus WO2020006753A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2018/094835 WO2020006753A1 (en) 2018-07-06 2018-07-06 Data compression method and apparatus
CN201880000946.4A CN109074669A (en) 2018-07-06 2018-07-06 data compression method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/094835 WO2020006753A1 (en) 2018-07-06 2018-07-06 Data compression method and apparatus

Publications (1)

Publication Number Publication Date
WO2020006753A1 true WO2020006753A1 (en) 2020-01-09

Family

ID=64789411

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/094835 WO2020006753A1 (en) 2018-07-06 2018-07-06 Data compression method and apparatus

Country Status (2)

Country Link
CN (1) CN109074669A (en)
WO (1) WO2020006753A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110633277B (en) * 2019-08-13 2024-05-03 平安科技(深圳)有限公司 Time sequence data storage method, device, computer equipment and storage medium
CN112770286B (en) * 2021-01-13 2023-11-17 深圳市木千科技有限公司 Sensor data processing method and device and computer equipment
CN117370261A (en) * 2022-06-30 2024-01-09 深圳市中兴微电子技术有限公司 Method for data transmission and multi-core chip

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1731448A (en) * 2005-08-26 2006-02-08 北京中星微电子有限公司 Apparatus and method for pre-storage processing before image data compression
CN101237582A (en) * 2008-03-07 2008-08-06 北京中星微电子有限公司 Local dynamic image amplification device and method and image processing system
CN104952088A (en) * 2015-05-25 2015-09-30 常州北大众志网络计算机有限公司 Method for compressing and decompressing display data
CN105681715A (en) * 2016-03-03 2016-06-15 腾讯科技(深圳)有限公司 Audio and video processing method and apparatus

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103761933A (en) * 2013-12-30 2014-04-30 深圳市华星光电技术有限公司 System and method for repairing bad display area of liquid crystal display panel
CN104868922B (en) * 2014-02-24 2018-05-29 华为技术有限公司 Data compression method and apparatus
CN104639834A (en) * 2015-02-04 2015-05-20 惠州Tcl移动通信有限公司 Method and system for transmitting camera image data
US9794126B2 (en) * 2015-11-11 2017-10-17 Simmonds Precision Products, Inc. Data compression of a sequence of binary data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1731448A (en) * 2005-08-26 2006-02-08 北京中星微电子有限公司 Apparatus and method for pre-storage processing before image data compression
CN101237582A (en) * 2008-03-07 2008-08-06 北京中星微电子有限公司 Local dynamic image amplification device and method and image processing system
CN104952088A (en) * 2015-05-25 2015-09-30 常州北大众志网络计算机有限公司 Method for compressing and decompressing display data
CN105681715A (en) * 2016-03-03 2016-06-15 腾讯科技(深圳)有限公司 Audio and video processing method and apparatus

Also Published As

Publication number Publication date
CN109074669A (en) 2018-12-21

Similar Documents

Publication Publication Date Title
WO2020006753A1 (en) Data compression method and apparatus
US9524052B2 (en) Efficient lossless compression for peripheral interface data transfer
JP2020174374A (en) Digital image recompression
CN102804760B (en) There is the storage device of multi-media interface connector
US20190364230A1 (en) Method of processing data for dynamic vision sensor, dynamic vision sensor performing the same and electronic device including the same
KR102385365B1 (en) Electronic device and method for encoding image data in the electronic device
WO2024098715A1 (en) Video compression method and system for baseboard management control chip, and related components
CN113873255B (en) Video data transmission method, video data decoding method and related devices
CN108833013A (en) A kind of visible optical transceiving method and system
JP2018513635A (en) Conversion method from N base number to physical line state symbol
CN115943389A (en) Surveillance camera upgrade via removable media with deep learning accelerator and random access memory
US10448059B2 (en) Fingerprint image processing system
WO2022068357A1 (en) Image processing method and apparatus, device, and storage medium
US11048650B1 (en) Method and system for integrating processing-in-sensor unit and in-memory computing unit
TW202020744A (en) Method of cable sensing data collection, and electronic apparatus and chip using the same
CN102298782B (en) System and method for parameter estimation for lossless video compression
WO2021031612A1 (en) Fingerprint sensing device
US9257040B2 (en) Method and device for learning and playing back electromagnetic signals
TW202324056A (en) Fingerprint image generation method and device for saving memory
CN113259604A (en) Intelligent perception image acquisition device and method
US10791331B2 (en) Foldable electronic device and file decompression method
CN113054984A (en) Pressure-sensitive detection circuit, chip, system and pressure-sensitive detection method
WO2018196817A1 (en) Lz77-based data compression method, device and terminal
CN110968179B (en) Data processing method and device, readable storage medium and lower computer
CN110830744B (en) Safety interaction system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18925652

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18925652

Country of ref document: EP

Kind code of ref document: A1