A depth map correction method, electronic device and storage medium
By identifying and eliminating abnormal pixels in the unfolded phase map, the problem of shadow and highlight areas caused by the optical-mechanical layout is solved, the accuracy of the depth map is improved, the cost is reduced, and efficient three-dimensional structure detection is achieved.
Patent Information
- Application Number
- CN202410968908.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-19
AI Technical Summary
When detecting components with the existing technology, the accuracy of the depth map is reduced due to the shadow and highlight area problems caused by the light machine lighting from the side, and increasing the number of light machines to compensate for these problems will significantly increase the cost.
By obtaining the target image of the light projected on the surface of the object to be detected, obtain the unfolded phase map and depth map, count the phase values of the pixels in the unfolded phase map to identify abnormal pixels, and eliminate these pixels in the depth map to correct the depth. picture.
While reducing the number of optical machines, it improves the accuracy of the three-dimensional restoration of the product structure, avoids distortion of shadow and highlight areas, and reduces inspection costs.
Smart Images

Figure CN118521515B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of semiconductor technology, and in particular to a depth map correction method, electronic equipment and storage medium. Background Art
[0002] In real-world inspections, in order to minimize blind spots in images caused by occlusion of components, AOI machines generally use a top vertical camera and a side light machine. However, such a layout will bring two problems.
[0003] The first problem is that when the optical machine shines light on the components from the side, the backlight side will form a shadow on the PCB. When the camera captures the image, the fringe pattern information in the shadow area will be distorted or even disappear. This shadow area is reflected in the final restored depth map as a slope with a cross section like an exponential function image, rather than the original PCB surface shape.
[0004] The second problem is that when the optical machine shines light on the component from the side, a small abnormally bright area will be formed at the junction of the component and the PCB board on the side facing the light. This is because the light shining on the wall of the component is reflected by diffuse reflection or secondary reflection and shines on the surface of the accessory board. This highlight area is reflected in the final restored depth map as a slope like the logarithmic function image mentioned above, rather than the original PCB board shape.
[0005] There are two main solutions to this problem in the industry. The first is to change the lighting solution, replace the original CCD industrial camera with a coaxial camera, and then install the optical machine vertically on the top. This allows the optical axis of the optical machine to be parallel to the optical axis of the camera and as close as possible. This avoids the appearance of shadow areas and highlight areas. However, the disadvantage of this is that at the same price, the coaxial camera is far inferior to CCD in terms of optical distortion, frame rate and image quality. This is why many manufacturers do not use this solution on their high-end models.
[0006] The second solution is to arrange additional optical machines at multiple angles based on the original lighting solution. Through multi-angle lighting and subsequent data fusion algorithms, the data from other optical machines can be used to make up for the shadows and highlights in the current optical machine data. The more common solutions in the industry are dual optical machines or quad optical machines, and some manufacturers have even launched solutions with eight optical machines. But the disadvantages of doing so are also obvious, and the cost is much higher than the original solution. Not only because the number of required optical machines has increased, another reason for the high cost is that in order to maintain high-speed detection, cameras and optical machines must have higher acquisition or projection frame rates than before, and the prices of high-speed cameras and high-speed optical machines are also much higher than ordinary cameras and optical machines. Summary of the invention
[0007] In view of this, an embodiment of the present invention provides a depth map correction method, an electronic device and a storage medium. The method can quickly and accurately detect abnormal pixels with abnormal phase values in the unfolded phase map to correct the depth map, thereby reducing the use of multiple optical machines while improving the accuracy of three-dimensional restoration of the product structure.
[0008] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0009] In a first aspect, an embodiment of the present invention provides a depth map correction method, the method comprising:
[0010] Acquire the target image generated by projecting light onto the surface of the object to be inspected;
[0011] Acquire an unfolded phase map and a depth map based on the target image;
[0012] Counting the phase values of the pixels in the unfolded phase image to obtain phase value information, and determining abnormal pixels in the unfolded phase image based on the phase value information;
[0013] Pixels corresponding to the abnormal pixels in the depth map are removed to correct the depth map.
[0014] In some embodiments, the phase value information includes several phase values and the number of pixels corresponding to the several phase values, and determining the abnormal pixel points in the unfolded phase image based on the phase value information includes:
[0015] Obtaining a target threshold based on the number of pixels corresponding to a first phase value and a mode of the number of pixels, wherein the first phase value includes any one of the several phase values, and the mode of the number of pixels is the mode of the number of pixels corresponding to the several phase values;
[0016] If the target threshold is greater than a preset threshold, determining the first phase value to be a target phase value;
[0017] The phase value of each pixel in the unfolded phase image is compared with the target phase value to determine the abnormal pixel in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
[0018] In some embodiments, obtaining the target threshold based on the number of pixels corresponding to the first phase value and the mode of the number of pixels includes:
[0019] The target threshold is obtained by dividing the number of pixels corresponding to the first phase value by the mode of the number of pixels.
[0020] In some embodiments, the phase value information includes several phase values and the number of pixels corresponding to the several phase values, and determining the abnormal pixel points in the unfolded phase image based on the phase value information further includes:
[0021] According to the magnitude of the phase values, the plurality of phase values are sorted to obtain a sorted sequence;
[0022] Based on the number of pixels corresponding to the second phase value and the third phase value, the abnormal pixel point in the unfolded phase image is determined, the second phase value and the third phase value are any two adjacent phase values among several phase values of the sorting sequence, and the third phase value is a phase value next to the second phase value.
[0023] In some embodiments, determining abnormal pixel points in the unfolded phase image based on the number of pixels corresponding to the second phase value and the third phase value includes:
[0024] If the sorting sequence is an ascending sorting sequence, and the number of pixels of the second phase value is equal to zero and the number of pixels of the third phase value is greater than zero, determining the third phase value to be a target phase value;
[0025] Comparing the phase value of each pixel in the unfolded phase image with the target phase value to determine abnormal pixels in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel;
[0026] or,
[0027] If the sorting sequence is a descending sorting sequence, and the number of pixels of the second phase value is greater than zero and the number of pixels of the third phase value is equal to zero, determining the second phase value as a target phase value;
[0028] The phase value of each pixel in the unfolded phase image is compared with the target phase value to determine the abnormal pixel in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
[0029] In some embodiments, before removing the pixel points corresponding to the abnormal pixel points in the depth map to correct the depth map, the method further includes:
[0030] The abnormal pixel point is marked to obtain a pixel marking mask, wherein the pixel marking mask includes a coordinate position of the abnormal pixel point and a correction mark, and the correction mark is used to correct the pixel point corresponding to the abnormal pixel point in the depth map.
[0031] In some embodiments, removing the pixel points corresponding to the abnormal pixel points in the depth map to correct the depth map includes:
[0032] Acquire the coordinate position and correction mark of the abnormal pixel point based on the pixel mark mask;
[0033] Based on the coordinate position of the abnormal pixel point, determining the target pixel point corresponding to the coordinate position in the depth map;
[0034] Based on the correction mark of the abnormal pixel, the depth map is corrected to obtain a corrected depth map, wherein when the correction mark is 1, the target pixel corresponding to the abnormal pixel in the depth map is removed.
[0035] In some embodiments, before counting the phase values of the pixels in the unfolded phase image to obtain phase value information, the method further includes:
[0036] Normalizing the phase value of each pixel in the unwrapped phase image to obtain a first unwrapped phase image;
[0037] Rounding off the phase value of each pixel in the first unwrapped phase image to obtain a second unwrapped phase image;
[0038] The counting of the phase values of the pixels in the unfolded phase image to obtain the phase value information includes:
[0039] The phase values of the pixels in the second unwrapped phase image are counted to obtain the phase value information of the pixels.
[0040] In a second aspect, an embodiment of the present invention provides an electronic device, including:
[0041] A processor, and a memory communicatively connected to the processor;
[0042] The memory stores computer program instructions executable by the processor, and when the computer program instructions are called by the processor, the processor executes any one of the depth map correction methods proposed in the first aspect, or executes steps in any one of the possible implementation methods of any one of the depth map correction methods proposed in the first aspect.
[0043] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, on which is stored computer program instructions executable by a processor, and when the computer program instructions are called by the processor, the processor executes any one of the depth map correction methods proposed in the first aspect, or executes the steps in any one of the possible implementation methods of any one of the depth map correction methods proposed in the first aspect.
[0044] Beneficial effects of the embodiments of the present invention: Different from the prior art, the depth map correction method provided by the embodiments of the present invention includes: obtaining a target image generated by projecting light onto the surface of an object to be detected; obtaining an unfolded phase map and a depth map based on the target image; counting the phase values of pixels in the unfolded phase map to obtain phase value information, and determining abnormal pixels in the unfolded phase map based on the phase value information; and eliminating pixels in the depth map corresponding to abnormal pixels to correct the depth map.
[0045] In the present invention, the abnormal pixels in the unfolded phase image are detected, and then the pixels corresponding to the abnormal pixels are searched and removed in the depth image to correct the depth image, thereby obtaining a corrected depth image. This method performs filtering based on the unfolded phase image, and by utilizing the physical properties of the unfolded phase image, the abnormal pixels with abnormal phase values in the unfolded phase image (corresponding to the shadow area and highlight area of the depth image) are quickly and accurately detected to correct the depth image, thereby minimizing the use of complex optical machines while improving the accuracy of three-dimensional restoration of product structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative work.
[0047] Figure 1 is a schematic diagram of an application scenario of a depth map correction method provided by some embodiments of the present invention;
[0048] Figure 2 is a schematic diagram of the structure of an electronic device provided by some embodiments of the present invention;
[0049] Figure 3 is a schematic flow chart of a depth map correction method provided by some embodiments of the present invention;
[0050] Figure 4 is an unwrapped phase image after the phase value is normalized and rounded in some embodiments of the present invention;
[0051] Figure 5 yes Figure 3 A schematic diagram of a sub-process of step S300 in the depth map correction method shown in the embodiment;
[0052] Figure 6 is an unfolded phase image in which abnormal pixels (corresponding to the shadow area in the depth image) exist in some embodiments of the present invention and the phase values are normalized and rounded;
[0053] Figure 7 yes Figure 3 A schematic diagram of another sub-process of step S300 in the depth map correction method shown in the embodiment;
[0054] Figure 8 is an unfolded phase image in which abnormal pixels (corresponding to the highlighted area in the depth image) exist in some embodiments of the present invention and the phase values are normalized and rounded;
[0055] Fig. 9 is one of the angles of the depth map of the pixel points corresponding to the abnormal pixel points in the shadow area and the highlight area that are not eliminated in some embodiments of the present invention;
[0056] Fig.10 is one of the angles of the depth map for removing pixels corresponding to abnormal pixels in shadow areas and highlight areas in some embodiments of the present invention;
[0057] Fig.11 is another angle of the depth map of the highlighted area and the pixel points corresponding to the abnormal pixel points in the highlighted area in some embodiments of the present invention;
[0058] Fig.12 is another angle of the depth map for removing the highlight area and the pixels corresponding to the abnormal pixels in the highlight area in some embodiments of the present invention;
[0059] Fig.13 It is an unfolded phase image in which there are no abnormal pixels (corresponding to the shadow area and the highlight area in the depth image) and the phase values are normalized and rounded in some embodiments of the present invention. DETAILED DESCRIPTION
[0060] In order to make the purpose and advantages of the embodiments of the present invention easier to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The detailed description of the embodiments of the present invention in the drawings below does not limit the scope of protection claimed by the present invention, but only represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0061] It should be noted that, if no conflict is constituted, the various technical features involved in the embodiments of the present invention described below can be combined with each other, and are all within the scope of protection of the present invention. In addition, although the functional modules are divided in the device or structural schematic diagram, and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order from the module division in the device, or in a different order from the flow chart. In addition, the "first", "second", "third" and other similar expressions used herein do not limit the data and execution order, but are only for the purpose of convenience of explanation and to distinguish between the same or similar items with basically the same functions and effects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features.
[0062] Unless otherwise defined, the technical terms and scientific terms used in this specification have the same meanings as those generally understood by those of ordinary skill in the art of the present invention. The terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. It should be understood that the term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.
[0063] In the semiconductor manufacturing industry, it is usually necessary to use automated optical inspection equipment (AOI) to detect and analyze product appearance, quality, and performance issues. The AOI equipment uses an optical machine to project light on the surface of the product, and uses a camera to capture the fringe pattern projected by the optical machine on the surface of the product. The captured fringe pattern is then decoded to obtain a wrapped phase map. The wrapped phase map is then unwrapped to obtain an unfolded phase map. Finally, the height information of the product surface is extracted from the unfolded phase map to obtain a depth map.
[0064] However, due to the layout of the camera and the optical machine, when the optical machine projects light from the side to the product, a shadow area is formed on the PCB board on the backlight side of the product, and a highlight area is formed at the junction of the product and the PCB board on the light-facing side. When the camera collects images, the fringe pattern information corresponding to the shadow area and the highlight area will be distorted or even disappear directly, resulting in the inability to obtain an accurate fringe pattern, which in turn leads to inaccurate depth map information that is ultimately restored, and the inability to accurately restore the three-dimensional results of the product structure, reducing the accuracy of the three-dimensional results of the product structure.
[0065] If only one optical machine is used to illuminate from the side, the phase information of the light-facing and backlight surfaces of the component will inevitably be lost. The existing technology generally uses multiple optical machines to illuminate at different angles to compensate for the phase information loss mentioned above. However, if the number of optical machines is limited to one due to mechanical structure limitations or other reasons with higher priority, the conditions for implementing the existing technology are not met.
[0066] In view of this, the present application does not change the existing layout of one camera and one optical machine, and effectively controls the cost without increasing it. It performs filtering based on the unfolded phase image, and utilizes the physical properties of the unfolded phase image to quickly and accurately detect abnormal pixels in the unfolded phase image (corresponding to the shadow area and highlight area of the depth image). Then, the pixels corresponding to the abnormal pixels are searched and eliminated in the depth map to correct the depth map (i.e., eliminate the shadow area and highlight area of the depth map) to obtain a corrected depth map, thereby reducing the use of multiple optical machines while improving the accuracy of three-dimensional restoration of the product structure.
[0067] See also Figure 1 , Figure 1 A schematic diagram of an application scenario of a depth map correction method provided by some embodiments of the present invention is shown.
[0068] like Figure 1 As shown, the application scenario includes an electronic device 100. Specifically, the electronic device 100, as a device providing computing and control capabilities, controls a camera or an image acquisition device to obtain a target image generated by projecting light from an optical machine onto the surface of the object to be tested. Among them, the target image can be a fringe image, a dot matrix image, a spot image, etc. Then, after the target image is processed accordingly, a corresponding unfolded phase image and a depth image are obtained. Next, the unfolded phase image is traversed to detect abnormal pixels with abnormal phase values in the unfolded phase image (equivalent to finding the shadow area and highlight area of the depth image), and according to the position information of the abnormal pixel points, the pixel points corresponding to the position information of the abnormal pixel points are searched and removed in the depth map to correct the depth map, obtain a corrected depth map, and output the corrected depth map. Finally, the three-dimensional result of the product structure is accurately restored according to the corrected depth map, thereby improving the accuracy of the three-dimensional restoration of the product structure.
[0069] It should be understood that in order to complete the correction of the depth map, the electronic device 100 also needs to work together with some other software and hardware, including, for example, image sensors, thermal imaging cameras, image processing software, image processing software, display devices, and storage devices.
[0070] It is worth noting that the electronic device 100 may be a laptop computer, a desktop computer, a tablet computer, or other suitable type of device having certain computing and control capabilities. Figure 1In the application scenario shown, the electronic device 100 is a desktop computer, but it does not impose any restrictions on the structure, type, quantity, etc. of the electronic device 100 in other application scenarios. For example, in some other application scenarios, the electronic device 100 may also be a notebook computer, a tablet computer, or other suitable types of devices, and the electronic device 100 in other application scenarios may also be a laptop computer, a tablet computer, or other suitable types of devices. Figure 1 The desktop computer shown in the embodiment may include more or fewer components, or may have the same Figure 1 The embodiments shown are different configurations of desktop computers.
[0071] To facilitate understanding of the depth map correction method provided by the embodiment of the present invention, the electronic device provided by the embodiment of the present invention is first introduced in detail.
[0072] See also Figure 2 , Figure 2 A schematic structural diagram of an electronic device 100 provided in some embodiments of the present invention is shown.
[0073] For example, Figure 2 As shown, the electronic device 100 includes at least one processor 110 and a memory 120 ( Figure 2 In the example of a bus system connection and a processor, the components in the electronic device 100 are coupled together through the bus system 130, and the bus system 130 is used to realize the connection and communication between these components. It is easy to understand that the bus system 130 includes not only a data bus, but also a power bus, a control bus, and a status signal bus. However, for the sake of clarity and brevity, the following description is omitted. Figure 2 In the figure, various buses are labeled as bus system 130. It can be understood that Figure 2 The structure shown in the embodiment is only for illustration and does not impose any limitation on the structure of the electronic device 100. Figure 2 More or fewer components as shown, or with Figure 2 Different configurations shown.
[0074] Specifically, the processor 110 is used to provide computing and control capabilities to control the electronic device 100 to perform corresponding tasks. For example, the electronic device 100 is controlled to perform any one of the depth map correction methods provided in the embodiments of the present invention, or to perform any one of the steps in any possible implementation of any one of the depth map correction methods provided in the embodiments of the present invention. Those skilled in the art can understand that the processor 110 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0075] The memory 120, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, instructions and modules, for example, programs, instructions and modules corresponding to the depth map correction method in the embodiment of the present invention. In some embodiments, the memory 120 may include a program storage area and a data storage area. The program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the processor 110, etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the non-transitory software programs, instructions and modules stored in the memory 120 to implement any depth map correction method provided in the embodiment of the present invention, or execute any step in any implementation of any depth map correction method provided in the embodiment of the present invention. Among them, the memory 120 may include a high-speed random access memory, and may also include a non-transitory memory. For example, at least one disk storage device, a flash memory device or other non-transitory solid-state storage device. In some embodiments, the memory 120 may also include a memory remotely arranged relative to the processor 110, and these remotely arranged memories may be connected to the processor 110 through a communication network. It should be understood that examples of the above-mentioned communication networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks and combinations thereof.
[0076] It should be understood that the execution subject of any depth map correction method provided in the embodiments of the present invention may be any suitable type of electronic device with certain computing and control capabilities. In some possible implementations, any depth map correction method provided in the embodiments of the present invention may be implemented by a processor calling computer program instructions stored in a memory.
[0077] It can be understood from the above that the depth map correction method provided by the embodiment of the present invention can be implemented by various suitable types of electronic devices with certain computing and control capabilities, for example, it can be implemented by the above-mentioned electronic device 100. The depth map correction method provided by the embodiment of the present invention is described below in conjunction with the exemplary application and implementation of the electronic device provided by the embodiment of the present invention.
[0078] See also Figure 3 , Figure 3 A schematic flow chart of a depth map correction method provided by some embodiments of the present invention is shown.
[0079] It is understandable that the depth map correction method provided by the embodiment of the present invention can be applied to the above electronic device (eg, desktop computer). Specifically, the execution subject of the depth map correction method is one or at least two processors of the electronic device.
[0080] like Figure 3 As shown, the depth map correction method includes but is not limited to the following steps S100-S400:
[0081] S100: Acquire a target image generated by projecting light onto the surface of the object to be inspected.
[0082] Specifically, a suitable light source (for example, a laser, a projector, or a structured light source, etc.) is selected, and the light source and camera (for example, an industrial camera, a depth camera, etc.) are installed at a set angle and position, so that the camera is aimed at the object to be inspected so as to be able to clearly capture the image formed by the projected light on the surface of the object to be inspected.
[0083] After installing the light source and camera, calibrate the light source and camera using a calibration plate or other calibration tool to ensure that the image captured by the camera has an accurate correspondence with the pattern projected by the light source. Then select and determine the pattern projected by the light source (such as stripes, dots, or random patterns, etc.) to adapt it to the shape and characteristics of the object to be inspected.
[0084] After determining the projection pattern, the light source is started, and the projection light emitted by the light source is evenly projected onto the surface of the object to be inspected. The camera synchronously collects the light pattern reflected on the surface of the object to be inspected to generate the corresponding target image. The electronic device can then obtain the generated target image, that is, the target image generated by the light projected onto the surface of the object to be inspected.
[0085] It should be understood that after the camera captures the light pattern reflected on the surface of the object to be inspected, it can perform necessary preprocessing (such as denoising, contrast enhancement, etc.) on the captured image, and then save it as a target image, that is, obtain the corresponding target image for subsequent calculation of the unfolded phase map and depth map.
[0086] It is easy to understand that the target image can be a stripe pattern, a dot pattern, a spot pattern or other images, depending on the actual application scenario and the pattern projected by the light source, etc. Technical personnel in this field can generate or obtain the required type of target image according to actual needs, and the embodiments of the present invention do not impose any limitations on this.
[0087] S200: Acquire an unfolded phase map and a depth map based on a target image.
[0088] Specifically, in the embodiment of the present invention, the target image is a fringe pattern, that is, the camera collects the fringe pattern generated by the light source projected on the surface of the object to be detected. In order to accurately measure the phase, it is necessary to collect multiple fringe patterns, and there is a phase difference (for example, 0°, 120° and 240°, etc.) between the fringe patterns of the collected fringe patterns.
[0089] After collecting multiple fringe patterns, the phase value of each pixel in each fringe pattern is calculated by Fourier transform, phase shift method or other phase demodulation algorithm. In some embodiments, the phase value of the pixel can be calculated using the following formula:
[0090]
[0091] in, , , They are the intensity values of the pixels in the fringe pattern when the phase difference is 0°, 120°, and 240° respectively.
[0092] Since the calculated pixel phase value is usually between −𝜋 and 𝜋, in order to obtain a continuous phase distribution, phase unwrapping is required to convert the periodic phase value into a continuous phase value to obtain an unwrapped phase map.
[0093] Specifically, before acquiring the depth map, the system needs to be strictly geometrically calibrated using a calibration plate and related calibration algorithms to determine the relative position and angle between the camera and the light source.
[0094] After the geometric calibration parameters of the system (e.g., the relative position and angle between the camera and the light source) are determined by calibration, the depth value of each pixel is calculated by triangulation based on the obtained unwrapped phase image and the geometric calibration parameters of the system. In some embodiments, the depth value of the pixel can be calculated using the following formula:
[0095]
[0096] Among them, 𝑍 represents the depth value of the pixel, 𝐵 represents the baseline distance between the camera and the light source, and 𝑓 represents the focal length of the camera. Indicates the phase difference.
[0097] After the above calculation, the depth value of each pixel is obtained, and then based on the position and depth value of each pixel, a corresponding depth map is generated.
[0098] S300: Counting the phase values of the pixels in the unfolded phase image to obtain phase value information, and determining abnormal pixels in the unfolded phase image based on the phase value information.
[0099] Specifically, after obtaining the unfolded phase map, each pixel in the unfolded phase map is traversed to obtain the phase value of each pixel, and then the phase values of all the acquired pixels are statistically analyzed to obtain phase value information, and based on the phase value information, it is detected and determined whether the phase value of each pixel in the unfolded phase map is abnormal, so as to screen out abnormal pixels in the unfolded phase map. It should be understood that the phase value information may include: mean, variance, maximum value, minimum value, and histogram, etc.
[0100] In some embodiments, a deviation threshold can be set based on the mean and variance (for example, the deviation threshold can be a preset multiple of the mean + standard deviation). In the process of detecting whether the phase value of each pixel in the unfolded phase image is abnormal, if the phase value of a certain pixel exceeds the set deviation threshold, it means that the phase value of the pixel is abnormal, and the pixel is marked as an abnormal pixel. It can be understood that there can be other methods (for example, box plot method) to detect whether the phase value of each pixel is abnormal, and the embodiment of the present invention does not impose any restrictions on this.
[0101] In some embodiments, after the unwrapped phase image is obtained, before the phase values of the pixels in the unwrapped phase image are counted to obtain the phase value information, the unwrapped phase image may be preprocessed, wherein the preprocessing includes operations such as denoising, smoothing, and normalization to improve the quality of the unwrapped phase image and facilitate subsequent processing and analysis.
[0102] It can be understood that denoising refers to removing noise from the unfolded phase image using filters (e.g., Gaussian filtering, mean filtering, median filtering, etc.). Smoothing refers to smoothing the unfolded phase image to reduce local changes. For example, bilateral filtering can be used to smooth the unfolded phase image while maintaining the edges. Normalization refers to normalizing the phase value of each pixel in the unfolded phase image to a standard range (e.g., [0, 1] or [−𝜋, 𝜋], etc.) for subsequent processing and analysis.
[0103] It should be understood that the preprocessing operation may also include other operations, not limited to denoising, smoothing and normalization, and those skilled in the art may select appropriate preprocessing operations according to actual needs to preprocess the unfolded phase image.
[0104] In some embodiments, the preprocessing operation performed on the unfolded phase image includes normalization and rounding processing, that is, before counting the phase values of the pixels in the unfolded phase image to obtain the phase value information, the depth map correction method further includes but is not limited to the following steps S301-S302:
[0105] S301: Normalizing the phase value of each pixel in the unwrapped phase image to obtain a first unwrapped phase image.
[0106] Exemplarily, the minimum and maximum phase values of pixels in the expanded phase image can be obtained by utilizing corresponding functions (e.g., the min function and the max function in the numpy library), and then a linear normalization method is used. For example, a normalization formula is used to substitute the original phase values of the pixels in the expanded phase image into the normalization formula, thereby mapping the original phase values of the pixels in the expanded phase image, and mapping the original phase values of each pixel from the original range (i.e., minimum value to maximum value) to a new standard range (e.g., [0, 1], [-1, 1] or [−𝜋, 𝜋], etc.), to obtain a first expanded phase image after the phase values of each pixel are normalized (i.e., the expanded phase image after normalization).
[0107] Among them, the normalization formula can be:
[0108]
[0109] in, represents the normalized pixel phase value, represents the original phase value of the pixel in the unwrapped phase image, represents the minimum phase value of a pixel in the unfolded phase image, Represents the maximum phase value of the pixel in the unwrapped phase image.
[0110] It should be understood that the new standard range is the phase value range in which the normalized phase value is located. Those skilled in the art may select and determine any appropriate standard range according to actual needs, and the embodiments of the present invention do not impose any limitation on this.
[0111] In this embodiment, normalization is mainly to uniformly process data under different optical machines. In other embodiments, when the data are from the same optical machine, normalization may not be performed.
[0112] S302: Rounding off the phase value of each pixel in the first unwrapped phase image to obtain a second unwrapped phase image.
[0113] After obtaining the normalized first unwrapped phase image, the decimal part of the normalized phase value of each pixel in the first unwrapped phase image (i.e., the decimal part of the pixel phase value) is rounded off according to the rounding rule by using the corresponding function (e.g., the round function in the numpy library) to obtain the pixel phase value whose rounded value is an integer, thereby obtaining the rounded second unwrapped phase image (i.e., the unwrapped phase image after the phase value is normalized and rounded off). Please refer to Figure 4 , Figure 4 The second unwrapped phase diagram obtained after the phase value is normalized and rounded in some embodiments of the present invention is shown.
[0114] At the same time, in this embodiment, rounding is used to facilitate finding abnormal phase values. When rounding is not used, the phase value is in the shape of a diagonal line, and the position of the phase anomaly is not easy to locate. When rounding is used, the phase value distribution is in the shape of a step, and the position of the phase anomaly is more obvious, which is convenient for subsequent processing. Therefore, in other embodiments, other methods are used to make the phase value distribution in the shape of a step. For example, other forms such as rounding up or rounding down can also achieve similar effects, and are not limited to rounding.
[0115] Correspondingly, counting the phase values of the pixel points in the unfolded phase image to obtain the phase value information refers to counting the phase values of the pixel points in the unfolded phase image (i.e., the second unfolded phase image) obtained after normalization and rounding to obtain the phase value information.
[0116] That is, the phase values of the pixels in the expanded phase image are counted to obtain the phase value information, which specifically includes but is not limited to the following steps S303:
[0117] S303: Counting the phase values of the pixels in the second unwrapped phase image to obtain phase value information of the pixels.
[0118] Specifically, after obtaining the second unfolded phase map, traverse each pixel in the second unfolded phase map, obtain the phase value of each pixel, then perform statistical analysis on the phase values of all the acquired pixels to obtain phase value information, and detect and determine whether the phase value of each pixel in the second unfolded phase map is abnormal based on the phase value information, so as to screen out abnormal pixels in the second unfolded phase map. It should be understood that the phase value information may include: mean, variance, maximum value, minimum value, and histogram, etc.
[0119] In some embodiments, a deviation threshold can be set based on the mean and variance (for example, the deviation threshold can be a preset multiple of the mean + standard deviation). In the process of detecting whether the phase value of each pixel in the second unfolded phase image is abnormal, if the phase value of a certain pixel exceeds the set deviation threshold, it means that the phase value of the pixel is abnormal, and the pixel is marked as an abnormal pixel. It should be understood that there can be other methods (for example, box plot method) to detect whether the phase value of each pixel is abnormal, and the embodiment of the present invention does not impose any restrictions on this.
[0120] In some embodiments, the phase value information obtained by statistics includes several phase values and the number of pixels corresponding to the several phase values.
[0121] See also Figure 5 , Figure 5 A schematic diagram of a sub-flow chart of step S300 in the depth map correction method provided by some embodiments of the present invention is shown.
[0122] like Figure 5 As shown, based on the phase value information, determining the abnormal pixel points in the unfolded phase image specifically includes but is not limited to the following steps S310-S330:
[0123] S310: Obtaining a target threshold based on the number of pixels corresponding to the first phase value and the mode of the number of pixels, wherein the first phase value includes any one of several phase values, and the mode of the number of pixels is the mode of the number of pixels corresponding to the several phase values.
[0124] After obtaining the phase value information through statistics, the mode of the number of pixels corresponding to the several phase values in the phase value information is determined as the pixel number mode. It should be understood that the mode refers to the value with the highest frequency in a set of data. In the embodiment of the present invention, the pixel number mode refers to the number of pixels with the highest frequency among the number of pixels corresponding to the several phase values. For example, the phase value information includes five phase values, which are 110, 115, 120, 125 and 130, respectively. The number of pixels corresponding to the phase value 110 is 20 (i.e., the phase value of 110 exists in 20 pixels of the expanded phase map), the number of pixels corresponding to the phase value 115 is 10 (i.e., the phase value of 115 exists in 10 pixels of the expanded phase map), the number of pixels corresponding to the phase value 120 is 10 (i.e., the phase value of 120 exists in 10 pixels of the expanded phase map), the number of pixels corresponding to the phase value 125 is 25 (i.e., the phase value of 125 exists in 25 pixels of the expanded phase map), and the number of pixels corresponding to the phase value 130 is 15 (i.e., the phase value of 130 exists in 15 pixels of the expanded phase map). Then, the mode of the number of pixels corresponding to the five phase values (i.e., 20, 10, 10, 25, 15) is 10, that is, the mode of the number of pixels is 10. It is easy to understand that the mode of the number of pixels can be one or more. For example, if there are multiple phase values corresponding to the same number of pixels with the highest frequency, then the mode of the number of pixels is the number of pixels corresponding to the multiple phase values.
[0125] Then, according to the number of pixels corresponding to any one of the phase values (i.e., the first phase value) and the determined pixel mode, the target threshold corresponding to the first phase value is calculated. For example, in some embodiments, the number of pixels corresponding to the first phase value and the pixel mode may be added to obtain a first sum value, and the number of pixels corresponding to the first phase value and the pixel mode may be multiplied to obtain a first product value, and then the first sum value may be divided by the first product value to obtain the target threshold corresponding to the first phase value.
[0126] It is easy to understand that there may be other suitable methods to calculate the target threshold corresponding to the first phase value. Those skilled in the art may select a suitable method to calculate the target threshold corresponding to the first phase value according to actual needs, and the embodiments of the present invention do not impose any limitation on this.
[0127] In some embodiments, a target threshold is obtained based on the number of pixels corresponding to the first phase value and the mode of the number of pixels, including but not limited to the following steps S3101:
[0128] S3101: Divide the number of pixels corresponding to the first phase value by the mode of the number of pixels to obtain a target threshold.
[0129] Specifically, in some embodiments, after determining the mode of the number of pixels, the number of pixels corresponding to the first phase value is divided by the mode of the number of pixels to obtain a target threshold corresponding to the first phase value.
[0130] S320: If the target threshold is greater than the preset threshold, determine the first phase value as the target phase value.
[0131] After calculating the target threshold corresponding to the first phase value, the target threshold is compared with the preset threshold to determine whether the first phase value is the target phase value. In some embodiments, when the target threshold is greater than the preset threshold, it indicates that the first phase value is an abnormal phase value, and the first phase value is determined as the target phase value to screen out abnormal pixel points corresponding to phase values equal to the target phase value in the expanded phase map.
[0132] S330: Compare the phase value of each pixel in the unfolded phase image with the target phase value to determine abnormal pixels in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
[0133] Specifically, after determining that the first phase value is the target phase value, traverse each pixel point in the expanded phase image, and compare the phase value of each pixel point in the expanded phase image with the target phase value to determine the abnormal pixel point in the expanded phase image. In some embodiments, if the phase value of a pixel point in the expanded phase image is equal to the target phase value, then the pixel point is an abnormal pixel point, and the pixel point in the expanded phase image is determined as an abnormal pixel point, and the coordinates of the abnormal pixel point and other information are recorded or marked for subsequent processing.
[0134] See also Figure 6 , Figure 6 The figure shows an unfolded phase image after the phase values of abnormal pixels (corresponding to the shadow area in the depth image) are normalized and rounded in some embodiments of the present invention.
[0135] In some embodiments, the phase value information obtained by statistics includes: several phase values and the number of pixels corresponding to the several phase values.
[0136] See also Figure 7 , Figure 7 Another sub-flow diagram of step S300 in the depth map correction method provided by some embodiments of the present invention is shown.
[0137] like Figure 7 As shown, based on the phase value information, determining the abnormal pixel points in the unfolded phase image also specifically includes but is not limited to the following steps S340-S350:
[0138] S340: Sort the phase values according to their magnitudes to obtain a sorted sequence.
[0139] Specifically, after the phase value information is obtained by statistics, a sorting algorithm (for example, quick sort or built-in sorting function, etc.) is used to sort the phase values according to the sizes of the phase values in the phase value information to obtain a sorting sequence of the phase values. The sorting of the phase values may be in ascending order or descending order, and correspondingly, the obtained sorting sequence is an ascending sorting sequence or a descending sorting sequence.
[0140] S350: Determine abnormal pixel points in the unfolded phase image based on the number of pixels corresponding to the second phase value and the third phase value, the second phase value and the third phase value are any two adjacent phase values among several phase values in the sorting sequence, and the third phase value is the next phase value of the second phase value.
[0141] Specifically, after obtaining the sorted sequence of phase values, any two adjacent phase values from the several phase values in the sorted sequence are selected as the second phase value and the third phase value, wherein the third phase value is the next phase value of the second phase value.
[0142] Then, based on the number of pixels corresponding to the second phase value and the number of pixels corresponding to the third phase value, the abnormal pixel points in the expanded phase image are detected and determined. For example, in some embodiments, if the number of pixels corresponding to the second phase value is greater than the first threshold value, and the number of pixels corresponding to the third phase value is less than the second threshold value, it means that the second phase value and the third phase value are abnormal phase values, and then each pixel point in the expanded phase image is traversed to screen out the abnormal pixel points in the expanded phase image corresponding to the phase value equal to the second phase value or the third phase value. Of course, there can also be other suitable methods to detect and determine the abnormal pixel points in the expanded phase image. Those skilled in the art can select a suitable method to detect and determine the abnormal pixel points in the expanded phase image according to actual needs, and the embodiments of the present invention do not impose any restrictions on this.
[0143] See also Figure 8 , Figure 8 The figure shows an unfolded phase image after the phase values of abnormal pixels (corresponding to the highlighted areas in the depth image) are normalized and rounded in some embodiments of the present invention.
[0144] In some embodiments, based on the number of pixels corresponding to the second phase value and the third phase value, determining abnormal pixel points in the unfolded phase image specifically includes but is not limited to the following steps S3501-S3504:
[0145] S3501: If the sorting sequence is an ascending sorting sequence, and the number of pixels of the second phase value is equal to zero and the number of pixels of the third phase value is greater than zero, then determine that the third phase value is a target phase value.
[0146] Specifically, if several phase values are sorted in ascending order, an ascending sorting sequence is obtained. After selecting and determining the second phase value and the third phase value in the ascending sorting sequence, if the number of pixels of the second phase value is equal to zero, and the number of pixels of the third phase value is greater than zero, indicating that the third phase value is an abnormal phase value, the third phase value is determined as the target phase value, so as to screen out abnormal pixel points corresponding to phase values equal to the target phase value in the expanded phase image.
[0147] S3502: Compare the phase value of each pixel in the unfolded phase image with the target phase value to determine abnormal pixels in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
[0148] Specifically, after determining that the third phase value is the target phase value, traverse each pixel point in the expanded phase image, and compare the phase value of each pixel point in the expanded phase image with the target phase value to determine the abnormal pixel point in the expanded phase image. In some embodiments, if the phase value of a pixel point in the expanded phase image is equal to the target phase value, then the pixel point is an abnormal pixel point, and the pixel point in the expanded phase image is determined as an abnormal pixel point, and the coordinates of the abnormal pixel point and other information are recorded or marked for subsequent processing.
[0149] S3503: If the sorting sequence is a descending sorting sequence, and the number of pixels of the second phase value is greater than zero and the number of pixels of the third phase value is equal to zero, then determine that the second phase value is the target phase value.
[0150] Specifically, if a plurality of phase values are sorted in descending order, a descending sorting sequence is obtained. After selecting and determining the second phase value and the third phase value in the descending sorting sequence, if the number of pixels of the second phase value is greater than zero, and the number of pixels of the third phase value is equal to zero, indicating that the second phase value is an abnormal phase value, the second phase value is determined as the target phase value, so as to screen out abnormal pixel points corresponding to phase values equal to the target phase value in the unfolded phase image.
[0151] S3504: Compare the phase value of each pixel in the unfolded phase image with the target phase value to determine abnormal pixels in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
[0152] Specifically, after determining that the second phase value is the target phase value, traverse each pixel point in the expanded phase image, and compare the phase value of each pixel point in the expanded phase image with the target phase value to determine the abnormal pixel point in the expanded phase image. In some embodiments, if the phase value of a pixel point in the expanded phase image is equal to the target phase value, then the pixel point is an abnormal pixel point, and the pixel point in the expanded phase image is determined as an abnormal pixel point, and the coordinates of the abnormal pixel point and other information are recorded or marked for subsequent processing.
[0153] S400: Eliminate pixels corresponding to abnormal pixels in the depth map to correct the depth map.
[0154] Specifically, after determining the abnormal pixel points in the unfolded phase image, the pixel points corresponding to the abnormal pixel points are found in the depth map according to the position information such as the coordinates of the abnormal pixel points, and the pixel points corresponding to the abnormal pixel points are set to invalid values (for example, NaN or specific invalid mark values, etc.), thereby correcting the depth map to obtain a corrected depth map.
[0155] In some embodiments, in order to improve the efficiency of correcting the depth map, after determining the abnormal pixels in the expanded phase image and before eliminating the pixels corresponding to the abnormal pixels in the depth map, the abnormal pixels can be marked first to generate a corresponding pixel marking mask, and then the pixels corresponding to the abnormal pixels in the depth map can be corrected at one time according to the coordinate position of the abnormal pixels in the pixel marking mask and the correction mark.
[0156] In some embodiments, before removing pixels corresponding to abnormal pixels in the depth map to correct the depth map, the depth map correction method further includes but is not limited to the following steps S401:
[0157] S401: Mark the abnormal pixel points to obtain a pixel marking mask, where the pixel marking mask includes the coordinate position of the abnormal pixel points and a correction mark, and the correction mark is used to correct the pixel points corresponding to the abnormal pixel points in the depth map.
[0158] Specifically, a pixel marking mask with the same size as the unfolded phase image is created, and the value of the pixel marking mask is initialized to 0. After determining the abnormal pixel points in the unfolded phase image, the coordinate positions of the pixel points corresponding to the abnormal pixel points are marked in the pixel marking mask, and the correction mark is attached to the pixel points at the coordinate positions, that is, the pixel points at the coordinate positions corresponding to the abnormal pixel points in the pixel marking mask are marked as "1" as the correction mark, and the correction mark "1" is used to indicate that the pixel points at the coordinate positions are abnormal, and the pixel points corresponding to the coordinate positions need to be corrected in the depth map.
[0159] After marking all abnormal pixels in the unfolded phase image, a marked pixel marking mask is obtained. It should be understood that the marked pixel marking mask includes the coordinate position corresponding to the abnormal pixel and the correction mark, and the correction mark is used to indicate that the pixel corresponding to the coordinate position of the abnormal pixel in the depth map needs to be corrected.
[0160] In some embodiments, after the pixel marking mask is obtained, the phase values of the pixel points corresponding to the abnormal pixel points in the depth map are corrected based on the pixel marking mask.
[0161] In some embodiments, pixels corresponding to abnormal pixels in the depth map are removed to correct the depth map, specifically including but not limited to the following steps S410-S430:
[0162] S410: Acquire the coordinate position and correction mark of the abnormal pixel point based on the pixel mark mask.
[0163] S420: Based on the coordinate position of the abnormal pixel point, determine the target pixel point corresponding to the coordinate position in the depth map.
[0164] S430: Correcting the depth map based on the correction mark of the abnormal pixel to obtain a corrected depth map, wherein when the correction mark is 1, the target pixel corresponding to the abnormal pixel in the depth map is removed.
[0165] Specifically, after obtaining the pixel mark mask, the pixel mark mask is traversed to search for the pixel points corresponding to the abnormal pixel points (i.e., the pixel points with the correction mark "1") in the pixel mark mask. After finding all the pixel points corresponding to the abnormal pixel points, their coordinate positions and correction marks are recorded, that is, the coordinate positions and correction marks of the abnormal pixel points are obtained.
[0166] Then, according to the obtained coordinate position of the abnormal pixel point, the pixel point corresponding to the coordinate position of the abnormal pixel point is searched in the depth map and used as the target pixel point.
[0167] After finding the target pixel point corresponding to the coordinate position of the abnormal pixel point, the phase value of the target pixel point is corrected according to the correction mark of the abnormal pixel point. That is, if the correction mark corresponding to the target pixel point is "1", the target pixel point is set to an invalid value (for example, NaN or a specific invalid mark value, etc.) in the depth map, thereby correcting the depth map to obtain a corrected depth map.
[0168] It should be understood that in some embodiments, the phase value of the target pixel point can be corrected by a simple replacement method (such as mean replacement) or a more complex interpolation method to correct the phase value of the target pixel point at the abnormal position. Those skilled in the art can select a suitable method to correct the phase value of the target pixel point according to actual needs, and the embodiments of the present invention do not impose any limitations on this.
[0169] See also Figures 9 to 13 , Fig. 9 and Fig.11 The figure shows the point cloud of two components. The sunken part on the left side of one component is the highlighted area, and the climbing part on the right side is the shadow area. Fig.10 and Fig.12 The corrected depth map obtained by removing the pixels corresponding to the abnormal pixels in the highlight area and the shadow area in some embodiments of the present invention is shown. It can be seen from the figure that the pixels corresponding to the abnormal pixels are set to invalid values. Fig.13 The unwrapped phase image is shown in some embodiments of the present invention when there are no abnormal pixels and the phase values are normalized and rounded off.
[0170] To summarize, the depth map correction method provided by an embodiment of the present invention includes: obtaining a target image generated by projecting light onto the surface of an object to be detected; obtaining an unfolded phase map and a depth map based on the target image; counting the phase values of pixels in the unfolded phase map to obtain phase value information, and determining abnormal pixels in the unfolded phase map based on the phase value information; and eliminating pixels in the depth map corresponding to abnormal pixels to correct the depth map.
[0171] In the present invention, abnormal pixels in the unfolded phase image are detected, and then pixels corresponding to the abnormal pixels are searched and removed in the depth image to correct the depth image, thereby obtaining a corrected depth image.
[0172] This method is based on filtering the unfolded phase image. By utilizing the physical properties of the unfolded phase image, it can quickly and accurately detect abnormal pixels with abnormal phase values in the unfolded phase image (corresponding to the shadow area and highlight area of the depth image) to correct the depth image. Even if the number of optical machines is limited to one due to mechanical structure limitations or other higher priority reasons, the effect of three-dimensional restoration of the structure of a single optical machine product can still be greatly improved.
[0173] An embodiment of the present invention provides a computer-readable storage medium, on which computer program instructions executable by a processor are stored. When the computer program instructions are called by the processor, the processor executes any one of the depth map correction methods provided in the embodiments of the present invention, or executes the steps in any one of the implementation methods of any one of the depth map correction methods provided in the embodiments of the present invention.
[0174] In some embodiments, the storage medium may be a flash memory, a hard disk, an optical disk, a register, a magnetic surface storage, a removable disk, a CD-ROM, a random access memory (RAM), a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM or other memory, or any other form of storage medium known in the technical field, or may be various devices including one or any combination of the above storage media.
[0175] In some embodiments, computer program instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0176] As an example, computer program instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0177] As an example, the computer program instructions may be deployed to be executed on a computing device (including devices such as smart terminals and servers), or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network. It is easy to understand that all or part of the steps of the method described in the embodiments provided by the present invention above can be directly implemented using electronic hardware or processor executable computer program instructions, or a combination of the two.
[0178] The technicians can understand that the embodiments provided by the present invention are only illustrative, and the writing order of each step in the method of the embodiment does not mean a strict execution order and does not constitute any limitation on the implementation process. The order can be adjusted, merged and deleted according to actual needs. The modules or sub-modules, units or sub-units in the device or system of the embodiment can be merged, divided and deleted according to actual needs. For example, the division of units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0180] It should be noted that the above embodiments are intended to illustrate the technical concept and features of the present invention, and their purpose is to enable people familiar with this technology to understand the content of the present invention and implement it accordingly, and cannot be used to limit the scope of protection of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments can be implemented according to the technical solutions recorded in the embodiments of the present invention, or some of the technical features can be equivalently replaced. It can be understood that these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and should be regarded as equal changes and modifications based on the embodiments of the present invention, and should all fall within the scope of the claims of the present invention.
Claims
1. A depth map correction method, characterized in that: The method comprises: Acquire the target image generated by projecting light onto the surface of the object to be inspected; Acquire an unfolded phase map and a depth map based on the target image; Counting the phase values of the pixels in the unfolded phase image to obtain phase value information, and determining abnormal pixels in the unfolded phase image based on the phase value information, wherein the phase value information includes several phase values and the number of pixels corresponding to the several phase values; The determining, based on the phase value information, abnormal pixel points in the unfolded phase image comprises: According to the magnitude of the phase values, the plurality of phase values are sorted to obtain a sorted sequence; Determining abnormal pixel points in the unfolded phase image based on the number of pixels corresponding to a second phase value and a third phase value, wherein the second phase value and the third phase value are any two adjacent phase values among the plurality of phase values in the sorted sequence, and the third phase value is a phase value next to the second phase value; Pixels corresponding to the abnormal pixels in the depth map are removed to correct the depth map.
2. The method according to claim 1, characterized in that The determining, based on the phase value information, abnormal pixel points in the unfolded phase image further includes: Obtaining a target threshold based on the number of pixels corresponding to a first phase value and a mode of the number of pixels, wherein the first phase value includes any one of the several phase values, and the mode of the number of pixels is the mode of the number of pixels corresponding to the several phase values; If the target threshold is greater than a preset threshold, determining the first phase value to be a target phase value; The phase value of each pixel in the unfolded phase image is compared with the target phase value to determine the abnormal pixel in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
3. The method according to claim 2, characterized in that The step of obtaining a target threshold based on the number of pixels corresponding to the first phase value and the mode of the number of pixels includes: The target threshold is obtained by dividing the number of pixels corresponding to the first phase value by the mode of the number of pixels.
4. The method according to claim 1, characterized in that: The determining of abnormal pixel points in the unfolded phase image based on the number of pixels corresponding to the second phase value and the third phase value includes: If the sorting sequence is an ascending sorting sequence, and the number of pixels of the second phase value is equal to zero and the number of pixels of the third phase value is greater than zero, determining the third phase value to be a target phase value; Comparing the phase value of each pixel in the unfolded phase image with the target phase value to determine abnormal pixels in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel; or, If the sorting sequence is a descending sorting sequence, and the number of pixels of the second phase value is greater than zero and the number of pixels of the third phase value is equal to zero, determining the second phase value as a target phase value; The phase value of each pixel in the unfolded phase image is compared with the target phase value to determine the abnormal pixel in the unfolded phase image, wherein if the phase value of a pixel is equal to the target phase value, the pixel is determined to be an abnormal pixel.
5. The method according to any one of claims 1 to 4, characterized in that: Before removing the pixel points corresponding to the abnormal pixel points in the depth map to correct the depth map, the method further includes: The abnormal pixel point is marked to obtain a pixel marking mask, wherein the pixel marking mask includes a coordinate position of the abnormal pixel point and a correction mark, and the correction mark is used to correct the pixel point corresponding to the abnormal pixel point in the depth map.
6. The method according to claim 5, characterized in that The removing the pixel points corresponding to the abnormal pixel points in the depth map to correct the depth map includes: Acquire the coordinate position and correction mark of the abnormal pixel point based on the pixel mark mask; Based on the coordinate position of the abnormal pixel point, determining the target pixel point corresponding to the coordinate position in the depth map; Based on the correction mark of the abnormal pixel, the depth map is corrected to obtain a corrected depth map, wherein when the correction mark is 1, the target pixel corresponding to the abnormal pixel in the depth map is removed.
7. The method according to claim 1, characterized in that Before counting the phase values of the pixels in the unfolded phase image to obtain phase value information, the method further includes: Normalizing the phase value of each pixel in the unwrapped phase image to obtain a first unwrapped phase image; Rounding off the phase value of each pixel in the first unwrapped phase image to obtain a second unwrapped phase image; The counting of the phase values of the pixels in the unfolded phase image to obtain the phase value information includes: The phase values of the pixels in the second unwrapped phase image are counted to obtain the phase value information of the pixels.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer program instructions executable by the processor, and when the computer program instructions are called by the processor, the processor executes the depth map correction method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions executable by a processor, and when the computer program instructions are called by the processor, the processor executes the depth map correction method according to any one of claims 1 to 7.
