A high-speed surface defect detection method, system and medium
By using two non-collinear light sources and constraint functions to reconstruct the surface normal vector in a high-speed detection environment, the problem of balancing detection speed and sensitivity in existing technologies is solved, and efficient identification of high-speed surface defects is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI I TEK OPTOELECTRONICS CO LTD
- Filing Date
- 2026-04-28
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies cannot simultaneously meet the speed and sensitivity requirements for surface defect detection in high-speed production environments. Multi-light source solutions are not fast enough, while single-light source solutions have low sensitivity and cannot effectively identify surface unevenness defects.
By using two non-collinear light sources for illumination and combining constraint functions, the surface normal vector is reconstructed and mapped to an RGB image by adjusting the lighting order of the light sources and image acquisition, thus achieving high-speed surface defect detection.
While maintaining high-speed detection, it improves the sensitivity and accuracy of surface defect detection, simplifies the system hardware structure, and is suitable for online detection of high-speed wound materials such as electrode sheets and copper foil.
Smart Images

Figure CN122487359A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision, and in particular relates to a high-speed surface defect detection method, system and medium. Background Technology
[0002] In the field of industrial visual inspection, rapid and accurate identification of surface defects is crucial for ensuring product quality. Traditional surface defect detection solutions mainly face the challenge of balancing detection capability and speed. On the one hand, photometric stereo vision methods can effectively enhance and identify three-dimensional morphological defects such as bumps and scratches on object surfaces. The core principle of this method is to illuminate the object surface from multiple (usually at least three) different directions and acquire images, then use the Lambertian reflection model to solve for the surface normal vector of each pixel, thereby reconstructing the microscopic geometric information of the surface. However, this multi-source time-division imaging scheme, especially for line scan applications in high-speed continuous production, has an inherent speed bottleneck. For example, common linear array photometric stereo systems use four-zone light sources. For each line scanned by the camera, four light sources need to be lit sequentially and four images need to be acquired, resulting in an effective defect detection line frequency of only one-quarter of the camera's maximum acquisition line frequency. In high-speed production scenarios involving wound materials such as electrodes and copper foil, such detection speed often cannot meet the requirements of real-time online operation.
[0003] On the other hand, in pursuit of ultimate detection speed, the industry widely adopts a simple solution combining a high-frequency line scan camera with a single bar light source. This solution is simple in structure, fast in imaging, and the detection line frequency can be consistent with the camera's line frequency. However, its fundamental drawback is that, relying solely on illumination from a single direction, it is difficult to effectively distinguish between grayscale differences caused by variations in surface material reflectivity and shadow changes caused by surface physical deformations (such as pits and protrusions). This results in weak detection capability for surface unevenness defects, low sensitivity, and a high likelihood of missed detections, failing to meet the inspection needs of precision manufacturing industries with stringent surface quality requirements.
[0004] Therefore, existing technologies present a clear contradiction: photometric stereoscopic methods with strong defect detection capabilities sacrifice detection speed, while single-source line scanning methods that meet the demands of high-speed detection sacrifice the ability to identify critical morphological defects. This invention aims to overcome this contradiction by providing a solution that maintains effective perception of surface morphological defects even in high-speed detection environments. Summary of the Invention
[0005] The purpose of this invention is to overcome the above-mentioned problems in the prior art and provide a high-speed surface defect detection method, system and medium. By setting two light sources and introducing a constraint function, the invention eliminates the dependence on at least three light sources and effectively solves the industry problem of difficult and missed detection of surface micro-morphology defects in high-speed production environments.
[0006] To achieve the above-mentioned technical objectives and effects, the present invention is implemented through the following technical solution: A high-speed surface defect detection method is provided to improve the detection speed of surface defects. The detection method includes: Adjust two light sources whose light output directions are not collinear so that the overlapping area of the two light sources covers the field of view of the camera, and calibrate the direction vector of each light source. The system controls two light sources to be lit sequentially and cyclically, and acquires images of the surface of the object under test corresponding to different light sources. Construct constraint functions and solve for the surface normal vector that minimizes the constraint functions; Map each component of the photometric stereo fusion image to the RGB channels and output the mapped RGB image; The photometric stereo fusion image is a set of any three parameters among the three component parameters corresponding to the surface normal vector, the surface gradient parameter in the X direction, the surface gradient parameter in the Y direction, and the reflectivity parameter. The constraint function includes a data term and a constraint term. The data term is used to constrain the difference between the measured grayscale value and the simulated grayscale value of the surface image of the object under test. The constraint term is used to constrain the surface gradient changes in the X and Y directions. The simulated grayscale value is calculated using the Lambert model. The illumination is synchronized with the camera acquisition.
[0007] Furthermore, the step of constructing the constraint function can be replaced by any one of the following four methods: Method 1: Preset reflectivity and directly solve for the surface normal vector; Method 2: First, divide the gray values at any position on the surface image of the object under test corresponding to the two light sources to eliminate the corresponding reflectance data; then, solve for the surface normal vector based on the equality of the surface gradient in the X direction and the surface gradient in the Y direction. Method 3: Preset the surface gradient in the X direction or the surface gradient in the Y direction, and solve for the surface gradient in the other direction; Method 4: Preset the direction of the third light source, and use the all-zero image as the corresponding surface image of the object under test. Combine the surface images of the object under test corresponding to the two light sources to solve the surface normal vector.
[0008] Furthermore, the camera is a line scan camera, and the light source is a strip light source.
[0009] Furthermore, after outputting the mapped RGB image, the process also includes: inputting the RGB image into a trained defect classification model to output the defect type and location.
[0010] Furthermore, the camera is fixed relative to the two light sources to pre-calibrate the direction vector of each light source.
[0011] Furthermore, after acquiring surface images of the object under test corresponding to different light sources, a low-resolution image is constructed based on the image pyramid, and a constraint function is constructed on the low-resolution image. The surface normal vector corresponding to the minimum constraint function is then calculated. Finally, the components of the photometric stereo fusion image are mapped to the RGB channels to obtain the final RGB image.
[0012] Furthermore, after obtaining the final RGB image, the region of interest is identified, and a constraint function is constructed based on the region of interest. The surface normal vector corresponding to the minimum constraint function is then calculated. Finally, the components of the photometric stereo fusion image are mapped to the RGB channels to obtain a new RGB image.
[0013] The present invention also provides a high-speed surface defect detection system, comprising: The calibration module is used to adjust two light sources whose light output directions are not collinear, so that the overlapping area of the illumination of the two light sources covers the field of view of the camera, and to calibrate the direction vector of each light source. The light source control module is used to control the two light sources to light up sequentially and in a cycle, and to acquire images of the surface of the object under test corresponding to different light sources; the lighting is synchronized with the camera acquisition. The constraint analysis module is used to construct constraint functions and solve for the surface normal vector that minimizes the constraint functions. The constraint functions include data terms and constraint terms. The data terms are used to constrain the difference between the measured grayscale values and the simulated grayscale values of the surface image of the object under test. The constraint terms are used to constrain the surface gradient changes in the X and Y directions. The simulated grayscale values are calculated using the Lambert model. The mapping output module is used to map each component of the photometric stereo fusion image to the RGB channels and output the mapped RGB image; wherein, the photometric stereo fusion image is a set of any three parameters among the three component parameters corresponding to the surface normal vector, the surface gradient parameter in the X direction, the surface gradient parameter in the Y direction, and the reflectivity parameter.
[0014] The present invention also provides a computer-readable storage medium including a computer program, characterized in that the computer program implements the above-described detection method when executed by a processor.
[0015] The beneficial effects of this invention are: (1) This invention first achieves an excellent balance between detection speed and defect detection capability. By reducing the number of light sources to two and increasing the detection line frequency to half that of the camera line frequency, it successfully overcomes the bottleneck of insufficient speed in traditional multi-light source photometric stereoscopic schemes, making it applicable to high-speed continuous production scenarios of wound materials such as electrodes and copper foils, and meeting the real-time requirements of industrial online inspection. Secondly, by introducing constraint functions, the shortcomings of hardware simplification are compensated by algorithmic innovation. The surface normal vector can be stably solved using only two images. While maintaining the high sensitivity enhancement capability for key morphological defects such as surface bumps and scratches, it eliminates the dependence on at least three light sources, simplifying the system hardware structure and control logic. Finally, it effectively solves the industry problem of difficult detection and missed detection of surface micromorphological defects in high-speed production environments.
[0016] (2) The key difference between this invention and the traditional solution of at least three light sources is that by adjusting and calibrating two light sources, the speed can be improved. By calibrating in advance, the influence of different installation configurations on the results is eliminated, and the system achieves versatility and the convenience of one-time calibration and long-term use, laying the foundation for high-speed and stable operation.
[0017] By controlling two light sources to illuminate sequentially and cyclically, mutual interference between the light sources can be avoided, resulting in a pure single-light source illumination image. Compared to traditional three- or four-light source solutions, this invention reduces the number of images required for acquisition from 3-4 to 2, thereby increasing the detection speed limit to nearly half the camera's line frequency. This significantly improves the throughput of online inspection and is suitable for high-speed winding production lines for electrodes, copper foil, etc.
[0018] By introducing constraints to eliminate unknown parameters or supplement constraint functions, the surface normal vector can be solved, thus overcoming the technical bottleneck that "two light sources cannot recover the normal vector". By introducing reasonable constraints, the surface normal vector information can be reconstructed stably and robustly from only two images, thereby obtaining key three-dimensional features for detecting concave and convex defects while ensuring speed.
[0019] By mapping each component of the photometric stereo fusion image to the RGB channel and outputting the mapped RGB image, the visualization enhancement of the detection results is achieved. In the output RGB image, the surface concavity and convexity features are significantly enhanced and color-coded, making scratches, pits and other defects that were not obvious in the original grayscale image clear at a glance, which greatly facilitates the subsequent defect identification and classification. Attached Figure Description
[0020] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings: Figure 1This is a flowchart of the detection method in this invention; Figure 2 This is a block diagram of the detection system in this invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] The core principle of photometric stereo vision-based methods is to illuminate the surface of an object from multiple (usually at least three) different directions and acquire images, then use the Lambertian model to solve for the surface normal vector of each pixel, thereby reconstructing the microscopic geometric information of the surface. However, in existing technologies, photometric stereo schemes with strong defect detection capabilities sacrifice detection speed, while single-source line scanning schemes that can meet the requirements of high-speed detection sacrifice the ability to identify key morphological defects.
[0023] To solve the above problems, such as Figure 1 As shown, this embodiment first provides a high-speed surface defect detection method to improve the surface defect detection speed. The detection method includes: Two non-collinear light sources are adjusted so that their overlapping illumination areas cover the camera's field of view, and the direction vectors of each light source are calibrated. Ensuring the overlapping illumination area covers the field of view is a prerequisite for guaranteeing that every point in the subsequently acquired image is illuminated by both light sources. Calibrating the direction vectors of the light sources is the core input data for solving the surface normal in photometric stereo vision. In the Lambertian model, image grayscale values are related to the light source direction vector, reflectivity, and surface normal vector. Unknown reflectivity and surface normal vectors need to be solved using known light source direction vectors. This step lays the foundation for photometric stereo calculations. Using only two light sources is a key difference from traditional schemes requiring at least three light sources, creating conditions for increased speed. Pre-calibration eliminates the influence of different installation configurations on the results, achieving system versatility and the convenience of one-time calibration for long-term use, laying the foundation for high-speed and stable operation. In a specific embodiment of this invention, the camera is a line scan camera, and the light source is a strip light source. Line scan cameras are suitable for imaging continuously moving rolled materials, with each row of pixels continuously exposed, allowing for infinite stitching into a two-dimensional image. Strip light sources provide a uniform, linear illumination area, perfectly matching the "linear" field of view of a line scan camera for efficient lighting. Strip light sources can be installed in either a direct or oblique configuration, with the two light sources arranged symmetrically on both sides, asymmetrically on both sides, or asymmetrically on the same side. The light source can be selected from any wavelength, including visible light, infrared, and ultraviolet.
[0024] Two light sources are controlled to be lit sequentially and cyclically, acquiring images of the test object surface corresponding to different light sources; the lighting is synchronized with camera acquisition. During the detection process, the controller alternately lights the two light sources according to a time sequence (i.e., when light source A is lit, the camera acquires one line / frame of images; when light source A is off and light source B is lit, the camera acquires the next line / frame of images), and this cycle continues. Finally, two images are obtained that are staggered in time but aligned in space, corresponding to the same test object surface under different light source illumination. Since there are only two light sources, the timing control is simpler than with four light sources. During each light source illumination period, the camera performs a complete line scan exposure. Using the "sequential lighting and cyclical" method avoids mutual interference between light sources, obtaining pure single-light source illumination images. Compared to traditional three- or four-light source solutions, this invention reduces the number of images required from 3-4 to 2, thereby increasing the detection speed limit to nearly half the camera's line frequency, significantly improving the throughput of online detection, and is suitable for high-speed winding production lines for electrodes, copper foil, etc.
[0025] A constraint function is constructed, and the surface normal vector corresponding to the minimum constraint function is found. The constraint function includes data terms and constraint terms. The data terms constrain the difference between the measured and simulated gray values of the surface image of the object under test, while the constraint terms constrain the surface gradient changes in the X and Y directions. The simulated gray values are calculated using the Lambert model. According to the Lambert model, I = ρLN, where I is the image surface gray value, ρ is the reflectivity, L is the direction vector of the light source, and N is the surface normal vector. Considering that the magnitude of N is 1, it has only two degrees of freedom. When the surface is represented as a height field, p and q are the surface gradients in the X and Y directions, respectively. p and q are equivalent to N and provide two degrees of freedom for the normal vector. Once p and q are obtained, N can be completely determined. Since there are only two light sources and the unknowns are p, q, and ρ, the number of equations is less than the number of unknowns. Direct solution is "underdetermined," with infinitely many solutions. By adding a constraint function, the problem is transformed into an optimization problem, allowing for a stable and physically meaningful solution for the surface normal vector. The introduced constraint function is essentially a smoothness prior assumption: real object surfaces are typically continuous and smooth, with gradient changes that are not excessively drastic. Therefore, among countless potential surfaces satisfying the two illumination equations, we select the smoothest (i.e., with the smallest gradient change) as the optimal solution. This feature overcomes the technical bottleneck of "two light sources being unable to recover the normal vector." By introducing reasonable physical constraints (surface smoothness), it successfully and robustly reconstructs surface normal vector information from only two images, thus obtaining crucial 3D features for detecting unevenness and convexity while maintaining speed.
[0026] As a specific embodiment of the present invention, the constraint function is specifically formulated as follows:
[0027] Among them, I i_true Let I be the measured grayscale value at pixel i. i_true Let i be the simulated grayscale value at pixel i. Let be the spatial derivative of the surface gradient in the X direction at pixel i. Let λ be the spatial derivative of the surface gradient in the Y direction at pixel i, and λ be a weighting coefficient proportional to the image noise level. The first term is the data term, used to calculate the sum of squares of the differences between the measured gray value at each pixel i and the simulated gray value calculated using the current normal vector and the Lambert model. The second term is the constraint term, which calculates the sum of squares of the spatial derivatives (i.e., rates of change) of the surface gradients p (X direction) and q (Y direction) at all pixels i, essentially a gradient smoothing constraint. This is solved using an iterative algorithm (such as the Gauss-Newton method or the conjugate gradient method). The algorithm starts with a set of initial guesses (such as a flat surface) and continuously adjusts the (p, q, ρ) values for each pixel to minimize the energy function E, ultimately obtaining the optimal (p, q, ρ) values for each pixel in the entire image. Minimizing the data term forces the solved normal vector to accurately interpret the observed image gray levels; minimizing the constraint term forces the surface changes to be gradual, avoiding unreasonable and drastic fluctuations due to noise or insufficient information. λ is a regularization parameter that balances the importance of these two terms and can be adjusted based on actual detection experience. Ultimately, it can effectively guarantee the stability and robustness of the solution under the underdetermined condition of dual light sources.
[0028] As can be seen from the above, the core of this invention is to solve for the surface normal vector by introducing constraints to eliminate unknown parameters or supplement constraint functions. In other embodiments of introducing constraints, the step of constructing the constraint function is replaced by any one of the following four methods: Method 1: Preset reflectivity and directly solve for the surface normal vector. When the surface material of the object under test is uniform and the albedo is constant, i.e., the reflectivity ρ is known to be constant and its value is known, the surface normal vector can be directly solved from two images by presetting the reflectivity ρ. According to the Lambert model I=ρLN, when the reflectivity ρ is known to be a constant k, for two light sources L1 and L2, a system of equations can be established at pixel i: I1=kL1N and I2=kL2N, where I1 and I2 are the measured gray values corresponding to the two light sources, and L1 and L2 are the direction vectors corresponding to the two light sources. According to the transformation relationship between N and p, q, the system of equations is associated with the surface gradients p, q, and two equations about p and q can be obtained. At this time, the number of equations equals the number of unknown parameters, and the surface normal vector can be finally calculated. This method, under the strong prior condition of constant reflectivity, does not require complex optimization iteration calculations and has an extremely fast calculation speed. It eliminates an unknown by utilizing known physical property parameters (constant reflectivity), transforming the problem into a well-posed problem. It is suitable for high-speed detection scenarios with uniform materials and can achieve the highest processing frame rate.
[0029] Method 2: First, divide the gray values at any position on the surface image of the object under test corresponding to the two light sources to eliminate the reflectance data; then, solve for the surface normal vector based on the equality of the surface gradient in the X direction and the surface gradient in the Y direction. Directly dividing the corresponding gray values of the two images directly eliminates the unknown reflectance ρ, thus obtaining an equation that only relates to the surface normal vector and the light source vector: I1 / I2=L1N / L2N. After representing N with p and q, the above equation can be transformed into a relational equation about p and q. At this point, assuming that the values of p and q are equal, multiple equations are established for adjacent pixel groups and solved jointly to reconstruct the surface gradient field.
[0030] Method 3: Preset the surface gradient in the X-direction or the surface gradient in the Y-direction, and solve for the surface gradient in the other direction. Assuming the surface gradient in the X-direction or the surface gradient in the Y-direction is zero or other known values, the solution objective is simplified to obtaining the gradient in only a single direction, thus reducing the dimensionality of the solution. Each equation contains only two unknowns, ρ and p / q. Finally, by analyzing the distribution of p / q values, the corresponding concave / convex defects can be detected.
[0031] Method 4: Preset a third light source direction and use the all-zero image as the corresponding surface image of the object under test. Combine the surface images of the object under test corresponding to the two light sources to solve for the surface normal vector. By constructing a virtual light source and image for solving, and combining the two measured images with the preset third image, the three unknown parameters p, q, and ρ can be quickly solved.
[0032] The photometric stereo fusion image is mapped to its components and then output as an RGB image. The photometric stereo fusion image is a set of any three parameters among the following: the three component parameters corresponding to the surface normal vector of the test object, the surface gradient parameters in the X and Y directions of the test object, and the surface reflectance parameters. For example, a combination of ρ and p, q, or a fusion of texture map, gradient map, and integral map. This step maps the three components of the photometric stereo fusion image to the R, G, and B color channels of the color image, generating and outputting a color image. Converting it to a visually intuitive RGB image facilitates subsequent manual observation or processing by deep learning-based defect detection models. The normal vector changes gradually in flat areas, appearing as smooth colors in the RGB image; while the normal vector direction changes drastically at uneven defects, resulting in obvious color abruptness and texture in the RGB image. This step enhances the visualization of the detection results. In the output RGB image, the surface features are significantly enhanced and color-coded, making scratches, pits and other defects that were not obvious in the original grayscale image clear at a glance, which greatly facilitates the subsequent defect identification and classification.
[0033] Considering that images acquired in industrial settings inevitably contain noise, such as sensor noise and ambient light interference, filtering is performed after acquiring surface images of the object under test corresponding to different light sources. Filtering suppresses image noise and smooths unnecessary details. It reduces the interference of noise on subsequent normal vector calculations, particularly benefiting gradient-based constraint terms, resulting in a smoother and more accurate final surface normal vector field, and reducing erroneous defect judgments caused by noise.
[0034] As a specific embodiment of the present invention, after outputting the mapped RGB image, the method further includes: inputting the RGB image into a trained defect classification model to output the defect type and location. The detection results can be interpreted manually or fed into a pre-trained deep learning model. The defect region in the normal vector map has unique color and texture features. The deep neural network can automatically learn these high-dimensional features and directly output the defect category (such as scratches or dents) and its coordinate position in the image, achieving full automation and intelligence of the detection process.
[0035] To obtain stable detection results, the camera and the two light sources are fixed relative to each other for pre-calibration to obtain the direction vectors of each light source. For example, the camera and the two light sources are mechanically fixed to a rigid structural component to form an integrated imaging head. The integrated structure ensures that the relative spatial position (angle, distance) between the camera and the light sources remains unchanged after installation. This allows the calibration results (solving the light source direction vectors) performed in the laboratory environment to be reliably applied to the production line and remain stable over a long period. It also simplifies the on-site installation and commissioning process, avoids the tedious work of recalibrating before each use, and ensures the consistency of the system across different production lines and at different times.
[0036] In a specific embodiment of the present invention, after acquiring surface images of the object under test corresponding to different light sources, a low-resolution image is constructed based on an image pyramid. A constraint function is then constructed on the low-resolution image, and the surface normal vector corresponding to the minimum constraint function is calculated. Then, the components of the photometric stereo fusion image are mapped to the RGB channels to obtain the final RGB image. After obtaining the original high-resolution image, a series of image pyramids with different resolutions (such as the original image, half-image, and quarter-image) are generated by downsampling. The normal vector is quickly calculated and the RGB image is generated on the low-resolution image. This is a "coarse-to-fine" multi-scale optimization strategy. The low-resolution image has a small data volume, allowing for a rapid calculation of a rough surface morphology. This result is then used as the initial value and passed to a higher-resolution image for refined calculation. This significantly accelerates the overall algorithm's computation speed, helps avoid getting trapped in local optima, improves the robustness of normal vector reconstruction, and further ensures the real-time performance of high-speed detection.
[0037] As a further specific implementation, after obtaining the final RGB image, the region of interest (ROI) is identified, and a constraint function is constructed based on the ROI. The surface normal vector corresponding to the minimum constraint function is then calculated. Next, the components of the photometric stereo fusion image are mapped to the RGB channels to obtain a new RGB image. In the initially generated RGB normal vector map, ROIs with potential defects are quickly located using a simple threshold or fast algorithm. Then, only for these ROIs, the constraint function optimization process is restarted using the original high-resolution image data to generate a higher-precision local RGB image. Defective regions are usually small, localized areas. First, a rapid global scan locates suspected areas, then computational resources are concentrated on reconstructing these key areas with fine detail, avoiding the huge resource overhead of high-precision calculations across the entire image.
[0038] like Figure 2 As shown, the present invention also provides a high-speed surface defect detection system, comprising: The calibration module is used to adjust two light sources whose light output directions are not collinear, so that the overlapping area of the illumination of the two light sources covers the field of view of the camera, and to calibrate the direction vector of each light source.
[0039] The light source control module is used to control the two light sources to light up sequentially and in a cycle, and to acquire images of the surface of the object under test corresponding to different light sources; the lighting is synchronized with the camera acquisition.
[0040] The constraint analysis module is used to construct constraint functions and solve for the surface normal vector that minimizes the constraint functions. The constraint functions include data terms and constraint terms. The data terms are used to constrain the difference between the measured grayscale values and the simulated grayscale values of the surface image of the object under test, and the constraint terms are used to constrain the surface gradient changes in the X and Y directions. The simulated grayscale values are calculated using the Lambert model.
[0041] The mapping output module is used to map each component of the photometric stereo fusion image to the RGB channels and output the mapped RGB image. The photometric stereo fusion image is a set of any three parameters among the three component parameters corresponding to the surface normal vector, the surface gradient parameter in the X direction, the surface gradient parameter in the Y direction, and the reflectivity parameter.
[0042] The detection system of the present invention can be operated with reference to the above detection method, and will not be repeated here.
[0043] The present invention also provides a computer-readable storage medium including a computer program that, when executed by a processor, implements the above-described detection method.
[0044] In practical applications, a computer-readable storage medium can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0045] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0046] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0047] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0048] In the description of this specification, references to terms such as "an embodiment," "example," and "specific example" indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0049] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A high-speed surface defect detection method, used to improve the detection speed of surface defects, characterized in that, The detection method includes: Adjust two light sources whose light output directions are not collinear so that the overlapping area of the two light sources covers the field of view of the camera, and calibrate the direction vector of each light source. The system controls two light sources to be lit sequentially and cyclically, and acquires images of the surface of the object under test corresponding to different light sources. Construct constraint functions and solve for the surface normal vector that minimizes the constraint functions; Map each component of the photometric stereo fusion image to the RGB channels and output the mapped RGB image; The photometric stereo fusion image is a set of any three parameters among the three component parameters corresponding to the surface normal vector, the surface gradient parameter in the X direction, the surface gradient parameter in the Y direction, and the reflectivity parameter; the constraint function includes a data term and a constraint term. The data term is used to constrain the difference between the measured grayscale value and the simulated grayscale value of the surface image of the object under test, and the constraint term is used to constrain the surface gradient changes in the X and Y directions; the simulated grayscale value is calculated using the Lambert model; the illumination is synchronized with the camera acquisition.
2. The method of claim 1, wherein The step of constructing the constraint function can be replaced by any one of the following four methods: Method 1: Preset reflectivity and directly solve for the surface normal vector; Method 2: First, divide the gray values at any position on the surface image of the object under test corresponding to the two light sources to eliminate the corresponding reflectance data; then, solve for the surface normal vector based on the equality of the surface gradient in the X direction and the surface gradient in the Y direction. Method 3: Preset the surface gradient in the X direction or the surface gradient in the Y direction, and solve for the surface gradient in the other direction; Method 4: Preset the direction of the third light source, and use the all-zero image as the corresponding surface image of the object under test. Combine the surface images of the object under test corresponding to the two light sources to solve the surface normal vector.
3. A method of high speed surface defect detection according to claim 1 or 2, wherein, After acquiring images of the object's surface under different light sources, filtering processing is performed.
4. The method of claim 1 or 2, wherein The camera is a line scan camera, and the light source is a strip light source.
5. The method of claim 1 or 2, wherein After outputting the mapped RGB image, the process also includes: inputting the RGB image into a trained defect classification model to output the defect type and location.
6. The method of claim 1 or 2, wherein The camera is fixed relative to the two light sources to pre-calibrate the direction vector of each light source.
7. A high speed surface defect detection method according to any one of claims 1 to 6, wherein After acquiring surface images of the object under test corresponding to different light sources, a low-resolution image is constructed based on the image pyramid. A constraint function is then constructed based on the low-resolution image, and the surface normal vector corresponding to the minimum constraint function is solved. Then, the components of the photometric stereo fusion image are mapped to the RGB channels to obtain the final RGB image.
8. The method of claim 7, wherein the method is a high speed surface defect detection method. After obtaining the final RGB image, the region of interest is identified, and a constraint function is constructed based on the region of interest. The surface normal vector corresponding to the minimum constraint function is then calculated. Finally, the components of the photometric stereo fusion image are mapped to the RGB channels to obtain a new RGB image.
9. A high speed surface defect detection system characterized by, include: The calibration module is used to adjust two light sources whose light output directions are not collinear, so that the overlapping area of the illumination of the two light sources covers the field of view of the camera, and to calibrate the direction vector of each light source. The light source control module is used to control the two light sources to light up sequentially and in a cycle, and to acquire images of the surface of the object under test corresponding to different light sources; the lighting is synchronized with the camera acquisition. The constraint analysis module is used to construct constraint functions and solve for the surface normal vector that minimizes the constraint functions. The constraint functions include data terms and constraint terms. The data terms are used to constrain the difference between the measured grayscale values and the simulated grayscale values of the surface image of the object under test. The constraint terms are used to constrain the surface gradient changes in the X and Y directions. The simulated grayscale values are calculated using the Lambert model. The mapping output module is used to map each component of the photometric stereo fusion image to the RGB channels and output the mapped RGB image; wherein, the photometric stereo fusion image is a set of any three parameters among the three component parameters corresponding to the surface normal vector, the surface gradient parameter in the X direction, the surface gradient parameter in the Y direction, and the reflectivity parameter.
10. A computer readable storage medium comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the detection method as described in any one of claims 1-8.