A data compression method, device and computer readable storage medium
By converting the depth data generated by the TOF camera into YUYV format and compressing it, the problem of low compression efficiency of the raw depth data from the TOF camera is solved, achieving efficient data storage and transmission.
Patent Information
- Application Number
- CN202210334633.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-03-31
AI Technical Summary
In existing technologies, the raw depth data generated by TOF cameras lacks an effective compression method, resulting in low data storage and transmission efficiency.
By reading the 16-bit binary raw depth data, it is determined whether it meets the preset input requirements of the YUYV encoder. If it does not meet the requirements, the high address byte and the low address byte are swapped as a whole, the data is converted into YUYV format, and finally the data is compressed.
It achieves effective compression of depth data generated by TOF camera, reduces storage space requirements, and the error of decompressed data is limited to the lower eight bits, reducing the impact of error.
Smart Images

Figure CN114928362B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of data compression, and in particular to a data compression method, device and computer readable storage medium. BACKGROUND
[0002] Time of flight (TOF) 3D imaging is a technique that sends a light pulse to a target continuously, and then receives the light returned from the object by a sensor to obtain the distance of the target object by detecting the flight (round trip) time of the light pulse. This technique is basically similar to the principle of 3D laser sensor, except that the 3D laser sensor is a point-by-point scanning, while the TOF camera obtains the depth information of the entire image at the same time. The TOF camera also has similarities with the ordinary machine vision imaging process, both of which are composed of a light source, optical components, a sensor, a control circuit and a processing circuit. Compared with the binocular measurement system which also belongs to non-invasive three-dimensional detection and has a very similar application field, the TOF camera has a fundamentally different 3D imaging mechanism. Binocular stereo measurement obtains the distance of the target object by detecting the incident and reflected light.
[0003] In the prior art, there is no good compression method for the TOF camera and other devices based on TOF technology to generate original depth data of a target area through a TOF lens. Usually, the generated original depth data is temporarily stored and then directly sent to a target device. SUMMARY
[0004] Embodiments of the present application provide a data compression method, device and computer readable storage medium, which can compress the depth data generated by a TOF device.
[0005] The first aspect of embodiments of the present application provides a data compression method, comprising:
[0006] reading 16-bit binary original depth data into a local memory to obtain target depth data, the target depth data including a low address byte and a high address byte;
[0007] determining whether the target depth data meets the preset input requirements of a YUYV encoder, the YUYV encoder being configured to encode the input depth data into a YUYV format;
[0008] if not, exchanging the high address byte and the low address byte of the target depth data as a whole, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data;
[0009] inputting the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein a low address byte of the target depth data is taken as a luminance component of the YUYV data, and a high address byte is taken as a chroma component of the YUYV data;
[0010] performing data compression on the YUYV data to obtain compressed data.
[0011] Optionally, the judging whether the target depth data meets preset input requirements of the YUYV encoder comprises:
[0012] obtaining an end mode of the local machine;
[0013] judging whether the end mode is a big-endian mode;
[0014] if yes, determining that the target depth data meets the preset input requirements of the YUYV encoder; and if no, determining that the target depth data does not meet the preset input requirements of the YUYV encoder.
[0015] Optionally, before the reading of the 16-bit binary original depth data into the local memory, the method further comprises:
[0016] cyclically left shifting the original depth data by N bits, wherein N is greater than or equal to 1.
[0017] Optionally, the performing data compression on the YUYV data comprises:
[0018] obtaining a memory usage of a target host connected to the local machine;
[0019] performing data compression on the YUYV data according to the memory usage.
[0020] Optionally, the performing data compression on the YUYV data according to the memory usage comprises:
[0021] extracting a remaining storage space allocated to the local machine from the memory usage;
[0022] when the remaining storage space is greater than a compression threshold, performing high-fidelity compression on the luminance component of the YUYV data and performing high-fidelity compression on the chroma component of the YUYV data; and when the remaining storage space is less than or equal to the compression threshold, performing high-fidelity compression on the luminance component of the YUYV data and performing low-fidelity compression on the chroma component of the YUYV data.
[0023] Embodiment one of the present application provides a data compression device, comprising:
[0024] a reading unit, configured to read 16-bit binary original depth data into a local memory to obtain target depth data, the target depth data including a low address byte and a high address byte;
[0025] a judging unit, configured to judge whether the target depth data meets preset input requirements of a YUYV encoder, the YUYV encoder being configured to encode input depth data into YUYV format;
[0026] a whole interchanging unit, configured to interchange the low address byte and the high address byte of the target depth data as a whole when the judging unit determines that the target depth data does not meet the preset input requirements of the YUYV encoder, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte of the target depth data is the same as the low eight bits of the original depth data;
[0027] an input unit, configured to input the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein the low address byte of the target depth data is used as a luminance component of the YUYV data, and the high address byte of the target depth data is used as a chroma component of the YUYV data;
[0028] a compression unit, configured to compress the YUYV data to obtain compressed data.
[0029] Embodiment third aspect of the present application provides a data compression device, comprising:
[0030] a processor, a memory, an input / output unit and a bus;
[0031] the processor is connected with the memory, the input / output unit and the bus;
[0032] the memory stores a program, and the processor invokes the program to execute the data compression method in the first aspect and any possible implementation manner of the first aspect.
[0033] Embodiment fourth aspect of the present application provides a TOF camera, comprising:
[0034] one or more processors;
[0035] a memory configured to store one or more programs;
[0036] when the one or more programs are executed by the one or more processors, the data compression method in the first aspect and any possible implementation manner of the first aspect is realized.
[0037] The fifth aspect of the embodiments of the present application provides a computer readable storage medium, which has a program stored thereon, and the program causes a computer to execute the data compression method in the first aspect and any possible implementation manner of the first aspect when the program is executed on the computer.
[0038] From the above technical solutions, the embodiments of the present application have the following advantages:
[0039] The data compression method provided by the embodiments of the present application, before converting the target depth data into YUYV data, first judges whether the target depth data meets the preset input requirement of the YUYV encoder, if it is determined that the target depth data does not meet the preset input requirement of the YUYV encoder, first exchanges the high address byte and the low address byte of the target depth data as a whole, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data, then converts the target depth data into YUYV data, wherein the low address byte of the target depth data is the luminance component of the YUYV data, and the high address byte is the chrominance component of the YUYV data, finally, the YUYV data is compressed, so that the compression of the target depth data can be realized. At the same time, even if the chrominance component introduces an error, the error between the decompressed depth data and the original depth data will be limited to the low eight bits, which is beneficial to reduce the error. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 The flowchart of one embodiment of the data compression method in the embodiments of the present application is shown;
[0041] Figure 2 The flowchart of another embodiment of the data compression method in the embodiments of the present application is shown;
[0042] Figure 3 The structural diagram of one embodiment of the data compression device in the embodiments of the present application is shown;
[0043] Figure 4 The structural diagram of another embodiment of the data compression device in the embodiments of the present application is shown;
[0044] Figure 5 The structural diagram of another embodiment of the data compression device in the embodiments of the present application is shown. DETAILED DESCRIPTION
[0045] The embodiments of the present application provide a data compression method for compressing the depth data generated by a TOF device.
[0046] The method of the present application can be applied to a smart camera, a smart phone or other device with logic processing capability based on TOF technology, and the present application is not limited thereto. For convenience of description, the following description takes the execution subject as a terminal as an example.
[0047] The embodiments of the present application will be described below with reference to the accompanying drawings.
[0048] Please refer to Figure 1 The data compression method in the embodiments of the present application includes the following steps.
[0049] 101. The terminal reads 16-bit binary original depth data into the local memory;
[0050] In actual application, the original depth data generated by the TOF lens is usually 16-bit binary data. After the TOF lens generates the original depth data, the terminal will read the original depth data into the local memory according to the characteristics of the local CPU, so as to obtain target depth data. The target depth data includes high address bytes and low address bytes.
[0051] 102. The terminal determines whether the target depth data meets the preset input requirement of the YUYV encoder. If not, step 103 is performed.
[0052] Before the terminal converts the target depth data into YUYV data, it needs to determine whether the target depth data meets the preset input requirement of the YUYV encoder. If it is determined that the target depth data does not meet the preset input requirement, step 103 can be performed.
[0053] 103. The terminal exchanges the high address bytes and the low address bytes of the target depth data as a whole.
[0054] When the terminal determines that the target depth data does not meet the preset input requirement of the YUYV encoder, the high address bytes and the low address bytes of the target depth data can be exchanged as a whole. In this way, the original high address bytes of the target depth data become new low address bytes, and the original low address bytes become new high address bytes. At the same time, the new high address bytes of the target depth data are the same as the low eight bits of the original depth data, and the new low address bytes are the same as the high eight bits of the original depth data. For example, the original depth data is 0x1A76, the high eight bits are 0x1A, and the low eight bits are 0x76. After the exchange, the low address bytes of the target depth data are 0x1A, and the high address bytes are 0x76.
[0055] 104. The terminal inputs the target depth data into the YUYV encoder to obtain corresponding YUYV data.
[0056] The terminal can input the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein the low address byte of the target depth data is used as the luminance component of the YUYV data, and the high address byte is used as the chrominance component of the YUYV data. For example, if the low address byte of the target depth data is 0x1A and the high address byte is 0x76, then the luminance component of the obtained YUYV data is 0x1A, and the chrominance component is 0x76.
[0057] 105. The terminal compresses the YUYV data to obtain compressed data.
[0058] After the target depth data is converted into corresponding YUYV data, the terminal can select a compression mode to compress the YUYV data according to actual conditions, and finally obtain compressed data, thereby completing the compression processing of the target depth data and obtaining compressed data corresponding to the target depth data and occupying less storage space.
[0059] In this embodiment, before the target depth data is converted into YUYV data, the terminal first determines whether the target depth data meets the preset input requirement of the YUYV encoder. If it is determined that the target depth data does not meet the requirement, the terminal first exchanges the high address byte and the low address byte of the target depth data as a whole, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data. Then, the target depth data is converted into YUYV data, wherein the low address byte of the target depth data is used as the luminance component of the YUYV data, and the high address byte is used as the chrominance component of the YUYV data. Finally, the YUYV data is compressed, thereby achieving the compression of the target depth data. At the same time, even if the chrominance component introduces an error, the error between the decompressed depth data and the original depth data will only be limited to the low eight bits, which is conducive to reducing the error.
[0060] Please refer to Figure 2 Another embodiment of the data compression method in the present application includes:
[0061] 201. The terminal circularly left shifts the original depth data by N bits.
[0062] In practical applications, such as office multi-person video conference places, the maximum measurement range of TOF devices is not necessarily the same, for example, the maximum measurement range of some TOF devices is 4m, while the maximum measurement range of some TOF devices is more than 10m, etc. The depth data generated by different TOF devices is usually in mm units, so the maximum value of the generated original depth data occupies 12 to 14 bits in 16-bit binary numbers, and the highest 2 to 4 bits are always 0, which will make the luminance component reserve 2 to 4 bits of invalid bits (because they are always 0). If you want to further improve the accuracy, you can introduce these invalid bits into the chrominance component and introduce the corresponding number of bits representing data into the luminance component. Therefore, the terminal can perform a left circular shift of N bits on the original depth data, where N is greater than or equal to 1, and the value of N is determined by the number of the highest invalid bits in the depth data generated by the terminal, that is, the value of N is determined by the maximum measurement range of the terminal. For example, when the maximum measurement range of the terminal is 4m, N is 4; when the maximum measurement range of the terminal is 10m, N is 2.
[0063] For example, for the original depth data 0x1A76, the binary form is 0001 1010 0111 0110, the high eight bits are 0001 1010, and the low eight bits are 0111 0110. When N is 3, the left circular shift of 3 bits can be performed on 0001 1010 0111 0110 to obtain 1101 0011 1011 0000, at this time the high eight bits of the original depth data become 1101 0011, and the low eight bits become 1011 0000.
[0064] It should be noted that the operation of left circular shift of N bits can be replaced by an operation with the same effect, as long as the data obtained after the operation is the same as the data obtained by performing the left circular shift of N bits.
[0065] 202、The terminal reads the 16-bit binary original depth data into the local memory;
[0066] In this embodiment, step 202 is similar to step 101 in the foregoing embodiments, which will not be described here.
[0067] 203、The terminal obtains the end mode of the local machine;
[0068] In practical application, the end mode is divided into big-endian mode and little-endian mode. The big-endian mode is that the high byte of data is stored in the low address of memory, and the low byte of data is stored in the high address of memory. Such storage mode is somewhat similar to processing data as a string in sequence: the address increases from small to large, and data is placed from high bit to low bit, which is consistent with our reading habit. The little-endian mode is that the high byte of data is stored in the high address of memory, and the low byte of data is stored in the low address of memory. Such storage mode effectively combines the high and low of the address with the weight of data bits. For example, for a data 0x1234, in the big-endian mode, 0x12 is stored in the low address, and 0x34 is stored in the high address; in the little-endian mode, 0x34 is stored in the low address, and 0x12 is stored in the high address. As long as the end mode is known, the original depth data can be known as what kind of target depth data is stored, so the terminal needs to obtain the end mode of the local machine.
[0069] 204. The terminal determines whether the end mode is the big-endian mode, if yes, step 211 is executed, if not, step 205 is executed.
[0070] After obtaining the end mode of the local machine, the terminal can determine whether the end mode is the big-endian mode, if it is determined that the end mode is the big-endian mode, step 211 can be executed, if it is determined that the end mode is not the big-endian mode, i.e., it is determined that the end mode is the little-endian mode, step 205 can be executed.
[0071] 205. The terminal determines that the target depth data does not meet the preset input requirement of the YUYV encoder.
[0072] After determining that the end mode of the local machine is the little-endian mode, the terminal can determine that the target depth data does not meet the preset input requirement of the YUYV encoder, and further processing of the target depth data is required before the operation of inputting the target depth data into the YUYV encoder is executed.
[0073] 206. The terminal exchanges the high address byte and the low address byte of the target depth data as a whole.
[0074] 207. The terminal inputs the target depth data into the YUYV encoder to obtain corresponding YUYV data.
[0075] In this embodiment, steps 206 to 207 are similar to steps 103 to 104 in the foregoing embodiment, and will not be described here.
[0076] 208. The terminal obtains the memory usage of a target host connected to the local machine.
[0077] After obtaining the YUYV data, the terminal can first acquire the memory usage of the target host connected to the terminal, wherein the memory usage includes the total amount of memory space allocated to the terminal by the target host, the memory space already used by the terminal, and the remaining memory space allocated to the terminal, and the like. The specific manner of acquiring the memory usage includes that the terminal actively sends a request to the target host, the target host feeds back the memory usage to the terminal after receiving the request, the target host periodically sends the memory usage to the terminal, the terminal locally saves the memory usage, and directly acquires the memory usage from the local terminal, and the like, which are not limited here.
[0078] 209. The terminal extracts the remaining memory space allocated to the terminal from the memory usage;
[0079] After acquiring the memory usage, the terminal can extract the remaining memory space allocated to the terminal from the memory usage, so as to select a suitable compression manner according to the capacity of the remaining memory space to compress the YUYV data.
[0080] 210. When the remaining memory space is greater than the compression threshold, the terminal performs high-fidelity compression on the luminance component of the YUYV data and performs high-fidelity compression on the chrominance component of the YUYV data; when the remaining memory space is less than or equal to the compression threshold, the terminal performs high-fidelity compression on the luminance component of the YUYV data and performs low-fidelity compression on the chrominance component of the YUYV data.
[0081] After obtaining the remaining memory space, the terminal can compare the remaining memory space with the preset compression threshold. If the remaining memory space is greater than the compression threshold, the terminal can perform high-fidelity compression on the luminance component and the chrominance component of the YUYV data; if the remaining memory space is less than or equal to the compression threshold, the terminal can perform high-fidelity compression on the luminance component of the YUYV data and perform low-fidelity compression on the chrominance component of the YUYV data.
[0082] 211. The terminal determines that the target depth data meets the preset input requirement of the YUYV encoder.
[0083] After determining that the end mode of the terminal is the big-end mode, the terminal can determine that the target depth data meets the preset input requirement of the YUYV encoder, and then directly perform steps 207 to 210.
[0084] In the embodiment, the operation of cyclically shifting left N bits of the original depth data can make the luminance component retain more valid bits, thereby further reducing the error between the decompressed depth data and the original depth data. Moreover, by comparing the remaining storage space of the target host with the preset compression threshold, obtaining a comparison result, and flexibly selecting a compression mode according to the comparison result, the flexibility of compressing the original depth data is improved.
[0085] Referring to Figure 3 In the embodiment, one embodiment of the data compression device includes:
[0086] The reading unit 301 is configured to read 16-bit binary original depth data into a local memory to obtain target depth data, and the target depth data includes a low address byte and a high address byte.
[0087] The judging unit 302 is configured to judge whether the target depth data meets the preset input requirement of a YUYV encoder, and the YUYV encoder is configured to encode the input depth data into YUYV format.
[0088] The overall interchanging unit 303 is configured to interchange the low address byte and the high address byte of the target depth data as a whole when the judging unit 302 determines that the target depth data does not meet the preset input requirement of the YUYV encoder, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte of the target depth data is the same as the low eight bits of the original depth data.
[0089] The input unit 304 is configured to input the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein the low address byte of the target depth data is used as the luminance component of the YUYV data, and the high address byte of the target depth data is used as the chrominance component of the YUYV data.
[0090] The compression unit 305 is configured to compress the YUYV data to obtain compressed data.
[0091] In this embodiment, before the input unit 304 converts the target depth data into YUYV data, the judging unit 302 first judges whether the target depth data meets the preset input requirement of the YUYV encoder. If it is determined that the target depth data does not meet the preset input requirement of the YUYV encoder, the overall interchanging unit 303 first interchanges the high address byte and the low address byte of the target depth data, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data. Then, the target depth data is converted into YUYV data, wherein the low address byte of the target depth data is the luminance component of the YUYV data, and the high address byte is the chroma component of the YUYV data. Finally, the compression unit 305 compresses the YUYV data, so as to realize the compression of the target depth data. At the same time, even if the chroma component introduces errors, the error of the decompressed depth data and the original depth data will only be limited to the low eight bits, which is beneficial to reduce the error.
[0092] Referring to Figure 4 Another embodiment of the data compression device in the present application includes:
[0093] The reading unit 401 is configured to read 16-bit binary original depth data into the local memory to obtain target depth data, wherein the target depth data includes a low address byte and a high address byte.
[0094] The judging unit 402 is configured to judge whether the target depth data meets the preset input requirement of the YUYV encoder, wherein the YUYV encoder is configured to encode the input depth data into YUYV format.
[0095] The overall interchanging unit 403 is configured to interchange the high address byte and the low address byte of the target depth data when the judging unit 402 determines that the target depth data does not meet the preset input requirement of the YUYV encoder, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data.
[0096] The input unit 404 is configured to input the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein the low address byte of the target depth data is the luminance component of the YUYV data, and the high address byte is the chroma component of the YUYV data.
[0097] The compression unit 405 is configured to compress the YUYV data to obtain compressed data.
[0098] In this embodiment, the judging unit 402 includes:
[0099] The obtaining module 4021 is configured to obtain the end mode of the local machine.
[0100] The judging module 4022 is configured to judge whether the end mode is a big-end mode.
[0101] The first determining module 4023 is configured to determine that the target depth data meets the preset input requirement of the YUYV encoder when the judging module determines that the end mode is the big-end mode.
[0102] The second determining module 4024 is configured to determine that the target depth data does not meet the preset input requirement of the YUYV encoder when the judging module determines that the end mode is not the big-end mode.
[0103] In this embodiment, the data compression device further includes:
[0104] The shifting unit 406 is configured to cyclically left shift the original depth data by N bits, where N is greater than or equal to 1.
[0105] In this embodiment, the data compression unit 405 is specifically configured to:
[0106] Obtain the memory usage of a target host connected to the local host;
[0107] Extract the remaining storage space allocated to the local host from the memory usage;
[0108] When the remaining storage space is greater than a compression threshold, perform high-fidelity compression on the luminance component of the YUYV data and perform high-fidelity compression on the chroma component of the YUYV data; and when the remaining storage space is less than or equal to the compression threshold, perform high-fidelity compression on the luminance component of the YUYV data and perform low-fidelity compression on the chroma component of the YUYV data.
[0109] In this embodiment, the functions of the units and modules correspond to the steps in the foregoing Figure 2 embodiments, and thus are not described herein again.
[0110] Please refer to Figure 5 Another embodiment of the data compression device in this embodiment includes:
[0111] The processor 501, the memory 502, the input / output unit 503, and the bus 504;
[0112] The processor 501 is connected to the memory 502, the input / output unit 503, and the bus 504;
[0113] In this embodiment, the functions of the processor 501 correspond to the steps in the foregoing Figures 1 to 2 embodiments, and thus are not described herein again.
[0114] This embodiment of the application further provides a TOF camera, including:
[0115] One or more processors;
[0116] a memory for storing one or more programs;
[0117] when the one or more programs are executed by one or more processors, the data compression method in the embodiment shown is implemented. Figures 1 to 2
[0118] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
[0119] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0120] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0121] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0122] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the various embodiments of the method of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, read-only memory), a random access memory (RAM, random access memory), a magnetic disk or an optical disk, and various media that can store program codes.
Claims
1. A data compression method characterized by, The method comprises the following steps: reading 16-bit binary original depth data into local memory to obtain target depth data, the target depth data comprising a low address byte and a high address byte; determining whether the target depth data meets preset input requirements of a YUYV encoder, the YUYV encoder being configured to encode input depth data into YUYV format; if not, swapping the high address byte and the low address byte of the target depth data as a whole, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data; inputting the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein the low address byte of the target depth data is used as the luminance component of the YUYV data, and the high address byte is used as the chroma component of the YUYV data; performing data compression on the YUYV data to obtain compressed data; the determination of whether the target depth data meets the preset input requirements of the YUYV encoder comprises the following steps: obtaining an end mode of the local machine; the end mode comprises a big-endian mode or a little-endian mode; the big-endian mode means that the high byte of data is stored in the low address of the memory, and the low byte of data is stored in the high address of the memory; the little-endian mode means that the high byte of data is stored in the high address of the memory, and the low byte of data is stored in the low address of the memory; determining whether the end mode is the big-endian mode; if yes, it is determined that the target depth data meets the preset input requirements of the YUYV encoder; if not, it is determined that the target depth data does not meet the preset input requirements of the YUYV encoder.
2. The data compression method of claim 1, wherein, Before the step of reading the 16-bit binary original depth data into the local memory, the method further comprises the following step: cyclically shifting the original depth data to the left by N bits, wherein N is greater than or equal to 1.
3. The data compression method according to claim 1 or 2, characterized in that, The data compression on the YUYV data comprises the following steps: obtaining the memory usage of a target host connected to the local machine; performing data compression on the YUYV data according to the memory usage.
4. The data compression method of claim 3, wherein, The data compression on the YUYV data according to the memory usage comprises the following steps: extracting the remaining storage space allocated to the local machine from the memory usage; when the remaining storage space is greater than a compression threshold, performing high-fidelity compression on the luminance component of the YUYV data and performing high-fidelity compression on the chroma component of the YUYV data; when the remaining storage space is less than or equal to the compression threshold, performing high-fidelity compression on the luminance component of the YUYV data and performing low-fidelity compression on the chroma component of the YUYV data.
5. A data compression device, characterized by, The method comprises the following steps: a reading unit configured to read 16-bit binary original depth data into local memory to obtain target depth data, the target depth data comprising a low address byte and a high address byte; a determination unit configured to determine whether the target depth data meets preset input requirements of a YUYV encoder, the YUYV encoder being configured to encode input depth data into YUYV format; The whole interchanging unit is configured to interchange the high address byte and the low address byte of the target depth data as a whole when the judging unit determines that the target depth data does not meet the preset input requirement of the YUYV encoder, so that the low address byte of the target depth data is the same as the high eight bits of the original depth data, and the high address byte is the same as the low eight bits of the original depth data; The input unit is configured to input the target depth data into the YUYV encoder to obtain corresponding YUYV data, wherein the low address byte of the target depth data is used as the luminance component of the YUYV data, and the high address byte is used as the chroma component of the YUYV data; The compression unit is configured to perform data compression on the YUYV data to obtain compressed data. The judging unit comprises: The acquisition module is configured to acquire an end mode of a local machine; the end mode comprises a big-endian mode or a little-endian mode; the big-endian mode refers to that a high byte of data is stored in a low address of a memory, and a low byte of data is stored in a high address of the memory; the little-endian mode refers to that the high byte of data is stored in the high address of the memory, and the low byte of data is stored in the low address of the memory; The judging module is configured to judge whether the end mode is the big-endian mode; The first determining module is configured to determine that the target depth data meets the preset input requirement of the YUYV encoder when the judging module determines that the end mode is the big-endian mode; The second determining module is configured to determine that the target depth data does not meet the preset input requirement of the YUYV encoder when the judging module determines that the end mode is not the big-endian mode.
6. The data compression device of claim 5, wherein, The data compression device further comprises: The shift unit is configured to cyclically left shift original depth data by N bits, wherein N is greater than or equal to 1.
7. A data compression device, characterized by, It comprises: a processor, a memory, an input / output unit and a bus; the processor is connected with the memory, the input / output unit and the bus; the memory stores a program, and the processor invokes the program to execute the data compression method in any one of claims 1 to 4.
8. A TOF camera, characterized by It comprises: one or more processors; a memory configured to store one or more programs; when the one or more programs are executed by the one or more processors, the data compression method in any one of claims 1 to 4 is implemented.
9. A computer readable storage medium, the computer readable storage medium stores a program, when the program runs on a computer, the computer executes the data compression method in any one of claims 1 to 4.
Citation Information
Patent Citations
System and method for adaptively configuring dynamic range for ultrasound image display
CN111819465A
Faster image processing
US20080107174A1