A structured light encoding and decoding method, device and storage medium

By generating a Gray code with limited width and width of the stripe, limiting the width range of the stripe, the impact of stripe width on measurement accuracy in structured light three-dimensional reconstruction is solved, and the three-dimensional reconstruction effect with high robustness and anti-interference performance is achieved.

CN113920209BActive Publication Date: 2025-05-16武汉库柏特科技股份有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111058242.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-09
Publication Date
2025-05-16
Estimated Expiration
2041-09-09

AI Technical Summary

Technical Problem

In structured light three-dimensional reconstruction technology, projected stripes are too narrow and can easily lead to blur, while too wide may lead to local overdarkness or overexposure, affecting measurement accuracy.

Method used

By generating Gray codes with limited width and width of the stripe, limiting the width range of the stripe, solving the impact of the projected stripe width on measurement accuracy.

Benefits of technology

It achieves the effect of high robustness and strong anti-interference performance in three-dimensional reconstruction, and improves the measurement accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113920209B_ABST
    Figure CN113920209B_ABST
Patent Text Reader

Abstract

The present application relates to a structured light encoding and decoding method, device and storage medium. The structured light encoding method comprises: placing a corresponding number of binary codes generated according to a preset number of coding bits into a first array in a preset order; moving the first two binary codes located at the head of the first array into the tail of a second array; searching for the binary code that meets the preset conditions from the head of the first array; wherein the preset conditions are set based on Gray code and a preset stripe width range; whenever the binary code that meets the preset conditions is searched, the binary code that meets the preset conditions is moved from the first array to the tail of the second array; when the length of the second array is equal to a preset value, a coding lookup table is generated according to the second array. The technical solution of the present application has high robustness and strong anti-interference performance in structured light three-dimensional reconstruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of structured light three-dimensional reconstruction, and in particular to a structured light encoding and decoding method, device and storage medium. Background Art

[0002] The acquisition of three-dimensional stereo images has important research and application value for computer vision and robotics, and has been widely used in related fields such as face recognition and automated measurement.

[0003] In the non-contact 3D measurement technology based on structured light, the stripes in the projected coded pattern in the surface structured light measurement method should have clear boundaries. However, if the projected stripes are too narrow, it is easy to cause blurring of the stripes, and if the projected stripes are too wide, it is easy to cause problems such as local darkness or overexposure, affecting the measurement accuracy. Summary of the invention

[0004] Embodiments of the present invention provide structured light encoding and decoding methods, devices, equipment and storage media, aiming to improve the robustness in three-dimensional reconstruction.

[0005] In a first aspect, an embodiment of the present invention provides a structured light encoding method, including:

[0006] Putting a corresponding number of binary codes generated according to a preset number of encoding bits into a first array in a preset order;

[0007] Move the first two binary codes located at the head of the first array to the tail of the second array;

[0008] Searching for the binary code that meets a preset condition starting from the head of the first array; wherein the preset condition is set based on a Gray code and a preset stripe width range;

[0009] Whenever the binary code that meets the preset condition is searched, the binary code that meets the preset condition is moved from the first array to the tail of the second array;

[0010] When the length of the second array is equal to a preset value, a coding lookup table is generated according to the second array.

[0011] In a second aspect, an embodiment of the present invention provides a structured light decoding method, based on a coding lookup table generated by the structured light coding method of the first aspect, comprising:

[0012] Identify the light stripes and dark stripes in the acquired preset number of stripe images, and obtain the Gray code corresponding to the preset pixel points in the stripe image;

[0013] According to the coding lookup table, a coding value corresponding to the Gray code, a first coding value and a second coding value adjacent to the coding value, a first Gray code corresponding to the first coding value, and a second Gray code corresponding to the second coding value are obtained;

[0014] Determine a first fringe pattern according to the Gray code and the first Gray code, and determine a boundary position of bright and dark fringes near the preset pixel point in the first fringe pattern as a first boundary position;

[0015] Determine a second fringe pattern according to the Gray code and the second Gray code, and determine a boundary position of the bright and dark fringes near the preset pixel point in the second fringe pattern as a second boundary position;

[0016] A sub-pixel precision decoding value of the preset pixel point is determined according to the encoded value, the position of the preset pixel point in the fringe pattern, the first boundary position, and the second boundary position.

[0017] In a third aspect, an embodiment of the present invention provides a structured light encoding device, including:

[0018] A binary code generation module, used for placing a corresponding number of binary codes generated according to a preset number of encoding bits into a first array in a preset order;

[0019] A head binary code moving module, used for moving the first two binary codes located at the head of the first array to the tail of the second array;

[0020] A search module, configured to search for the binary code satisfying a preset condition starting from the head of the first array; wherein the preset condition is set based on a Gray code and a preset stripe width range;

[0021] a conditional binary code moving module, configured to move the binary code satisfying the preset condition from the first array to the tail of the second array whenever the binary code satisfying the preset condition is found;

[0022] The coding lookup table generating module is used to generate a coding lookup table according to the second array when the length of the second array is equal to a preset value.

[0023] In a fourth aspect, an embodiment of the present invention provides a structured light decoding device, which includes:

[0024] A Gray code acquisition module is used to identify the light stripes and dark stripes in the acquired preset number of stripe images, and obtain Gray codes corresponding to preset pixel points in the stripe images;

[0025] A table lookup module, configured to obtain, according to the coding lookup table, a coding value corresponding to the Gray code, a first coding value and a second coding value adjacent to the coding value, a first Gray code corresponding to the first coding value, and a second Gray code corresponding to the second coding value;

[0026] A first boundary position determination module, configured to determine a first fringe pattern according to the Gray code and the first Gray code, and determine a boundary position of the bright and dark fringes near the preset pixel point in the first fringe pattern as a first boundary position;

[0027] A second boundary position determination module, used to determine a second fringe pattern according to the Gray code and the second Gray code, and determine the boundary position of the bright and dark fringes near the preset pixel point in the second fringe pattern as the second boundary position;

[0028] A decoding value determination module is used to determine the sub-pixel precision decoding value of the preset pixel point according to the encoded value, the position of the preset pixel point in the fringe pattern, the first boundary position and the second boundary position.

[0029] In a fifth aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:

[0030] one or more processors;

[0031] A memory for storing one or more programs;

[0032] When the one or more programs are executed by the one or more processors, the one or more processors implement the structured light encoding method or the structured light decoding method provided by any embodiment of the present invention.

[0033] In a sixth aspect, an embodiment of the present invention provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute a structured light encoding method or a structured light decoding method as provided in any embodiment of the present invention.

[0034] The structured light encoding and decoding method, device, equipment and storage medium provided in the embodiments of the present invention compile a Gray code with limited stripe width. Since the width range of the stripes is limited, the problem of the influence of the projected stripe width on the measurement accuracy is solved, and the effect of high robustness and strong anti-interference performance in three-dimensional reconstruction is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 A flow chart of a structured light encoding method provided in Embodiment 1 of the present invention;

[0036] Figure 2A flow chart of a structured light encoding method provided in Embodiment 2 of the present invention;

[0037] Figure 3 A flowchart of a structured light decoding method provided in Embodiment 3 of the present invention;

[0038] Figure 4 A schematic diagram of the structure of a structured light encoding device provided in Embodiment 4 of the present invention;

[0039] Figure 5 A schematic diagram of the structure of a structured light decoding device provided in Embodiment 5 of the present invention;

[0040] Figure 6 A schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention;

[0041] Figure 7 Schematic diagram of a structured light measurement device in Embodiment 3 of the present invention. DETAILED DESCRIPTION

[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0043] Embodiment 1

[0044] Figure 1 This is a flow chart of a structured light encoding method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where structured light encoding is performed during three-dimensional measurement and reconstruction. The method can be performed by a structured light encoding device, which can be implemented by hardware and / or software and can generally be integrated in an electronic device. The method specifically includes:

[0045] Step 110, placing a corresponding number of binary codes generated according to a preset number of coding bits into a first array in a preset order;

[0046] Among them, the coding value to be encoded can be set, and the coding value is in decimal, which can be determined according to the resolution of the optical machine projection, that is, the number of pixel rows and columns projected in the horizontal and vertical directions. According to the coding value, the preset coding bit number, that is, the number of bits of the binary code, can be determined. For example, taking 8*8 resolution as an example, the Gray code of the row and column are both 3-bit binary codes. The corresponding number of binary codes generated according to the preset coding bit number, and these binary codes are placed in the first array in a preset order. The preset order can be the size order of the binary code. For example, the binary code is placed in the first array in order from small to large, then the head in the first array is the smallest binary code, and the tail is the largest binary code. Optionally, before placing the corresponding number of binary codes generated according to the preset number of coding bits into the first array in a preset order, the method further includes: when it is necessary to encode 0 to M-1, rounding up the logarithm of M with a base of 2 as the preset number of coding bits; wherein M is a positive integer; for example, the preset number of coding bits is calculated by the following formula: n=ceil(log2(M)); placing the corresponding number of binary codes generated according to the preset number of coding bits into the first array in a preset order includes: generating a binary code from 0 to (2 n -1) as the binary code and put it into the first array in ascending order; wherein n is the preset number of encoding bits.

[0047] Step 120, moving the first two binary codes located at the head of the first array to the tail of the second array;

[0048] The second array is a pre-generated empty array, and the first two binary codes at the head of the first array are removed from the first array and put into the second array, and the original order is still maintained in the second array.

[0049] Step 130, searching for the binary code that meets a preset condition starting from the head of the first array;

[0050] The preset condition is set based on the Gray code and the preset stripe width range. Optionally, the preset condition is: the binary code in the first array and the binary code at the end of the second array have only one bit difference, and the width of the complete stripe formed by the binary code in the second array and the first array belongs to the preset stripe width range. The preset stripe width range can be pre-set, and the maximum stripe width W is set. max , minimum width W min The code values ​​of two adjacent pixels in the Gray code are different in only one bit. Gray codes with limited stripe width have the characteristics of high robustness and strong anti-interference performance in structured light 3D reconstruction because they limit the maximum and minimum widths of the stripes.

[0051] Step 140: Whenever the binary code that meets the preset condition is found, the binary code that meets the preset condition is moved from the first array to the tail of the second array;

[0052] The binary codes satisfying the preset conditions are searched sequentially from the head of the first array, and whenever a binary code satisfying the preset conditions is found, the binary code is moved out of the first array and moved into the tail of the second array.

[0053] Step 150: When the length of the second array is equal to a preset value, generate a coding lookup table according to the second array.

[0054] Among them, as the binary code that meets the preset conditions is searched and moved from the first array to the tail of the second array, the length of the second array will gradually increase. When the length of the second array is equal to the preset value, the search for the binary code that meets the preset conditions can be ended, and then a coding lookup table is generated according to the second array. The preset value can be the number of coding values ​​that need to be encoded. Through the structured light encoding method provided in this embodiment, Gray code encoding with stripe width that meets the requirements can be screened out.

[0055] The technical solution of this embodiment compiles a Gray code with limited stripe width. Since the width range of the stripes is limited, the problem of the influence of the projected stripe width on the measurement accuracy is solved, and the effect of high robustness and strong anti-interference performance in three-dimensional reconstruction is achieved.

[0056] Embodiment 2

[0057] Figure 2A flowchart of structured light encoding is provided for the second embodiment of the present invention. This embodiment is further refined on the basis of the above technical solution. It may be that whenever the binary code that meets the preset condition is searched, after the binary code that meets the preset condition is moved from the first array to the tail of the second array, it also includes: when the binary code that meets the preset condition cannot be found in the first array, and the length of the second array is less than the preset value, the fourth to the tail of the binary code in the second array is moved to the head of the first array, and the third binary code in the second array is moved to the tail of the first array, and the number of iterations is increased by one; if the current number of iterations is less than the preset number of iterations, return to execute the operation of searching for the binary code that meets the preset condition from the head of the first array. Alternatively, when the binary code that meets the preset condition cannot be found in the first array and the length of the second array is less than the preset value, the fourth to the last binary code in the second array is moved to the head of the first array, and the third binary code in the second array is moved to the tail of the first array, and after the number of iterations is increased by one, it further includes: if the current number of iterations is equal to the preset number of iterations, adjusting the preset stripe width range, and returning to execute the operation of placing the generated binary code into the first array in a preset order. The method specifically includes:

[0058] Step 210: Put the corresponding number of binary codes generated according to the preset number of coding bits into the first array in a preset order;

[0059] Step 220, moving the first two binary codes located at the head of the first array to the tail of the second array;

[0060] Step 230: Searching for the binary code that meets a preset condition starting from the head of the first array;

[0061] Step 240: Whenever the binary code that meets the preset condition is found, the binary code that meets the preset condition is moved from the first array to the tail of the second array;

[0062] Step 250: when no binary code that meets the preset condition is found in the first array and the length of the second array is less than the preset value, the fourth to the last binary code in the second array is moved to the head of the first array, the third binary code in the second array is moved to the tail of the first array, and the number of iterations is increased by one;

[0063] Step 260: If the current number of iterations is less than the preset number of iterations, return to step 230.

[0064] Step 270 : If the current number of iterations is equal to the preset number of iterations, adjust the preset stripe width range and return to step 210 .

[0065] The preset number of iterations may be preset. If the number of iterations exceeds the preset number of iterations, the preset stripe width range needs to be adjusted. The maximum stripe width and / or the minimum stripe width may be adjusted.

[0066] Step 280: When the length of the second array is equal to a preset value, generate a coding lookup table according to the second array.

[0067] The technical solution of this embodiment can adjust the preset stripe width range during the process of screening Gray code to screen out Gray code with stripe width that meets the requirements.

[0068] Embodiment 3

[0069] Figure 3 This is a flow chart of a structured light decoding method provided in Embodiment 3 of the present invention. This embodiment is applicable to the case where a coding pattern of surface structured light is decoded during three-dimensional measurement and reconstruction. The method can be executed by a structured light decoding device, which can be implemented by hardware and / or software and can generally be integrated in an electronic device. The method is based on a coding lookup table generated in any of the above structured light coding methods, and specifically includes:

[0070] Step 310: Identify the bright stripes and dark stripes in the acquired preset number of stripe patterns, and obtain Gray codes corresponding to preset pixel points in the stripe patterns;

[0071] Among them, the bright stripes in the stripe pattern can be recorded as 1, and the dark stripes can be recorded as 0, and the Gray code (represented by G) corresponding to the preset pixel point can be identified based on this. According to the Gray code generated by the above encoding method, the optical machine projects a preset number of stripe patterns, and the camera synchronously collects a preset number of stripe patterns. The structured light measurement device for projecting and collecting stripe patterns is as follows Figure 7 As shown. The preset number is the number of bits of the Gray code. The preset pixel point is a pixel point in the fringe image, and the position in each fringe image is the same. The position of the preset pixel point in the fringe image is b, and the Gray code G of the corresponding number of bits can be obtained by processing the preset number of fringe images at this point.

[0072] Step 320: Obtain, according to the coding lookup table, a coding value corresponding to the Gray code, a first coding value and a second coding value adjacent to the coding value, a first Gray code corresponding to the first coding value, and a second Gray code corresponding to the second coding value;

[0073] The code lookup table is queried to obtain the code value (expressed as B) corresponding to the Gray code G. The adjacent codes of the code value B, the first code value (expressed as B-1) and the second code value (expressed as B+1) are found according to the code lookup table. The first Gray code G1 corresponding to the first code value B-1 and the second Gray code G2 corresponding to the second code value B-2 can also be found from the code lookup table.

[0074] Step 330: determining a first fringe pattern according to the Gray code and the first Gray code, and determining a boundary position of the bright and dark fringes near the preset pixel point in the first fringe pattern as a first boundary position;

[0075] The ranking position of the first fringe pattern in the preset number of fringe patterns may be calculated according to the following formula:

[0076] i1=log2(G xor G1)+1

[0077] Among them, i1 is the sorting position of the first fringe pattern in the preset number of fringe patterns, G is the Gray code, G1 is the first Gray code, and xor is an exclusive OR operation.

[0078] Step 340: determining a second fringe pattern according to the Gray code and the second Gray code, and determining a boundary position of the bright and dark fringes near the preset pixel point in the second fringe pattern as a second boundary position;

[0079] The ranking position of the second fringe pattern in the preset number of fringe patterns may be calculated according to the following formula:

[0080] i2=log2(G xor G2)+1

[0081] Among them, i2 is the sorting position of the second fringe pattern in the preset number of fringe patterns, G is the Gray code, G2 is the second Gray code, and xor is an exclusive OR operation.

[0082] Step 350: Determine a sub-pixel precision decoding value of the preset pixel point according to the encoded value, the position of the preset pixel point in the fringe pattern, the first boundary position, and the second boundary position.

[0083] Wherein, determining the sub-pixel precision decoding value of the preset pixel point according to the coded value B, the position of the preset pixel point in the fringe pattern, the first boundary position and the second boundary position may include:

[0084] The sub-pixel precision decoding value of the preset pixel is calculated according to the following formula:

[0085] B' = B + ((b-b1) / (b2-b1)-0.5)

[0086] Among them, B' is the sub-pixel precision decoding value, B is the encoded value, b is the position of the preset pixel point in the fringe pattern, b1 is the first boundary position, and b2 is the second boundary position.

[0087] The technical solution of this embodiment is a sub-pixel decoding solution designed for Gray code encoding with limited stripe width, which is different from other decoding solutions. Other decoding solutions are for general Gray code encoding solutions. Extracting sub-pixel positions only needs to be completed on one stripe image. However, due to the encoding characteristics of Gray code with limited stripe width, two stripe images are required to extract sub-pixel positions. Therefore, it is necessary to determine which two stripe images are needed so as to combine the boundaries extracted from the two stripe images into the final sub-pixel position. According to the encoding characteristics of Gray code with limited stripe width, the decoding accuracy is improved to sub-pixel accuracy, thereby improving the accuracy of three-dimensional measurement and reconstruction.

[0088] Embodiment 4

[0089] Figure 4 A schematic diagram of the structure of a structured light encoding device provided in Embodiment 4 of the present invention is shown in FIG. Figure 4 As shown, the structured light encoding device includes: a binary code generation module 410, a head binary code movement module 420, a search module 430, a conditional binary code movement module 440 and a coding lookup table generation module 450, wherein:

[0090] A binary code generation module 410, configured to place a corresponding number of binary codes generated according to a preset number of encoding bits into a first array in a preset order;

[0091] A head binary code moving module 420, used to move the first two binary codes located at the head of the first array to the tail of the second array;

[0092] A search module 430, configured to search for the binary code satisfying a preset condition starting from the head of the first array; wherein the preset condition is set based on a Gray code and a preset stripe width range;

[0093] A conditional binary code moving module 440 is used to move the binary code satisfying the preset condition from the first array to the tail of the second array whenever the binary code satisfying the preset condition is found;

[0094] The coding lookup table generating module 450 is configured to generate a coding lookup table according to the second array when the length of the second array is equal to a preset value.

[0095] Optionally, the structured light encoding device further includes:

[0096] an iteration module, configured to, after the binary code satisfying the preset condition is moved from the first array to the tail of the second array whenever the binary code satisfying the preset condition is searched, until the binary code satisfying the preset condition cannot be found in the first array and the length of the second array is less than the preset value, move the binary code from the fourth to the tail in the second array to the head of the first array, move the third binary code in the second array to the tail of the first array, and increase the number of iterations by one;

[0097] The iteration judgment module is used to return to the operation of searching for the binary code that meets the preset condition from the head of the first array if the current iteration number is less than the preset iteration number.

[0098] Optionally, the structured light encoding device further includes:

[0099] The stripe width range adjustment module is used to move the fourth to the last binary code in the second array into the head of the first array and the third binary code in the second array into the tail of the first array when the binary code satisfying the preset condition cannot be found in the first array and the length of the second array is less than the preset value, and after increasing the number of iterations by one, if the current number of iterations is equal to the preset number of iterations, adjust the preset stripe width range and return to execute the operation of placing the generated binary codes into the first array in a preset order.

[0100] Optionally, the structured light encoding device further includes:

[0101] A coding bit determination module, used for, before placing the corresponding number of binary codes generated according to the preset coding bit into the first array in a preset order, when encoding 0 to M-1 is required, rounding up the logarithm of M with base 2 as the preset coding bit number; wherein M is a positive integer;

[0102] Binary code generation module, specifically used for:

[0103] Generate from 0 to (2 n -1) as the binary code and put it into the first array in ascending order; wherein n is the preset number of encoding bits.

[0104] Optionally, the preset condition is: the binary code in the first array and the binary code at the end of the second array have only one bit difference, and the complete stripe width formed by the binary codes in the second array and the first array belongs to the preset stripe width range.

[0105] The structured light encoding device provided in the embodiment of the present invention can execute the structured light encoding method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0106] Embodiment 5

[0107] Figure 5 This is a schematic diagram of the structure of a structured light decoding device provided in Embodiment 5 of the present invention, wherein a coding lookup table generated based on any of the above structured light coding methods is as follows: Figure 5 As shown, the structured light decoding device includes: a Gray code acquisition module 510, a table lookup module 520, a first boundary position determination module 530, a second boundary position determination module 540 and a decoding value determination module 550, wherein:

[0108] Gray code acquisition module 510, used to identify the light stripes and dark stripes in the acquired preset number of stripe images, and obtain the Gray code corresponding to the preset pixel points in the stripe image;

[0109] A table lookup module 520, configured to obtain, according to the coding lookup table, a coding value corresponding to the Gray code, a first coding value and a second coding value adjacent to the coding value, a first Gray code corresponding to the first coding value, and a second Gray code corresponding to the second coding value;

[0110] A first boundary position determining module 530, configured to determine a first fringe pattern according to the Gray code and the first Gray code, and determine a boundary position of the bright and dark fringes near the preset pixel point in the first fringe pattern as a first boundary position;

[0111] A second boundary position determination module 540 is used to determine a second fringe pattern according to the Gray code and the second Gray code, and determine the boundary position of the bright and dark fringes near the preset pixel point in the second fringe pattern as the second boundary position;

[0112] The decoding value determination module 550 is used to determine the sub-pixel precision decoding value of the preset pixel point according to the encoded value, the position of the preset pixel point in the fringe pattern, the first boundary position and the second boundary position.

[0113] Optionally, the first boundary position determining module 530 is specifically configured to:

[0114] The ranking position of the first fringe pattern in the preset number of fringe patterns is calculated according to the following formula:

[0115] i1=log2(G xor G1)+1

[0116] Wherein, i1 is the sorting position of the first fringe pattern in the preset number of fringe patterns, G is the Gray code, G1 is the first Gray code, and xor is an exclusive OR operation;

[0117] The second boundary position determining module 540 is specifically configured to:

[0118] The ranking position of the second fringe pattern in the preset number of fringe patterns is calculated according to the following formula:

[0119] i2=log2(G xor G2)+1

[0120] Among them, i2 is the sorting position of the second fringe pattern in the preset number of fringe patterns, G is the Gray code, G2 is the second Gray code, and xor is an exclusive OR operation.

[0121] Optionally, the decoding value determination module 550 is specifically configured to:

[0122] The sub-pixel precision decoding value of the preset pixel is calculated according to the following formula:

[0123] B' = B + ((b-b1) / (b2-b1)-0.5)

[0124] Among them, B' is the sub-pixel precision decoding value, B is the encoded value, b is the position of the preset pixel point in the fringe pattern, b1 is the first boundary position, and b2 is the second boundary position.

[0125] The structured light decoding device provided in the embodiment of the present invention can execute the structured light decoding method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0126] Embodiment 6

[0127] Figure 6 A schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention is shown in FIG. Figure 6 As shown, the electronic device includes a processor 610, a memory 620, an input device 630, and an output device 640; the number of the processor 610 in the electronic device can be one or more. Figure 6 A processor 610 is taken as an example; the processor 610, the memory 620, the input device 630 and the output device 640 in the electronic device can be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0128] The memory 620, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the structured light encoding method in the embodiment of the present invention (for example, the binary code generation module 410, the head binary code movement module 420, the search module 430, the conditional binary code movement module 440 and the encoding lookup table generation module 450 in the structured light encoding device), or program instructions / modules corresponding to the structured light decoding method in the embodiment of the present invention (for example, the Gray code acquisition module 510, the table lookup module 520, the first boundary position determination module 530, the second boundary position determination module 540 and the decoding value determination module 550 in the structured light decoding device). The processor 610 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 620, that is, realizes the above-mentioned structured light encoding method or structured light decoding method.

[0129] The memory 620 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 620 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 620 may further include a memory remotely arranged relative to the processor 610, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0130] The input device 630 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device, and can also be a camera for collecting images. The output device 640 can include a display device such as a display screen, and can also be an optical machine for projecting a fringe pattern.

[0131] Embodiment 7

[0132] Embodiment 7 of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a structured light encoding method when executed by a computer processor, including:

[0133] Putting a corresponding number of binary codes generated according to a preset number of encoding bits into a first array in a preset order;

[0134] Move the first two binary codes located at the head of the first array to the tail of the second array;

[0135] Searching for the binary code that meets a preset condition starting from the head of the first array; wherein the preset condition is set based on a Gray code and a preset stripe width range;

[0136] Whenever the binary code that meets the preset condition is searched, the binary code that meets the preset condition is moved from the first array to the tail of the second array;

[0137] When the length of the second array is equal to a preset value, a coding lookup table is generated according to the second array.

[0138] Alternatively, a structured light decoding method is used to perform a coding lookup table generated based on the structured light coding method in any embodiment of the present invention, comprising:

[0139] Identify the light stripes and dark stripes in the acquired preset number of stripe images, and obtain the Gray code corresponding to the preset pixel points in the stripe image;

[0140] According to the coding lookup table, a coding value corresponding to the Gray code, a first coding value and a second coding value adjacent to the coding value, a first Gray code corresponding to the first coding value, and a second Gray code corresponding to the second coding value are obtained;

[0141] Determine a first fringe pattern according to the Gray code and the first Gray code, and determine a boundary position of bright and dark fringes near the preset pixel point in the first fringe pattern as a first boundary position;

[0142] Determine a second fringe pattern according to the Gray code and the second Gray code, and determine a boundary position of the bright and dark fringes near the preset pixel point in the second fringe pattern as a second boundary position;

[0143] A sub-pixel precision decoding value of the preset pixel point is determined according to the encoded value, the position of the preset pixel point in the fringe pattern, the first boundary position, and the second boundary position.

[0144] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided in an embodiment of the present invention are not limited to the method operations described above, and can also execute related operations in the structured light encoding method or structured light decoding method provided in any embodiment of the present invention.

[0145] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0146] It is worth noting that in the embodiments of the above-mentioned structured light encoding device and structured light decoding device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0147] Although the present invention has been described in detail above by means of general description, specific implementation methods and tests, it is obvious to those skilled in the art that some modifications or improvements may be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all fall within the scope of protection claimed by the present invention.

Claims

1. A structured light encoding method, characterized in that: include: Putting a corresponding number of binary codes generated according to a preset number of encoding bits into a first array in a preset order; Move the first two binary codes located at the head of the first array to the tail of the second array; Searching for the binary code that meets a preset condition starting from the head of the first array; wherein the preset condition is set based on a Gray code and a preset stripe width range; Whenever the binary code that meets the preset condition is searched, the binary code that meets the preset condition is moved from the first array to the tail of the second array; When the length of the second array is equal to a preset value, generating a coding lookup table according to the second array; After the binary code satisfying the preset condition is moved from the first array to the tail of the second array each time the binary code satisfying the preset condition is searched, the method further includes: When the binary code satisfying the preset condition cannot be found in the first array and the length of the second array is less than the preset value, the binary codes from the fourth to the end of the second array are moved to the head of the first array, the third binary code in the second array is moved to the end of the first array, and the number of iterations is increased by one; If the current number of iterations is less than the preset number of iterations, the operation of searching for the binary code that meets the preset condition starting from the head of the first array is returned to be executed.

2. The method according to claim 1, characterized in that: When the binary code satisfying the preset condition cannot be found in the first array and the length of the second array is less than the preset value, the fourth to the last binary code in the second array is moved to the head of the first array, the third binary code in the second array is moved to the tail of the first array, and after the number of iterations is increased by one, the method further includes: If the current number of iterations is equal to the preset number of iterations, the preset stripe width range is adjusted, and the operation of placing the generated binary codes into the first array in a preset order is returned to be executed.

3. The method according to any one of claims 1 to 2, characterized in that: Before placing the corresponding number of binary codes generated according to the preset number of encoding bits into the first array in a preset order, the method further includes: When encoding 0 to M-1 is required, the logarithm of M with base 2 is rounded up to an integer as the preset encoding bit number; wherein M is a positive integer; The step of placing a corresponding number of binary codes generated according to a preset number of encoding bits into a first array in a preset order comprises: Generate from 0 to (2 n -1) as the binary code and put it into the first array in ascending order; wherein n is the preset number of encoding bits.

4. The method according to any one of claims 1 to 2, characterized in that: The preset condition is that the binary code in the first array and the binary code at the end of the second array have only one bit difference, and the complete stripe width formed by the binary codes in the second array and the first array falls within the preset stripe width range.

5. A structured light decoding method, characterized in that: The coding lookup table generated based on any one of claims 1 to 4 comprises: Identify the light stripes and dark stripes in the acquired preset number of stripe images, and obtain the Gray code corresponding to the preset pixel points in the stripe image; According to the coding lookup table, a coding value corresponding to the Gray code, a first coding value and a second coding value adjacent to the coding value, a first Gray code corresponding to the first coding value, and a second Gray code corresponding to the second coding value are obtained; Determine a first fringe pattern according to the Gray code and the first Gray code, and determine a boundary position of bright and dark fringes near the preset pixel point in the first fringe pattern as a first boundary position; Determine a second fringe pattern according to the Gray code and the second Gray code, and determine a boundary position of the bright and dark fringes near the preset pixel point in the second fringe pattern as a second boundary position; Determine a sub-pixel precision decoding value of the preset pixel point according to the coded value, the position of the preset pixel point in the fringe pattern, the first boundary position, and the second boundary position; The step of determining a first fringe pattern according to the Gray code and the first Gray code comprises: The ranking position of the first fringe pattern in the preset number of fringe patterns is calculated according to the following formula: i1=log2(G xor G1)+1 Wherein, i1 is the sorting position of the first fringe pattern in the preset number of fringe patterns, G is the Gray code, G1 is the first Gray code, and xor is an exclusive OR operation; The step of determining a second fringe pattern according to the Gray code and the second Gray code comprises: The ranking position of the second fringe pattern in the preset number of fringe patterns is calculated according to the following formula: i2=log2(G xor G2)+1 Among them, i2 is the sorting position of the second fringe pattern in the preset number of fringe patterns, G is the Gray code, G2 is the second Gray code, and xor is an exclusive OR operation.

6. The method according to claim 5, characterized in that The step of determining the sub-pixel precision decoding value of the preset pixel point according to the coded value, the position of the preset pixel point in the fringe pattern, the first boundary position, and the second boundary position includes: The sub-pixel precision decoding value of the preset pixel is calculated according to the following formula: B' = B + ((b-b1) / (b2-b1)-0.5) Among them, B' is the sub-pixel precision decoding value, B is the encoded value, b is the position of the preset pixel point in the fringe pattern, b1 is the first boundary position, and b2 is the second boundary position.

7. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the structured light encoding method as described in any one of claims 1 to 4 or the structured light decoding method as described in any one of claims 5 to 6.

8. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the structured light encoding method as described in any one of claims 1 to 4, or the structured light decoding method as described in any one of claims 5 to 6 when executed by a computer processor.

Citation Information

Patent Citations

  • Structured light three-dimensional measurement method based on orthogonal Gray code and line shift combination

    CN105890546A

  • Coded grating projection method in three-dimensional measurement of coding structured light

    CN107490348A

  • Structured light encoding method and device, structured light encoding and decoding method and device, computer equipment and medium

    CN112729166A