Device and method for detecting and measuring surface defects of products

Through the method of projecting structured light and real-time image capture, combined with device calibration and parameter learning, the shortcomings of existing machine vision detection devices in universality, robustness and real-time are solved, high accuracy and rapid detection of three-dimensional defects on the product surface are achieved, and a defect grading method is designed.

CN115201202BActive Publication Date: 2025-03-14ZHONGKE SONGTA (SUZHOU) TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210757297.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-30
Publication Date
2025-03-14
Estimated Expiration
2042-06-30

AI Technical Summary

Technical Problem

Existing machine vision detection devices lack universality, robustness, real-timeness and ability to rank defects, making it difficult to effectively detect and measure product surface defects in different environments.

Method used

The projector is used to project structured light on the product surface, the camera captures the image in real time, and performs image processing through the computer. The distortion principle of grating stripes is used to detect surface defects, and combined with device calibration, parameter learning and real-time detection algorithms, accurate detection of three-dimensional defects is achieved.

Benefits of technology

It improves the detection ability of three-dimensional defects on the surface of an object, enhances the accuracy, real-time and flexibility of detection, reduces the demand for computer hardware, and designs a set of grading and judging defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115201202B_ABST
    Figure CN115201202B_ABST
Patent Text Reader

Abstract

The present invention discloses a device and method for detecting and measuring surface defects of products, the device comprises a projector for projecting structured light onto the surface of the product to be inspected passing through the production line in real time, a camera for capturing the image of the surface of the product to be inspected with the projected structured light in real time, and a computer connected to the projector and the camera by a bus, the computer receiving the captured image from the camera, and detecting and measuring the surface defects of the object and quantifying the size specifications through the image processing algorithm preset by the computer. The machine vision detection method of device calibration, parameter learning, parameter setting, image correction, real-time detection and defect analysis improves the detection capability of three-dimensional defects on the surface of the object, especially compared with the traditional detection method, it has the improvement effect in many aspects such as accuracy, real-time performance, flexibility, etc., and reduces the hardware requirements for the computer, with outstanding cost performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an industrial application of machine vision, and in particular to a device and method for detecting and measuring surface defects of products. Background Art

[0002] Machine vision enables industrial equipment to have basic recognition and analysis capabilities by analyzing images. With the deepening of industrial digitalization and intelligent transformation and the gradual advancement of intelligent manufacturing, industrial machine vision has gradually formed a large-scale industry, and with the implementation of artificial intelligence technology in the industrial field, it has gradually penetrated into various scenarios of industrial production. As a basic research topic in the field of machine vision, the surface defect detection task aims to automatically distinguish different surface conditions of objects and is applied in many practical tasks, such as 3C product surface defect detection, mobile phone cover glass detection, wafer surface detection, etc.

[0003] In the process of industrial transformation and upgrading, the industry is transforming from a rough processing and manufacturing model that is overly dependent on low labor costs to a fully automated, high value-added and high productivity model. In the production line of the old industrial system, defects on the surface of products are mainly detected by human eye observation. This manual detection method will result in large differences in subjective will, and as the working hours increase, the detection efficiency is low, and it cannot adapt to the high-speed and intelligent social production rhythm. The surface defect detection method based on machine vision uses a camera to capture images of the surface of the object, and calculates the type and location of the defect through a visual analysis algorithm, replacing the process of human eye observation. The surface defect detection method based on machine vision has the advantages of non-contact measurement, long-term stable operation, and not being affected by harsh working environments, and is favored by many companies.

[0004] At present, the research on surface defect detection based on structured light in industry and academia is still at the simple task level of using traditional two-dimensional machine vision algorithms to detect defects on the surface of textureless objects. For example, Caulier et al. (2007) proposed a grating pattern feature algorithm with certain universality, but this method has low robustness to lighting and requires a large amount of calculation. Kemao et al. (2006) proposed a method based on template matching and window Fourier transform to detect abnormal defects. Although this method has improved real-time performance, it is more sensitive to changes in lighting, and the algorithm has low universality and robustness. In addition, there are some research works that apply abnormal feature extraction methods such as Gabor filters, wavelet transforms, and attention mechanisms. The announced schemes based on structured light defect detection include: a metal plate defect detection method based on structured light applied by Hefei Tongguan Information Technology Co., Ltd. (2021). In this patent, the stripe image to be detected is multiplied by the corresponding pixel points in the standard stripe image to solve the phase and locate the defect based on the height information of the metal plate; Beijing Institute of New Technology Application (2020) provides a product reflective surface defect detection method, which locates surface defects based on edge detection and morphological filtering methods; Hunan Xunmu Technology Co., Ltd. (2020) transmits grating stripes to the glass to be tested, and uses virtual moiré fringe technology to detect and calculate small deformations such as glass ribs, and obtain information such as the size and position of conventional defects.

[0005] Looking at the current status of surface defect detection research at home and abroad, we can find the following problems: First, the existing machine vision detection devices lack universality. Most defect detection methods use traditional lighting methods such as diffuse lighting and directional lighting to obtain images of the surface of objects. Cameras can capture texture defects but it is difficult to effectively capture structural defects. Although the current deep learning neural network can extract deeper features, it is still impossible to detect defects from images that the camera cannot capture. Therefore, the inefficient lighting method for the surface of objects directly leads to the poor detection effect of existing machine vision devices on defects.

[0006] Secondly, the existing machine vision inspection devices are not robust enough. Most inspection devices can effectively detect under ideal working conditions. When the environment changes, such as camera working distance, image clarity, light intensity, material reflection, hardware jitter during feeding, etc., the inspection algorithm will fail. Therefore, in order to ensure effectiveness in different environments, it is necessary to design a more stable defect detection algorithm and a more stable system.

[0007] Thirdly, the real-time performance of existing machine vision inspection devices is not high. For industrial application scenarios with high inspection requirements, existing devices require a large amount of calculation in the process of defect detection, resulting in a long inspection time. For example, deep learning algorithms require a large amount of convolution calculations and expensive computing equipment.

[0008] Finally, existing machine vision inspection devices lack the ability to grade and judge defects. Existing machine vision inspection devices are difficult to define a unified set of defect standards in different working environments. Summary of the invention

[0009] In view of the above-mentioned deficiencies in the prior art, the present invention proposes a device and method for detecting and measuring product surface defects. By adjusting the device and reconstructing the detection method, the problems of lack of universality, robustness, real-time performance and defect classification in product surface defect detection in the industrial production field are solved.

[0010] The technical solution of the present invention to achieve the above-mentioned one object is a device for detecting and measuring surface defects of products, characterized by comprising:

[0011] A projector is used to project structured light onto the surface of the product to be inspected that is passing through the production line in real time;

[0012] The camera is used to capture the surface image of the product to be inspected with the projected structured light in real time;

[0013] The computer is connected to the projector and the camera via a bus, and is used to output structured light to the projector and receive captured images from the camera. Through the image processing algorithm preset by the computer, the surface defects of the object are detected and measured and the size specifications are quantified.

[0014] Furthermore, the projector is configured to use blue light as the light for structured light projection, and the structured light is configured to be grating stripes.

[0015] The technical solution of the present invention to achieve the above another object is a method for detecting and measuring surface defects of products, which is implemented based on the device described in any one of claims 1 to 3 and uses grating as structured light, and is characterized by comprising:

[0016] S1, device calibration, by calculating the mapping relationship between the projector imaging area and the ideal coordinates, mapping the tilted grating image area to the ideal coordinate system, and obtaining a grating image parallel to the Y axis;

[0017] S2, learning parameters, using samples with different material surfaces through the projection and framing range, and projecting sinusoidal grating stripes on the scene through a projector, learning pattern features including template features, noise threshold, defect threshold, background brightness threshold, and measurement parameters;

[0018] S3, setting parameters, according to the detection requirements, setting the defect parameters including at least the length and size of the dislocation through a computer;

[0019] S4, image correction, in the working stage, using the mapping relationship obtained in the device calibration step, the tilted grating image input by the camera is corrected to an ideal grating image perpendicular to the stripe direction of the grating;

[0020] S5, real-time detection, input the ideal grating image after image correction into the computer, and the computer segments the input image and detects defects based on the learning parameters and set parameters, and outputs an image containing all defect information that meets the user's needs.

[0021] S6. Analyze defects, use a connected domain analysis algorithm to extract connected domain features of defect information, and convert the connected domain features into real-world defect quantitative representations based on measurement parameters. Based on preset defect parameters, filter and output the defect quantitative representation or image representation of the surface of the product to be inspected that meets the user's definition.

[0022] Compared with traditional manual inspection or other machine vision inspection methods, the technical solution for product surface defect detection and measurement based on the present invention has the following significant improvements: the ability to detect three-dimensional defects on the surface of objects is improved, especially compared with traditional inspection methods, it has improved effects in accuracy, real-time performance, flexibility and other aspects, and reduces the hardware requirements for computers, with outstanding cost performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a schematic diagram of the structure of the device for detecting and measuring surface defects of products according to the present invention.

[0024] Figure 2 The figure is a flow chart of the method for detecting and measuring surface defects of products according to the present invention.

[0025] Figure 3 It is a projected grating pattern in the detection method of the present invention. DETAILED DESCRIPTION

[0026] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention. The "above" and "below" mentioned in the present invention include the numbers themselves. Unless otherwise specified, the technical means used in the implementation examples are conventional means well known to those skilled in the art. It should be noted that the "calculation" mentioned throughout the text refers to the calculation automatically run by hardware or software after entering the algorithm / method provided by the present invention, and does not refer to manual calculation; when using the algorithm / method provided by the present invention to calibrate the camera, the calibration result finally obtained is not subject to human will.

[0027] like Figure 1 As can be seen from the schematic diagram of the hardware structure of the device shown, the device mainly includes three parts: a projector, a camera and a computer. From the perspective of functional limitations, the projector is used to project structured light onto the surface of the product to be inspected that passes through the production line in real time; and the camera is used to capture the image of the surface of the product to be inspected that is projected with structured light in real time; the two are integrated into one and fixed to the gantry through which the production line passes. The projection angle of the projector and the shooting distance and angle of the camera are adjustable. There is also a computer bus (not shown) that connects the projector and the camera, which is used to output structured light to the projector and receive the captured image from the camera. Through the image processing algorithm preset by the computer, the surface of the object including scratches, stains, abrasions, bumps and other defects are detected and measured, and the size specifications are quantified.

[0028] This device solves the problem of lack of universality from the perspective of data acquisition. A projector is used to project a grating image on the surface of the object to be inspected, and based on the principle that the grating is distorted at the defect, the significance of the surface defects of the object is enhanced, so that the camera can effectively acquire two-dimensional texture defects and three-dimensional structural defects.

[0029] This device designs an effective defect detection method to solve the problem of robustness. Blue light, which is less common in nature, is selected as the light for structured light projection, which has a certain robustness to ambient light.

[0030] Based on the structural description of the above detection and measurement device, the feasibility of its detection method is further understood by combining the technical route description of the device. Figure 2As shown, the device needs to be learned before use, including three steps: device calibration, parameter learning, and parameter setting. The general description is: S1, device calibration, by calculating the mapping relationship between the projector imaging area and the ideal coordinates, the inclined grating image area is mapped to the ideal coordinate system to obtain a grating image parallel to the Y axis; S2, learning parameters, using samples with different material surfaces through the projection and framing range, and projecting sinusoidal grating stripes on the scene through the projector, learning pattern features including template features, noise threshold, defect threshold, background brightness threshold, and measurement parameters; S3, setting parameters, according to the detection requirements, set the defect parameters including at least the length and size of the dislocation through the computer. After the learning process is completed, the defect information on the surface of the object will be output when the system is working, mainly including the steps of image correction, real-time detection and defect analysis. It can be summarized as follows: S4, image correction, in the working stage, the inclined grating image input by the camera is corrected into an ideal grating image perpendicular to the stripe direction of the grating using the mapping relationship obtained in the device calibration step; S5, real-time detection, the ideal grating image after image correction is input into the computer, and the computer segments the target and detects defects based on the learning parameters and set parameters of the input image, and outputs an image containing all defect information that meets user needs; S6, defect analysis, using the connected domain analysis algorithm to extract the connected domain features of the defect information, and based on the measurement parameters, the connected domain features are converted into real-world defect quantitative representations, and based on the preset defect parameters, the defect quantitative representation or image representation that meets the user's definition on the surface of the product to be inspected is filtered and output.

[0031] From a more specific detailed description: First, the device is calibrated, and the surface information of the object is obtained by using a projector to project a stripe pattern on the object and a camera to shoot. In actual environments, it is difficult to keep the direction of the grating stripes consistent with the vertical direction of the camera imaging. Therefore, the direction of the grating projection pattern in the actual image is variable, which increases the difficulty of the subsequent feature extraction algorithm. Therefore, this device maps the inclined grating image area to the ideal coordinate system by calculating the mapping relationship between the projector imaging area and the ideal coordinates, and obtains a grating image parallel to the Y-axis. The ideal coordinate system here has the cognition and definition that technicians in this field are accustomed to. Combined with the production line, the plane where the conveyor belt is located is the XY plane, the conveying direction of the product to be inspected is parallel to the Y-axis, and the height of the product to be inspected is the Z-axis.

[0032] The calibration process of the device is as follows: first, a checkerboard pattern is projected onto the surface of the object; then the position of the outermost corner point in the checkerboard image is extracted, and a perspective transformation relationship from the corner point position to the ideal coordinate is established; finally, this perspective transformation relationship is used to correct the grating image with tilted stripes into an ideal grating image.

[0033] Furthermore, learning parameters, when working, the projector projects sinusoidal grating stripes to the scene. In different working environments and working distances, the sinusoidal waveforms collected by the camera have different period, phase, amplitude and other characteristics; in addition. The projection light passes through the absorption, refraction, reflection and other processes of the material surface, and the sinusoidal pattern obtained by the camera is deformed. Before working, this device learns the sinusoidal pattern characteristics of different material surfaces so that it can be flexibly applied in different environments. The features that need to be learned are: template features, noise threshold, defect threshold, background brightness threshold, measurement-related parameters, etc.

[0034] (1) Template features are composed of a series of sinusoidal data with different phases and periods. This device obtains a defect-free surface pattern of the object to be detected, and extracts normalized positive waveforms with different phases and periods through image processing algorithms, and forms a template library. Each template in the template library is a period of sinusoidal data, such as Figure 3 shown.

[0035] (2) The noise threshold is used in the real-time detection stage to determine whether a certain data segment matches the template. This device uses a template matching algorithm to take each data segment in the defect-free surface image and match it with the template in the template library to find the best matching template. Before template matching, the defect-free surface image is normalized. The mean absolute error (MAE) between each data segment in the defect-free surface image and all templates in the template library is calculated and used as the noise threshold. The calculation formula is: ,in, is the template vector, is the image vector. The template with the smallest error is the matched template, and the error is the matching error.

[0036] (3) The defect threshold is used in the real-time detection stage to determine whether a data segment contains defects. This device uses a template matching algorithm to match the surface image with defects with the template in the template library, calculate the matching errors of all data segments in the image, and sort them from small to large. The defect threshold is the kth value of all matching errors, where the k value is determined by the proportion of defects in the image and is the number of values ​​set by the user.

[0037] (4) The background brightness threshold is used in the real-time detection stage to segment the target area and background area in the image. Since the reflection coefficients of projector light on the surfaces of different materials are different, for example, when the pattern is projected onto the surface of a smooth material, such as glass and display screens, mirror reflection will occur, and the brightness of the image captured by the camera is often low; when the pattern is projected onto a rough material, diffuse reflection will occur on its surface, and the brightness of the image captured by the camera is often high. Based on the different surface reflection coefficients of the target material and the background, this device projects a fully bright pattern onto the background material, and takes the average brightness of the background material image as the background brightness threshold, which is used to segment the target area and background area in the image.

[0038] (5) Measurement parameters (or parameters related to measurement) are used in the real-time detection stage to represent the mapping relationship between image coordinates and the real world. This device can detect the shape of the defect and its position in the image, and can also measure its actual size, perimeter, area and other real-world parameters.

[0039] Then set the parameters. According to the user's needs, defects that meet the requirements can be detected through parameter setting. The main parameters include misalignment length, defect size, etc.

[0040] (1) Defect size. In actual industrial applications, different products have different tolerances for defects. For example, in some glass inspection projects, defects with the longest side of 0.2 mm are allowed on the glass surface. When a piece of glass has a defect with the longest side of 0.1 mm on the surface, it is still a good product. Therefore, this device can meet different requirements in actual applications by setting the parameters of defect size.

[0041] (2) Defect definition. In actual industrial applications, different imaging factors such as different light intensities and different working distances make it difficult to have a unified set of defect judgment standards in different devices. This device proposes a defect definition standard called misalignment judgment method. Misalignment refers to a certain length of displacement to the left or right at a certain point in the data segment. When there is a defect in a certain data segment of the image, there is a large error between the normalized image data segment and its matching template at the defect. Assuming that the position where the error exists is x, if the value at the data segment position x is equal to the value of the template after being displaced to the left or right by len pixels, the misalignment length is len. A misalignment threshold is set in the misalignment judgment method. When the misalignment length is greater than the threshold, the pixel is judged to be a defect, otherwise it is noise.

[0042] After completing the preparation before detection, the image correction is carried out. Since it is difficult to keep the direction of the grating stripes consistent with the vertical direction of the camera imaging in the actual environment, the direction of the grating projection pattern in the actual acquired image is variable, which increases the difficulty of the real-time detection process. Based on the perspective transformation relationship obtained in the device calibration step, this device corrects the input tilted grating image into an ideal grating image with vertical stripes during the working stage.

[0043] Then, real-time detection is performed. Based on the learning parameters and setting parameters, all defects that meet the user's needs are output. The input image of this stage is an ideal grating image, and the output is the defect information in the image, including the position, width and height of the defect in the image, and the parameters of the defect in the real world, such as perimeter, area and longest side. This stage mainly consists of segmenting the target and detecting defects.

[0044] In actual industrial applications, when the shape of the object to be detected is irregular or the camera's field of view is large, the grating image is mixed with a part of the background area, which will affect the effectiveness of the defect detection algorithm. Based on the reflection ability of different materials to project different patterns, this device uses the learned background brightness threshold to segment the target area and the background area based on the thresholding method. In addition, there are also some defects on the edge of the object, such as broken edge defects. This device fills the target area by fitting the edge of the target area. The fitting methods include circular, elliptical, polygonal and other methods.

[0045] In the defect detection stage, based on the user's definition of defects, all defects that meet the conditions of the misalignment judgment method are detected in the image. The detection method mainly consists of two parts: anomaly detection based on template matching and defect area calculation.

[0046] Specifically, all abnormal areas in the image are detected by template matching, and the abnormal areas include defective areas and noise in the image. The image data is normalized; based on the target area image and the template library, the normalized grating image is template matched to generate a template image; the error between the template image and the normalized grating image is calculated to generate an error image, and the error calculation method is absolute error; a misaligned threshold image is generated based on the template image, and the error image is thresholded, marking the area in the error image that is greater than the corresponding threshold as an abnormal area. Then, the abnormal image is filled to obtain an ideal matching grating image; and the error is calculated with the normalized grating image to generate an error image; then, the error image is thresholded based on the misaligned threshold image to generate a defective area image. Among them, the filling method of the abnormal image uses the value around the abnormal area to supplement, such as taking the average value of the surrounding pixels.

[0047] Finally, the defects are analyzed and all defect information is extracted based on the defect area image, such as the position, width and height of the defect in the image, and the parameters of the defect in the real world, such as perimeter, area and longest side. The connected domain analysis algorithm is used to extract the connected domain of the defect, and based on the measurement-related parameters obtained in the learning phase, the connected domain features are converted to the real world to measure the size, perimeter, area and other information of the defect. In addition, based on the user's tolerance requirements for defects, this device filters defects that do not meet the requirements and outputs user-defined defect information on the product surface.

[0048] The present invention designs a set of effective defect detection algorithms for various scenarios of industrial environments, and has accurate and stable detection capabilities in environments such as non-fixed camera working distance, changing image clarity, uneven illumination intensity, material reflection, and hardware jitter during the loading process. The calculation amount of this method is less than one ten-thousandth of the calculation amount of various existing detection methods, which significantly improves the detection speed while ensuring the detection performance. At the same time, due to the miniaturization of the calculation amount, the hardware requirements for the computer are also reduced. Only an ordinary computer is needed, and the real-time requirements of the industry can be met without the assistance of expensive graphics cards, FPGAs and other parallel computing devices, which can meet the requirements of most industrial applications.

[0049] In summary, the embodiments of the device and method for detecting and measuring product surface defects of the present invention are described in detail above. Compared with the traditional manual inspection or other machine vision inspection methods, its significant improvements are described one by one as follows.

[0050] (1) High universality: This device projects a grating pattern onto the surface of an object, uses a camera to capture defects, and finally detects defects through a machine vision algorithm. It can not only detect two-dimensional defects such as scratches and wear, but also has good detection capabilities for three-dimensional defects on the surface of objects, such as bulges, dents, and bumps.

[0051] (2) High accuracy: Based on machine vision technology, this device overcomes the influence of the external environment on the defect detection function. This device has high robustness in complex application environments such as uneven brightness. In actual application scenarios, this device overcomes the influence of jitter of objects during transmission, and the missed detection rate is less than 0.05%, the false detection rate is less than 0.5%, and the smallest defect that can be detected is one pixel.

[0052] (3) High real-time performance: The device uses machine vision technology to propose a fast and effective defect detection algorithm. On an ordinary desktop computer, the detection speed for a 5-megapixel image is 20 milliseconds.

[0053] (4) High flexibility: This device is small in size and does not require complicated calibration during installation. The calibration process can be completed by simply placing a calibration plate in a specific area, and the application scenarios are flexible.

[0054] (5) Cost-effective: This device has low hardware requirements and only requires an ordinary computer. It does not require expensive graphics cards, FPGAs or other parallel computing devices to meet the real-time requirements of the industry and meet the accuracy requirements of most industrial applications.

[0055] (6) This device has designed a set of methods for grading and judging defects, which effectively defines the defect standards to be detected according to customer needs in different working environments.

[0056] Although the preferred embodiments of the present invention have been described above in conjunction with the accompanying drawings, the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms of specific changes without departing from the scope of protection of the purpose of the present invention and the claims, which all fall within the scope of protection of the present invention.

Claims

1. A method for detecting and measuring surface defects of products, wherein the device comprises a projector for projecting structured light onto the surface of a product to be inspected passing through a production line in real time, a camera for capturing images of the surface of the product to be inspected projected with structured light in real time, and a computer connected to the projector and the camera by a bus, wherein the computer is used to output structured light to the projector and receive images collected from the camera, and detect and measure surface defects of the object and quantify size specifications through a preset image processing algorithm, wherein the projector is configured to project grating stripes of blue light, characterized in that include: S1, device calibration, by calculating the mapping relationship between the projector imaging area and the ideal coordinates, mapping the tilted grating image area to the ideal coordinate system, and obtaining a grating image parallel to the Y axis; S2. Learning parameters. Using samples of different material surfaces through the projection and framing range, and projecting sinusoidal grating stripes on the scene through a projector, learning pattern features including template features, noise threshold, defect threshold, background brightness threshold, and measurement parameters. The template features are used to obtain defect-free surface patterns of objects to be inspected, and normalized sinusoidal waveforms of different phases and periods are extracted through image processing algorithms to form a template library. The noise threshold is calculated as the average absolute error of each segment of data in the defect-free surface image to all templates in the template library. ,in is the template vector, is an image vector; the defect threshold is obtained by matching the surface image with defects with the template in the template library, calculating the matching errors of all data segments in the image, and sorting them from small to large to set the number of values ​​that can be customized; the background brightness threshold is obtained by projecting a fully bright pattern on the background material of the product to be inspected, and taking the average brightness of the background material image; the measurement parameter represents the corresponding relationship between the image coordinates and the real world; S3, setting parameters, according to the detection requirements, setting the defect parameters including at least the length and size of the dislocation through a computer; S4, image correction, in the working stage, using the mapping relationship obtained in the device calibration step, the tilted grating image input by the camera is corrected to an ideal grating image perpendicular to the stripe direction of the grating; S5, real-time detection, input the ideal grating image after image correction into the computer, and the computer segments the input image into targets and detects defects based on learning parameters and set parameters, and outputs an image containing all defect information that meets user needs, wherein the segmentation target is to extract the target area based on the background brightness threshold, and perform edge fitting on the target area, and normalize the image data, and the defect detection is to perform template matching on the normalized grating image based on the target area image and the template library to generate a template image; calculate the error between the template image and the normalized grating image to generate an error image, and the error calculation method is absolute error; generate a misalignment threshold image based on the template image, and perform a thresholding operation on the error image, mark the area in the error image that is larger than the corresponding threshold as an abnormal area, and then fill the abnormal image to obtain an ideal matching grating image; and calculating the error with the normalized grating image to generate an error image; then thresholding the error image based on the misalignment threshold image to generate a defect area image; S6. Analyze defects, use a connected domain analysis algorithm to extract connected domain features of defect information, and convert the connected domain features into real-world defect quantitative representations based on measurement parameters. Based on preset defect parameters, filter and output the defect quantitative representation or image representation of the surface of the product to be inspected that meets the user's definition.

2. The method for detecting and measuring surface defects of a product according to claim 1, characterized in that: The misalignment judgment method is defined in the setting parameters, and a judgment is made based on whether there is a phase offset at a certain point in the data segment and whether there is an error exceeding the limit at the corresponding point with the matching template after the image data segment is normalized.

Citation Information

Patent Citations

  • Product surface quality online detection method based on digital projection

    CN105866129A