Camera-level fully automatic trial-and-error method and system based on simulated defects

By superimposing simulated defect features on real images, the problems of insufficient accuracy of optical path design and camera algorithms in existing technologies are solved, efficient and accurate defect detection is achieved, and complex training processes and background influences are avoided.

CN120355717BActive Publication Date: 2025-09-05ZHEJIANG SHUANGYUAN TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510847273.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-09-05
Estimated Expiration
2045-06-24

AI Technical Summary

Technical Problem

Existing industrial defect detection systems lack accuracy in optical path design and camera preliminary defect detection algorithms. In addition, the training process of simulated defect images is time-consuming and affected by background, resulting in inaccurate detection results.

Method used

A camera-level fully automatic trial-and-error method based on simulated defects is adopted. By randomly selecting the image area to be detected and superimposing the simulated defect classification template, the background influence is taken into account and the simulated defect features are directly added to the real image for detection, avoiding the complex model training process.

Benefits of technology

It improves the efficiency and accuracy of defect detection, can accurately detect defects under real lighting and background, reduces computing power consumption and time, and realizes qualitative and quantitative verification of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120355717B_ABST
    Figure CN120355717B_ABST
Patent Text Reader

Abstract

The present invention discloses a camera-level fully automatic trial-and-error method and system based on simulated defects. According to the defect detection result of the defect detection module on the image to be detected, it is judged whether the simulated defect classification template image applied to the image to be detected with (r0, c0) as the center point is successfully detected, thereby realizing the verification of whether the detected defect is a simulated defect applied to the image to be detected. It does not require a complex simulated defect image training process, and the defect detection is faster and more efficient. In addition, the defect detection process takes into account the influence of the background of the image to be detected on the detection result, and the defect detection accuracy is higher. In addition, since the rationality of the optical path design, the correctness of the optical path imaging, and the balanced consistency of the defect detection capability may affect the number of defects to be confirmed, the suspected simulated defects are identified by judging the number of defects to be confirmed, thereby realizing the verification of the rationality of the optical path design, the correctness of the optical path imaging, and the balanced consistency of the defect detection capability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial automated optical inspection and defect verification, and in particular to a camera-level fully automatic trial and error method and system based on simulated defects. Background Art

[0002] Existing industrial defect detection systems typically use high-resolution cameras and image processing algorithms to identify surface defects such as scratches, cracks, and stains. However, these systems have limitations and face the following risks:

[0003] Improper optical path design can lead to light path deviation, uneven energy distribution, or stray light interference. For example, errors in the selection or installation of lenses, filters, and reflectors can cause imaging distortion or light spot offset, affecting detection accuracy. The stability of optical path imaging directly affects image quality. For example, dust and oil adhering to the surface of optical components can cause scattered light interference and reduce image contrast. The camera's initial defect detection algorithm is not reliable enough. For example, dark current noise or readout noise of the CMOS / CCD in high ISO mode can mask tiny defect signals.

[0004] To address the aforementioned issues, CN114155244A discloses a defect detection method, apparatus, device, and storage medium. These methods generate simulated defect samples based on a preset defect sample generation model and defect-free images. These images are then augmented using a large number of simulated defect sample images to increase the number of defect samples. Finally, these augmented defect samples are used to detect defects in the target image, improving the accuracy of small-sample defect detection. CN117315387A discloses a method for generating industrial defect images. This method extracts feature maps from defect foreground images and feature maps from non-defective product images, fuses these features, generates diffusion features from the fused features, encodes the diffusion features, and outputs simulated industrial defect images. This method requires only a few real defect sample images to generate a large number of simulated industrial defect images in a short period of time.

[0005] The method provided by the aforementioned patent first requires the use of existing defect samples to train and generate simulated defect images. However, the training process consumes a lot of time and computing power. Secondly, due to factors such as lighting, material, and movement speed, the background image of the object to be detected may be diverse. The method in the aforementioned patent only "mixes" the simulated defect image into the real defect image for the camera or host computer to detect, classify, and identify, but ignores the fact that the background of the current image to be detected will also affect the detection results. Summary of the Invention

[0006] The present invention aims to avoid the complex training process of simulated defect images, improve the efficiency of defect detection, consider the influence of the background of the image to be detected on the defect detection results, and improve the accuracy of defect detection. It provides a camera-level fully automatic trial and error method and system based on simulated defects.

[0007] To achieve this object, the present invention adopts the following technical solutions:

[0008] A camera-level fully automatic trial-and-error system based on simulated defects is provided, including:

[0009] An image storage module is used to store a plurality of image data collected by the image acquisition module for the workpiece to be inspected as an image to be inspected with M rows and N columns of pixels;

[0010] a defect simulation module, connected to the image storage module, configured to further randomly select at least one region from the image to be detected randomly selected from the image storage module, then randomly select at least one simulated defect classification template image, and determine whether the selected region is the background image of the image to be detected;

[0011] If yes, the simulated defect classification template image used as a basis for judgment is superimposed on the area to be judged, and the image to be detected is marked with a simulated defect image and then transmitted to the defect detection module;

[0012] If not, transmitting the image to be inspected to the defect detection module;

[0013] A defect detection module, connected to the defect simulation module, is used to perform defect detection and verification on the image to be detected,

[0014] If the verification is successful, one or more of the defect type, size, and position on the image to be inspected is recorded and a defect detection verification report is generated;

[0015] If the verification fails, a defect detection result is generated.

[0016] Preferably, when determining whether the region is the background image in the image to be detected, the size of the randomly selected simulation defect classification template used as a basis for determination is consistent with the size of the region used as the determination object.

[0017] Preferably, the method of superimposing the simulation defect classification template map onto the region is expressed as follows:

[0018] pr_arti_dt(x,y)=pr_ori(x,y)*r1(x,y)+r2(x,y);

[0019] pg_arti_dt(x,y)=pg_ori(x,y)*g1(x,y)+g2(x,y);

[0020] pb_arti_dt(x,y)=pb_ori(x,y)*b1(x,y)+b2(x,y);

[0021] Wherein, pr_arti_dt(x,y), pg_arti_dt(x,y), and pb_arti_dt(x,y) are the pixel values ​​of the R color channel, the G color channel, and the B color channel after applying the simulated defect at the pixel point (x,y) of the region, respectively;

[0022] pr_ori(x,y), pg_ori(x,y), and pb_ori(x,y) are the pixel values ​​of the R color channel, G color channel, and B color channel at the pixel point (x,y) on the region before the simulated defect is applied;

[0023] r1(x,y) and r2(x,y) respectively represent the first simulated defect characteristic value and the second simulated defect characteristic value of the (x,y) pixel point on the region in the R color channel;

[0024] g1(x,y) and g2(x,y) respectively represent the first simulated defect feature value and the second simulated defect feature value of the (x,y) pixel point on the region in the G color channel;

[0025] b1(x,y) and b2(x,y) respectively represent the first simulated defect feature value and the second simulated defect feature value of the (x,y) pixel point on the region in the B color channel.

[0026] Preferably, the method of assigning simulated defect features to each pixel in the simulated defect classification template image is:

[0027] Each pixel in the simulation defect classification template image is divided into several levels according to color from dark to light, and then the pixel with the corresponding color level is assigned the corresponding simulation defect feature value in the R, G, and B channels respectively.

[0028] As a preferred method, the method of assigning corresponding simulated defect feature values ​​to each pixel point in the pinhole type simulated defect classification template image is:

[0029] The first simulated defect characteristic values ​​r1, g1, and b1 of each pixel in the R, G, and B color channels are all assigned a value of "1". The second simulated defect characteristic values ​​r2, g3, and b2 of each pixel in the R, G, and B color channels are assigned as follows:

[0030] Each pixel is divided into several color levels from high to low according to the color of the pixel from dark to light, and then the second simulated defect feature values ​​r2, g3, and b2 of each pixel in the R, G, and B color channels are assigned corresponding defect feature values ​​in a manner such that the larger the color level, the smaller the second simulated defect feature value;

[0031] The method for assigning simulated defect features to each pixel in the foreign fiber simulated defect classification template is as follows:

[0032] Each pixel is divided into several color levels from high to low according to the color of the pixel. Then, the first simulation defect feature values ​​r1 and g1 of each pixel in the R and G color channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the larger the first simulation defect feature value. The first simulation defect feature value b1 of each pixel in the B color channel is assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the first simulation defect feature value. The second simulation defect feature values ​​r2, g2, and b2 of each pixel in the R, G, and B channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the second simulation defect feature value or the same.

[0033] Preferably, the method for determining whether the selected area is the background image of the image to be detected is:

[0034] Calculate and apply the simulated defect classification template image to the center row number r0 and the center column number c0 of the image to be detected, where r0 and c0 are both defect center points of the simulated defect classification template image;

[0035] Align the defect center point of the simulated defect classification template image with the r0 and c0 pixel points calculated on the image to be detected, so as to apply the simulated defect classification template image to the image to be detected, and then calculate the standard deviation stdv and maximum difference sub of the pixel values ​​of the application area def_area on the image to be detected;

[0036] Determine whether the standard deviation stdv is less than the standard deviation threshold stdv_sh and the maximum difference sub is less than the maximum difference threshold sub_sh,

[0037] If yes, it is determined that the application area def_area is the background image of the image to be detected;

[0038] If not, it is determined that the application area def_area is not the background image of the image to be detected, and the applied simulation defect classification template image is removed from the application area def_area.

[0039] As a preference, , c , where m and n represent the pixels with m rows and n columns in the simulation defect classification template image; M and N represent the pixels with M rows and N columns in the image to be detected;

[0040] The maximum difference sub is the difference between the maximum and minimum pixel values ​​in the application area def_area;

[0041] The method for the defect simulation module to mark the image to be detected as a simulated defect image is:

[0042] After forming a record of the number num of the image to be inspected, the defect center point (r0, c0) of the application area def_area, the size of the simulated defect classification template image applied to the area def_area, and the type of the simulated defect in the image and saving it to the simulated defect sample set, the simulated defect image marking of the image to be inspected is completed;

[0043] The sizes of different simulation defect classification template images are the same or different.

[0044] Preferably, the method for the defect detection module to perform defect detection and verification on the image to be detected comprises the steps of:

[0045] S31, setting the center point matching search radius rad, and judging whether the image to be detected currently undergoing defect detection is marked as a simulated defect image,

[0046] If yes, find the defect center point (r0, c0) associated with the number num of the image to be detected from the simulated defect sample set, and then go to step S32;

[0047] If not, generating and storing the defect detection result of the image to be detected;

[0048] S32, extracting all types of defects whose center points are within the range of (r0±rad, c0±rad) from the defect results of the image to be detected, and naming them as defects to be confirmed;

[0049] S33, judging whether the simulated defect classification template image applied on the image to be detected with (r0, c0) as the center point is successfully detected according to the number of the defects to be confirmed, and generating the judgment result as the defect detection verification report.

[0050] S34, recording the remaining defects except the suspected simulation defects in the defect detection results.

[0051] Preferably, step S33 specifically includes the following steps:

[0052] S331, determine whether the number of defects to be confirmed is greater than 1,

[0053] If so, extract the defect to be confirmed whose center point is closest to (r0, c0) as the suspected simulated defect applied to the image to be inspected with (r0, c0) as the center point, and then go to step S333;

[0054] If not, go to step S332;

[0055] S332, determine whether the number of defects to be confirmed is 1,

[0056] If so, the defect to be confirmed is determined to be a suspected simulation defect, and then the process goes to step S333;

[0057] If not, it is determined that the application of the simulated defect on the image to be inspected fails, and the result of determining the application of the simulated defect fails is recorded in the defect inspection verification report, and the remaining defects are output to the defect inspection result;

[0058] S333, comparing the type and / or size of the suspected simulated defects with each of the simulated defect classification templates applied to the image to be detected, and recording the comparison results in the defect detection verification report, and outputting the remaining defects to the defect detection results.

[0059] The present application also provides a camera-level fully automatic trial and error method based on simulated defects, which is implemented by the camera-level fully automatic trial and error system based on simulated defects, including the steps of:

[0060] S1, storing a plurality of image data collected for the workpiece to be inspected as an image to be inspected with M rows and N columns of pixels;

[0061] S2, randomly selecting at least one simulated defect template image, then randomly selecting at least one area with the same size as the selected simulated defect template image from the randomly selected image to be detected, and then determining whether the selected area is the background image of the image to be detected,

[0062] If yes, the simulated defect classification template image is superimposed on the selected area, and the image to be inspected is marked as a simulated defect image before proceeding to step S3;

[0063] If not, go to step S3;

[0064] S3, performing defect detection and verification on the image to be detected,

[0065] If the verification is successful, one or more of the defect type, size, and position on the image to be inspected is recorded and recorded in a defect detection verification report;

[0066] If the verification fails, the result of determining that the simulation defect application fails is recorded in the defect detection verification report, and the remaining defects are recorded in the defect detection results.

[0067] The present invention has the following beneficial effects:

[0068] 1. Normalize the simulated defect features to corresponding pixel values. After obtaining the real image to be inspected, add the normalized simulated defect features to the defect-free background area of ​​the real image. This eliminates the need for model training to generate simulated defect images, solving the current problem of generating simulated defect images through models that requires a lot of computing power and time.

[0069] 2. The normalized simulated defect features are added to the defect-free background area of ​​the real image to be detected, taking into account the impact of the defective background area in the real image to be detected on the detection results, making the defect detection of the target image more accurate.

[0070] 3. The system can achieve qualitative and quantitative verification of the detection capability in real lighting environment and real background for real images to be inspected with simulated defect features, and the verification process does not interfere with the detection of real defects in the images to be inspected. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.

[0072] Figure 1 The image to be inspected includes a defect-free background image portion and a defective foreground image portion;

[0073] Figure 2 is a flowchart for implementing the camera-level fully automatic trial and error method based on simulated defects provided in this embodiment;

[0074] Figure 3 This is an example diagram of a pinhole-type simulated defect with 8 rows and 7 columns;

[0075] Figure 4 This is an example diagram of simulated defects of foreign fibers with 9 rows and 8 columns;

[0076] Figure 5 is a structural diagram of a camera-level fully automatic trial and error system based on simulated defects provided by an embodiment of the present invention;

[0077] Figure 6 It is an example image of the image to be inspected that is fed into the defect simulation module to apply the simulated defect classification template image;

[0078] Figure 7 is Figure 6 Example image after applying the simulation defect classification template. DETAILED DESCRIPTION

[0079] The technical solution of the present invention will be further described below with reference to the accompanying drawings and through specific implementation methods.

[0080] Among them, the drawings are only used for illustrative purposes and represent only schematic diagrams rather than actual pictures, and should not be understood as limiting this patent; in order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; for those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.

[0081] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "inside", "outside" and the like indicate an orientation or position relationship based on the orientation or position relationship shown in the drawings, it is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting this patent. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.

[0082] In the description of the present invention, unless otherwise expressly specified or limited, when the term "connection" or the like appears to indicate a connection relationship between components, such term should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be internal communication between two components or an interaction between two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood in specific circumstances.

[0083] First, the background image part and the foreground image part of the real image to be detected are explained. Figure 1 As shown, the pixel values ​​of the defect-free background image may be larger or smaller. The pixel values ​​of the entire background image may be consistent or gradually change. However, overall, the pixel values ​​of the background part are relatively stable without sudden changes.

[0084] The following combination Figure 2 The camera-level fully automatic trial and error method based on simulated defects provided in this embodiment is described, and specifically includes the following steps:

[0085] S1, storing a plurality of image data collected for the workpiece to be inspected as an image to be inspected with M rows and N columns of pixels;

[0086] Specifically, first, the information of various simulated defects is set in the system according to the requirements, including the characteristics and size of each defect, and then the set simulation defect classification template is stored in the defect simulation module;

[0087] The image acquisition module continuously collects a number of image data of the workpiece to be inspected, and the image storage module stores the image data in sequence as the image to be inspected. Assume that the size of the image to be inspected is OK Column, it means the number of pixels of the collected image data is .

[0088] S2, randomly selecting at least one simulated defect template image, then randomly selecting at least one area with the same size as the selected simulated defect template image from the randomly selected image to be detected, and then determining whether the selected area is the background image of the image to be detected,

[0089] If so, the simulated defect classification template image is superimposed on the selected area, and the image to be inspected is marked with a simulated defect image and then transmitted to the defect detection module;

[0090] If not, the image to be inspected is transmitted to the defect detection module;

[0091] Specifically, the image selection module randomly selects an image to be inspected from the image storage module and transmits it to the defect simulation module. After receiving the image to be inspected, the defect simulation module selects at least one simulated defect classification template from the simulated defect classification templates stored in its own module and randomly selects an area in the selected image to be inspected that matches the size of the selected simulated defect classification template.

[0092] For example, the simulated defect classification template image selected from the defect simulation module includes TP1 and TP2, and then the randomly selected areas from the image to be inspected include areas AP1, AP2, and AP3. Assuming that AP1 and TP1 are the same size, AP2 and TP2 are the same size, and AP3 and TP2 are the same size, and there can be no overlap between AP1, AP2, and AP3, then a determination is made as to whether AP1 is the background image of the image to be inspected; and based on AP1, AP2, and AP3, a determination is made as to whether AP1 is the background image of the image to be inspected.

[0093] When the defect simulation module determines that the selected area is the background image in the image to be detected, the simulated defect classification template image used as the basis for judgment is superimposed on the area as the judgment object, and the simulated defect image of the image to be detected is transmitted to the defect detection module.

[0094] In this embodiment, the method of superimposing the simulation defect classification template map on the region is:

[0095] First, the pixel value p_total after the image to be detected is superimposed with the simulated defect is defined as:

[0096] p_total=255if p_total>255;

[0097] p_total=p_totalif 255>=p_total>=0;

[0098] p_total=0 if p_total<0.

[0099] Applying a simulated defect to a certain area in the image to be inspected can be viewed as a linear change in the background pixel values ​​in the area. In this embodiment, the simulated defect classification template image is superimposed on the area using the following expression:

[0100] pr_arti_dt(x,y)=pr_ori(x,y)*r1(x,y)+r2(x,y);

[0101] pg_arti_dt(x,y)=pg_ori(x,y)*g1(x,y)+g2(x,y);

[0102] pb_arti_dt(x,y)=pb_ori(x,y)*b1(x,y)+b2(x,y);

[0103] Wherein, pr_arti_dt(x,y), pg_arti_dt(x,y), and pb_arti_dt(x,y) are the pixel values ​​of the R color channel, the G color channel, and the B color channel after applying the simulated defect at the pixel point (x,y) of the region, respectively;

[0104] pr_ori(x,y), pg_ori(x,y), and pb_ori(x,y) are the pixel values ​​of the R color channel, G color channel, and B color channel at the pixel point (x,y) on the region before the simulated defect is applied;

[0105] r1(x,y) and r2(x,y) respectively represent the first simulated defect characteristic value and the second simulated defect characteristic value of the (x,y) pixel point on the region in the R color channel;

[0106] g1(x,y) and g2(x,y) respectively represent the first simulated defect feature value and the second simulated defect feature value of the (x,y) pixel point on the region in the G color channel;

[0107] b1(x,y) and b2(x,y) respectively represent the first simulated defect feature value and the second simulated defect feature value of the (x,y) pixel point on the region in the B color channel.

[0108] Assume that the simulated defect classification template image contains m rows and n columns, totaling m×n pixels. The feature value of the pixel in row i and column j is denoted as defect(i, j). defect(i, j) is a one-dimensional array of length 6, with the six elements represented as r1(i, j), r2(i, j), g1(i, j), g2(i, j), b1(i, j), and b2(i, j). r1(i, j) and r2(i, j) are the first and second simulated defect feature values ​​of pixel (i, j) in the R color channel, respectively. g1(i, j) and g2(i, j) are the first and second simulated defect feature values ​​of pixel (i, j) in the G color channel, respectively. b1(i, j) and b2(i, j) are the first and second simulated defect feature values ​​of pixel (i, j) in the B color channel, respectively.

[0109] Different defects usually have different characteristics, types, and sizes. The following uses pinhole-type simulated defects and foreign fiber-type simulated defects as examples to specifically explain how to assign simulated defect characteristics to each pixel in the simulated defect classification template:

[0110] Hole defects are usually completely transparent, so the hole feature appears in the image with a pixel value of (255, 255, 255) in the pinhole area. However, due to light diffusion, the pixel value in the pinhole neighborhood often gradually changes from 255 to the "0" pixel value of the background image. Figure 3 An example diagram of pinhole type simulation defects with 8 rows and 7 columns is shown. Figure 3 The method of assigning corresponding simulated defect features to each pixel point in the pinhole-type simulated defect example is:

[0111] for Figure 3 For the pixel marked with 1, let: r1=1, r2=0; g1=1, g2=0; b1=1, b2=0;

[0112] For the pixel marked 2: let r1=1, r2=50; g1=1, g2=50; b1=1, b2=50;

[0113] For the pixel marked 3: let r1=1, r2=100; g1=1, g2=100; b1=1, b2=100;

[0114] For the pixel marked 4: let r1=1, r2=150; g1=1, g2=150; b1=1, b2=150;

[0115] For the pixel marked 5: let r1=1, r2=255; g1=1, g2=255; b1=1, b2=255.

[0116] In this way, when the simulated defect feature is applied to an area of ​​8 rows and 7 columns in the image to be detected, the pixel value of the area can achieve the effect of a pinhole defect.

[0117] In short, the method of assigning corresponding simulated defect feature values ​​to each pixel in the pinhole type simulated defect classification template is as follows:

[0118] The first simulated defect characteristic values ​​r1, g1, and b1 of each pixel in the R, G, and B color channels are all assigned a value of "1". For example, in the above example, r1, g1, and b1 of each pixel labeled 1-5 are all assigned a value of "1". The second simulated defect characteristic values ​​r2, g3, and b2 of each pixel in the R, G, and B color channels are assigned as follows:

[0119] Each pixel is divided into several color levels from high to low according to the color of the pixel from dark to light, such as Figure 3 In the example, if the color of the pixel marked 1 is darker than the color of the pixel marked 2, the color level of the pixel marked 1 is classified as the first level, and the color level of the pixel marked 2 is classified as the second level. The first level is higher than the second level.

[0120] Then, the second simulated defect feature values ​​r2, g3, and b2 of each pixel in the R, G, and B color channels are assigned corresponding feature values, such that the larger the color level, the smaller the second simulated defect feature value. For example, in the above example, the second simulated defect feature value r2 of the R color channel of the pixel marked 1 with a color level of the first level is assigned a value of 0, while the second simulated defect feature value r2 of the R color channel of the pixel marked 2 with a color level of the second level is assigned a value of 50.

[0121] The purpose of assigning corresponding feature values ​​to each pixel in the pinhole type simulated defect classification template image in the above method is to make a simulated pinhole defect appear on the image to be detected.

[0122] Foreign fiber defects are colored fibers that are different from the material color that appears on the image to be detected. The characteristic of this type of simulated defect is that the fiber is most obvious at the center and becomes closer to the background image as it moves outward. Figure 4 The example is a schematic diagram of a blue foreign fiber simulated defect with 9 rows and 8 columns. In this embodiment, the simulated defect feature can be assigned as follows:

[0123] for Figure 4 For the pixel marked with 1, let r1=1, r2=0; g1=1, g2=0; b1=1, b2=0;

[0124] For the point marked 2: r1=0.9, r2=-20; g1=0.9, g2=-20; b1=1.2, b2=20;

[0125] For the point marked 3: r1=0.8, r2=-40; g1=0.8, g2=-40; b1=1.4, b2=20;

[0126] For the point marked 4: r1=0.7, r2=-60; g1=0.7, g2=-60; b1=1.6, b2=20;

[0127] In short, the method of assigning simulated defect features to each pixel in the foreign fiber simulated defect classification template is as follows:

[0128] Each pixel is divided into several color levels from high to low according to the color of the pixel. Then, the first simulation defect feature values ​​r1 and g1 of each pixel in the R and G color channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the larger the first simulation defect feature value. The first simulation defect feature value b1 of each pixel in the B color channel is assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the first simulation defect feature value. The second simulation defect feature values ​​r2, g2, and b2 of each pixel in the R, G, and B channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the second simulation defect feature value or the same.

[0129] For example, Figure 4 In the example, the color of the pixel marked 1 is lighter than that of the pixel marked 2. Therefore, the color level of the pixel marked 1 is lower than that of the pixel marked 2. The pixel marked 1 is at the fourth color level, and the pixel marked 2 is at the third color level. According to the above rule, the first simulated defect characteristic values ​​r1 and g1 of the pixel marked 1 in the R and G color channels are larger than those of the pixel marked 2. For example, in the example above, r1 = 1 for the pixel marked 1, while r1 = 0.9 for the pixel marked 2. The first simulated defect characteristic value b1 of each pixel in the B color channel shows that the larger the color level, the smaller the first simulated defect characteristic value. For example, in the example above, b1 = 1 for the pixel marked 1, while b1 = 1.2 for the pixel marked 2. The second simulation defect characteristic values ​​r2, g2, and b2 of each pixel in the R, G, and B channels are assigned in the same manner as the larger the color level, the smaller the second simulation defect characteristic value. For example, in the above example, r2 of the pixel marked 1 is 0, but r2 of the pixel marked 2 is -20, or b2 of the pixel marked 1 is 0, and b2 of the pixel marked 2 is 20.

[0130] The purpose of assigning corresponding characteristic values ​​to each pixel in the foreign fiber simulated defect classification template image in the above method is to make the simulated foreign fiber defect appear on the image to be detected.

[0131] The following is a detailed description of the method by which the defect simulation module determines whether the selected area is the background image in the image to be detected:

[0132] First, set the standard deviation threshold stdv_sh (stdv_sh = 10) and the maximum difference threshold sub_sh (sub_sh = 5). Assume that the image to be inspected entering the defect simulation module is uniquely numbered num (num = 8) and has M rows and N columns, meaning it consists of M × N pixels. The pixel value in row i and column j of the image to be inspected is denoted as img(i,j). Its pixel values ​​in the R, G, and B channels are denoted as img(i,j)[r], img(i,j)[g], and img(i,j)[b], respectively.

[0133] After the image to be inspected enters the defect simulation module, it randomly selects a simulated defect classification template image, or selects several simulated defect classification template images to form a simulated defect group. Assume that the selected simulated defect classification template image has m rows and n columns, and its simulated defect feature value at row i and column j is defect(i,j). Defect(i,j) is a one-dimensional array of length 6, with the six elements in the array represented as r1(i,j), r2(i,j), g1(i,j), g2(i,j), b1(i,j), and b2(i,j).

[0134] The defect simulation module randomly selects a simulated defect classification template image to represent a simulated defect with a pixel size of 5 rows and 6 columns. The defect type is a pinhole. The defect characteristics are shown in Table 1 below:

[0135] Table 1 Selected simulation defect characteristics

[0136]

[0137] Then, a randomly selected simulated defect classification template image is applied to the center row number r0 and the center column number c0 of the image to be inspected.

[0138] The value range of r0 and c0 is:

[0139] , c , that is, the area where the simulated defect classification template is applied on the image to be detected is the first Go to Row, No. Column to The area to be applied is named def_area. or When is an odd number, or Round up.

[0140] Then calculate the standard deviation stdv and the maximum difference sub of the pixel values ​​in the applied area def_area on the image to be detected, where the maximum difference sub is the difference between the maximum and minimum pixel values ​​in the applied area def_area, that is:

[0141] sub=max(set(img(i,j)))- min(set(img(i,j))), r0≤i≤r0+m-1, c0≤j≤c0+n-1. i,j represent the pixel point in the i-th row and j-th column of the application area def_area; img(i,j) is the pixel value of the pixel point in the i-th row and j-th column of the application area def_area, set represents the set of pixels, max(set(img(i,j))) and min(set(img(i,j))) are the maximum and minimum pixel values ​​in the application area def_area, respectively.

[0142] The calculation method of standard deviation stdv is:

[0143]

[0144] Determine whether the standard deviation stdv is less than the standard deviation threshold stdv_sh and the maximum difference sub is less than the maximum difference threshold sub_sh,

[0145] If not, it is determined that the application area def_area is not the background image of the image to be detected, and the simulation defect classification template image is not applied to the application area def_area;

[0146] If so, the application area def_area is determined to be the background image of the image to be detected, and the simulation defect classification template is applied to the application area def_area (for an example of applying the simulation defect classification template to the def_area area, please refer to Figure 7 For an example of def_area before application, please refer to Figure 6 );

[0147] For example, assuming that the calculated values ​​of r0 = 5 and c0 = 6, then based on the method for determining the range of the applied area def_area, the standard deviation stdv and maximum difference sub of the pixel values ​​in rows 3 to 7 and columns 3 to 8 of the image to be detected are calculated. Assume that stdv = 5 and sub = 2. Since stdv = 5 is less than the preset standard deviation threshold of 10, and sub = 2 is less than the preset maximum difference threshold of 5, the applied area def_area is determined to be the background image of the image to be detected.

[0148] In this example, the method for applying the simulation defect classification template map to the application area def_area is:

[0149] The defect center point of the simulated defect classification template image is aligned with the r0 and c0 pixel points calculated on the image to be detected, so as to apply the simulated defect classification template image to the image to be detected. The method of applying the simulated defect classification template image to the image to be detected is expressed by the following expression:

[0150] img(i, j)[r]=img(i,j)[r]*r1(i,j)+r2(i,j)

[0151] img(i, j)[g]=img(i,j)[g]*g1(i,j)+g2(i,j)

[0152] img(i, j)[b]=img(i,j)[b]*b1(i,j)+b2(i,j)

[0153] In the above expression, img(i, j) on the left side of the equation represents the pixel value of the pixel in the i-th row and j-th column after the simulated defect classification template is applied to the region def_area, and img(i, j) on the right side of the equation represents the pixel value of the pixel in the i-th row and j-th column before the simulated defect classification template is applied to the region def_area.

[0154] In this embodiment, the defect simulation module performs a method of marking a simulated defect image on the image to be detected as follows:

[0155] After forming a record and saving it into the simulated defect sample set, the number num of the image to be inspected, the defect center point (r0, c0) of the applied area def_area, the size of the simulated defect classification template image applied to the area def_area, and the type of the simulated defect in the image, the simulated defect image marking of the image to be inspected is completed.

[0156] After the above step S2 is completed, it is determined whether to mark the image to be inspected with a simulated defect image. Figure 2 As shown, the camera-level fully automatic trial and error method based on simulated defects provided in this embodiment proceeds to the following steps:

[0157] S3, perform defect detection and verification on the image to be inspected,

[0158] If the verification is successful, one or more of the defect type, size and position on the image to be inspected is recorded and a defect detection verification report is generated;

[0159] If the verification fails, a defect detection result is generated.

[0160] In this embodiment, the image to be detected transmitted by the defect simulation module is further detected and verified by the defect detection module. Figure 6 For example, the Figure 6 In this example, the image to be inspected has a number num of 8, a set standard deviation threshold of 10, and a maximum difference threshold of 5. The defect detection module uses existing methods to detect defects in the image to be inspected, so the defect detection process is not described here. If a defect is detected, the defect detection result includes parameters such as the type of defect detected, the size of the defect image, and the center point location. The technical innovation of the present invention lies in the correctness verification of the defect detection result. The verification method specifically includes the following steps:

[0161] S31, set the center point matching search radius rad ( Figure 6 The image to be detected in the example is set to rad=1, which is 1 pixel), and it is determined whether the image to be detected for the current defect detection is marked as a simulated defect image.

[0162] If yes, find the defect center point (r0, c0) associated with the number num of the image to be detected from the simulated defect sample set, and then go to step S32;

[0163] If not, generate and store the defect detection result for the image to be detected;

[0164] S32, extracting all types of defects whose center points are within the range of (r0±rad, c0±rad) from the defect results of the image to be inspected, and naming them as defects to be confirmed;

[0165] For example, assuming that the defect detection module detects two defects within the range of (r0±rad, c0±rad), the defect detection results are shown in Table 2 below:

[0166] Table 2 Examples of defects detected on the image to be inspected

[0167]

[0168] Assuming rad=1, find the defect detection results whose center row number on the image to be inspected is in the interval (5-1,5+1) and the center column number is in the interval (6-1,6+1).

[0169] S33, based on the number of defects to be confirmed, determine whether the simulated defects after applying the simulated defect classification template with (r0, c0) as the center point on the image to be detected are successfully detected, and record the judgment result in the defect detection verification report.

[0170] In step S33, the method for determining whether the simulated defect classification template image applied to the image to be inspected with (r0, c0) as the center point is successfully inspected specifically includes the following steps:

[0171] S331, determine whether the number of defects to be confirmed is greater than 1,

[0172] If so, the defect to be confirmed whose center point is closest to (r0, c0) is extracted as a suspected simulated defect applied to the image to be inspected with (r0, c0) as the center point, and then the process goes to step S333;

[0173] If not, go to step S332;

[0174] S332, determine whether the number of defects to be confirmed is 1,

[0175] If so, the defect to be confirmed is determined to be a suspected simulation defect, and then the process goes to step S333;

[0176] If not, it is determined that the application of the simulated defect to the image to be inspected has failed, and the result of determining that the application of the simulated defect has failed is recorded in the defect inspection verification report;

[0177] S333 , comparing the suspected simulated defect with each simulated defect classification template image applied to the image to be detected in terms of type and / or size of the simulated defect, and recording the comparison result in a defect detection verification report.

[0178] Assuming that after the type and / or size comparison of the simulated defects in Table 2 above is performed, the defects represented in Table 3 below are not successfully matched, then the defects represented in Table 3 below are stored in the defect results, and the defect information that is successfully matched is stored in the defect detection verification report of the example in Table 4.

[0179] Table 3 Examples of defect information that need to be stored in the defect detection results

[0180]

[0181] Table 4 Example of defect information that needs to be stored in the defect detection and verification report

[0182]

[0183] S34, recording the remaining defects except the suspected simulation defects in the defect detection results.

[0184] It should also be noted that under the "if" judgment of step S331 or step S332, the comparison results of step S333 include two types. The first is that the comparison is successful, then the type and / or size of the simulated defect in the successfully compared simulated defect classification template diagram is extracted, and the successful comparison result is used as the classification and / or size recognition result of the suspected simulated defect. The second is that the comparison fails, then it is determined that the suspected simulated defect is not a simulated defect applied to the image to be detected, and the result of the failed comparison is formed into a defect detection verification report, thereby realizing the verification of whether the defect detection result of the defect detection module on the image to be detected is a simulated defect applied to the image to be detected, and thereby quickly identifying the type and size of the defect detected by the defect detection module, without the need for a complex simulation defect image training process, defect detection is faster and more efficient, and the defect detection process takes into account the influence of the background of the image to be detected on the detection result, and the defect detection accuracy is higher. In addition, since the rationality of the optical path design, the correctness of the optical path imaging, and the balanced consistency of the defect detection capability may affect the number of defects to be confirmed, this embodiment identifies suspected simulated defects by judging the number of defects to be confirmed, thereby realizing the verification of the rationality of the optical path design, the correctness of the optical path imaging, and the balanced consistency of the defect detection capability.

[0185] This embodiment also provides a camera-level fully automatic trial and error system based on simulated defects, such as Figure 5 As shown, including:

[0186] An image storage module is used to store a plurality of image data collected by the image acquisition module for the workpiece to be inspected as an image to be inspected with M rows and N columns of pixels;

[0187] The defect simulation module is connected to the image storage module and is used to further randomly select at least one area from the image to be detected randomly selected in the image storage module, and then randomly select at least one simulated defect classification template image from its own module, and then determine whether the selected area is the background image of the image to be detected based on the simulated defect classification template image.

[0188] If yes, the simulated defect classification template image used as the basis for judgment is superimposed on the area to be judged, and the image to be inspected is compared with the simulated defect image and then transmitted to the defect detection module;

[0189] If not, the image to be inspected is transmitted to the defect detection module;

[0190] The defect detection module is connected to the defect simulation module to detect and verify defects in the image to be inspected.

[0191] If the verification is successful, one or more of the defect type, size, and position on the image to be inspected is recorded and recorded in a defect detection verification report;

[0192] If the verification fails, the result of determining that the simulation defect application fails is recorded in the defect detection verification report.

[0193] The remaining defects are recorded in the defect detection results.

[0194] in addition, Figure 5 The defect result module shown in is used to form defect detection results, and the report generation module is used to automatically generate defect detection verification reports.

[0195] The following briefly describes the functions that can be verified by the camera-level fully automatic trial and error system based on simulated defects provided in this embodiment:

[0196] 1. Defect detection sensitivity verification

[0197] The trial and error system provided in this embodiment verifies the detection sensitivity of the trial and error system by generating simulated defect samples with different gray levels.

[0198] The system can accurately simulate various defect features, ranging from fuzzy (small grayscale difference) to obvious (large grayscale difference). Users can request that the system automatically record the detection rate, size error, and correct classification probability of simulated defects at each grayscale level. Table 5 below shows an example of the system's quantitative defect analysis results for a certain simulated defect at different grayscale levels. Table 6 shows an example of the system's qualitative defect analysis results for a certain simulated defect at a certain grayscale level. In this example, the user sets the maximum grayscale difference between a certain simulated defect and the background image to be between 70 and 130. In this case, the system's simulated defect detection rate, size error, and correct classification probability for the image to be inspected are all qualified, indicating that the defect detection algorithm provided in this embodiment can meet the requirements.

[0199] Table 5 Example of quantitative analysis results of a certain simulated defect at different gray levels

[0200]

[0201] Table 6 Example of the system's qualitative analysis results for a certain simulated defect at a certain grayscale level

[0202]

[0203] 2. Defect size detection capability

[0204] The trial-and-error system provided in this embodiment comprehensively verifies the defect size detection capability of the detection system by generating simulated defect samples of different size levels.

[0205] The trial-and-error system can simulate a variety of defect characteristics, ranging from vague (small grayscale difference) to obvious (large grayscale difference). For irregularly shaped defects, it can set several possible shapes to determine their impact on dimensional detection. The verification process includes both linear and area dimensional testing. Statistical analysis generates a dimensional accuracy report containing key metrics such as mean error, maximum error, and standard deviation. The system also plots a correlation curve between actual and measured dimensions, visually demonstrating how measurement accuracy changes with defect size.

[0206] 3. Verification of consistency of horizontal position detection capability

[0207] To ensure consistent inspection across the entire inspection area of ​​the image being inspected, the system innovatively incorporates a lateral scanning verification mechanism. By applying the same simulated defect to the same area in different inspection images, the defect is effectively applied to different lateral locations on the workpiece or material being inspected. By comparing the positional inspection results for this simulated defect, the consistency of the system's lateral positional inspection capabilities can be assessed.

[0208] 4. Verification of the accuracy of classification results

[0209] The system comprehensively tests the classification accuracy of various simulated defect types, including foreign matter, pinholes, oil stains, and dark spots. The system constructs a confusion matrix, recording the correct classification rate and incorrect classification distribution for each defect type, and calculates key evaluation metrics such as precision, recall, and F1 score. Furthermore, the system flexibly adjusts the weighting applied to different simulated defect types in the inspection image based on actual production needs, prioritizing the verification of the accuracy of key defect types. Verification results include overall classification accuracy and detailed classification performance for each defect type, providing data support for ongoing system optimization.

[0210] 5. Reliability of Outbreak Defects

[0211] In response to the explosive defect scenarios that may occur during the production process, the system is designed with a patented stress testing function. By applying a large number of simulated defects at a high frequency in a short period of time (making a simulated defect group consist of multiple sub-defects with the same or different characteristics, and applying the simulated defect group in multiple consecutive images to be detected), the system's detection reliability and processing stability under extreme conditions are fully verified. The system records and analyzes the changes in detection rate, response time delay and system resource usage in the case of explosive defects, and evaluates the performance of the system under high load. The present invention also pays special attention to the system's memory management and parallel processing capabilities to ensure that there will be no data loss or system crash when faced with a large number of sudden defects. The verification process also includes recovery testing to evaluate the time and performance changes for the system to recover from high load to normal state. Through this function, the system can effectively prevent the risk of detection failure due to explosive defects, and ensure the continuity of the production process and the stability of product quality.

[0212] 6. Automatic report output function

[0213] The system integrates an intelligent report generation module, which can automatically generate a comprehensive system performance evaluation report after the entire verification process is completed. The report content includes detailed test results of the aforementioned functions, presented in various forms such as numerical values, charts and ratings. Based on the preset performance standards, the system automatically evaluates whether the various functional indicators meet the requirements and gives a clear pass or fail conclusion. For indicators that do not meet the standards, the system will provide users with specific gap data and optimization suggestions. The report supports multiple output formats, such as PDF, HTML, Excel, etc., and is automatically distributed to relevant personnel through the network. In addition, the system also has a historical data comparison function, which can automatically analyze the changing trends of system performance and promptly identify potential performance degradation problems. Through this automated reporting function, the efficiency and standardization of system verification have been greatly improved, providing reliable data support for equipment maintenance and quality management.

[0214] In summary, this embodiment has the following beneficial effects:

[0215] 1. The system boasts comprehensive risk prevention and control capabilities, effectively addressing the issue of poorly balanced and consistent defect detection capabilities. Furthermore, the rationality of the optical path design is verified once after initial system installation to ensure long-term reliability. Subsequent verification is unnecessary unless physical modifications are made. The correct functioning of optical path imaging can be accurately determined through manual trial and error and by adjusting the camera image brightness.

[0216] 2. The system has a highly flexible operating time feature. It does not require downtime for inspection or special verification time. Defect detection and verification can be performed at any time during the production process without affecting the normal production process or interfering with the generation and recording of test results. This feature allows the production line to maintain continuous operation. At the same time, the system can perform real-time monitoring and verification in the background, greatly improving production efficiency.

[0217] 3. The system utilizes advanced intelligent algorithms and automated control technologies to achieve fully automated operation. From defect detection to data analysis and report generation, the entire process requires no human intervention, significantly reducing human error. The automated report generation function outputs detailed defect detection results reports based on pre-set templates, enabling production managers to quickly understand product quality status and make informed decisions.

[0218] 4. The system's design fully considers cost-effectiveness. First, the system simulates defects according to pre-set methods, eliminating the need for training defect samples. This system leverages existing camera hardware resources, adding trial-and-error functionality to basic inspection capabilities without requiring additional hardware investment. Furthermore, through software optimization and functional integration, the system fully leverages the potential of existing camera equipment, achieving functional expansion and performance improvements. Furthermore, the system's modular design allows future upgrades to focus on specific modules, avoiding the high cost of replacing the entire system.

[0219] It should be noted that the above-described specific embodiments are merely preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that various modifications, equivalent substitutions, variations, and the like may be made to the present invention. However, as long as these modifications do not depart from the spirit of the present invention, they are intended to be within the scope of protection of the present invention. Furthermore, certain terms used in this specification are not intended to be limiting and are provided solely for ease of description.

Claims

1. A camera-level fully automatic trial and error system based on simulated defects, characterized by: include: An image storage module is used to store a plurality of image data collected by the image acquisition module for the workpiece to be inspected as an image to be inspected with M rows and N columns of pixels; a defect simulation module, connected to the image storage module, configured to randomly select at least one simulated defect classification template image, then further randomly select at least one region having the same size as the selected simulated defect classification template image from the image to be detected randomly selected from the image storage module, and determine whether the selected region is the background image of the image to be detected; If so, the simulated defect classification template image used as a basis for judgment is superimposed on the area to be judged, and the image to be detected is marked with a simulated defect image and then transmitted to the defect detection module; If not, transmitting the image to be inspected to the defect detection module; A defect detection module, connected to the defect simulation module, is used to perform defect detection and verification on the image to be detected, If the verification is successful, one or more of the defect type, size, and position on the image to be inspected is recorded and a defect detection verification report is generated; If the verification fails, a defect detection result is generated; The method of assigning simulated defect features to each pixel in the simulated defect classification template image is as follows: The method of assigning the corresponding simulated defect feature value to each pixel in the pinhole type simulated defect classification template is as follows: The first simulated defect characteristic values ​​r1, g1, and b1 of each pixel in the R, G, and B color channels are all assigned a value of "1". The second simulated defect characteristic values ​​r2, g2, and b2 of each pixel in the R, G, and B color channels are assigned values ​​as follows: Each pixel is divided into several color levels from high to low according to the color of the pixel from dark to light, and then the second simulated defect feature values ​​r2, g2, and b2 of each pixel in the R, G, and B color channels are assigned corresponding defect feature values ​​in a manner such that the larger the color level, the smaller the second simulated defect feature value; The method for assigning simulated defect features to each pixel in the foreign fiber simulated defect classification template is as follows: Each pixel is divided into several color levels from high to low according to the color of the pixel. Then, the first simulation defect feature values ​​r1 and g1 of each pixel in the R and G color channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the larger the first simulation defect feature value. The first simulation defect feature value b1 of each pixel in the B color channel is assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the first simulation defect feature value. The second simulation defect feature values ​​r2, g2, and b2 of each pixel in the R, G, and B channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the second simulation defect feature value or the same.

2. The camera-level fully automatic trial and error system based on simulated defects according to claim 1 is characterized in that: When determining whether the region is the background image in the image to be detected, the size of the randomly selected simulation defect classification template used as a basis for determination is consistent with the size of the region used as the determination object.

3. The camera-level fully automatic trial and error system based on simulated defects according to claim 1, characterized in that: The method of superimposing the simulation defect classification template map onto the region is expressed as follows: ; ; ; Wherein, pr_arti_dt(x,y), pg_arti_dt(x,y), and pb_arti_dt(x,y) are the pixel values ​​of the R color channel, the G color channel, and the B color channel after applying the simulated defect at the pixel point (x,y) of the region, respectively; pr_ori(x,y), pg_ori(x,y), and pb_ori(x,y) are the pixel values ​​of the R color channel, the G color channel, and the B color channel at the pixel point (x,y) on the region before the simulated defect is applied; r1(x,y) and r2(x,y) respectively represent the first simulated defect characteristic value and the second simulated defect characteristic value of the (x,y) pixel point on the region in the R color channel; g1(x,y) and g2(x,y) respectively represent the first simulated defect feature value and the second simulated defect feature value of the (x,y) pixel point on the region in the G color channel; b1(x,y) and b2(x,y) respectively represent the first simulated defect feature value and the second simulated defect feature value of the (x,y) pixel point on the region in the B color channel.

4. The camera-level fully automatic trial and error system based on simulated defects according to any one of claims 1 to 3, characterized in that: Each pixel in the simulation defect classification template image is divided into several levels according to color from dark to light, and then the pixel with the corresponding color level is assigned the corresponding simulation defect feature value in the R, G, and B channels respectively.

5. The camera-level fully automatic trial and error system based on simulated defects according to claim 1, characterized in that: The method for determining whether the selected area is the background image of the image to be detected is: Calculate and apply the simulated defect classification template image to the center row number r0 and the center column number c0 of the image to be detected, where r0 and c0 are both defect center points of the simulated defect classification template image; Align the defect center point of the simulated defect classification template image with the r0 and c0 pixel points calculated on the image to be detected, so as to apply the simulated defect classification template image to the image to be detected, and then calculate the standard deviation stdv and maximum difference sub of the pixel values ​​of the application area def_area on the image to be detected; Determine whether the standard deviation stdv is less than the standard deviation threshold stdv_sh and the maximum difference sub is less than the maximum difference threshold sub_sh, If yes, it is determined that the application area def_area is the background image of the image to be detected; If not, it is determined that the application area def_area is not the background image of the image to be detected, and the applied simulation defect classification template image is removed from the application area def_area.

6. The camera-level fully automatic trial and error system based on simulated defects according to claim 5, characterized in that: , c , where m and n represent the pixels with m rows and n columns in the simulation defect classification template image; M and N represent the pixels with M rows and N columns in the image to be detected; The maximum difference sub is the difference between the maximum and minimum pixel values ​​in the application area def_area; The method for the defect simulation module to mark the image to be detected as a simulated defect image is: After forming a record of the number num of the image to be inspected, the defect center point (r0, c0) of the application area def_area, the size of the simulated defect classification template image applied to the area def_area, and the type of the simulated defect in the image and saving it to the simulated defect sample set, the simulated defect image marking of the image to be inspected is completed; The sizes of different simulation defect classification template images are the same or different.

7. The camera-level fully automatic trial and error system based on simulated defects according to claim 1, characterized in that: The method for the defect detection module to detect and verify defects on the image to be detected includes the following steps: S31, setting the center point matching search radius rad, and judging whether the image to be detected currently undergoing defect detection is marked as a simulated defect image, If yes, find the defect center point (r0, c0) associated with the number num of the image to be detected from the simulated defect sample set, and then go to step S32; If not, generating and storing the defect detection result of the image to be detected; S32, extracting all types of defects whose center points are within the range of (r0±rad, c0±rad) from the defect results of the image to be detected, and naming them as defects to be confirmed; S33, judging whether the simulated defect classification template image applied to the image to be inspected with (r0, c0) as the center point is successfully detected based on the number of defects to be confirmed, and generating the judgment result as the defect detection verification report; S34, recording the remaining defects except the suspected simulation defects in the defect detection results.

8. The camera-level fully automatic trial and error system based on simulated defects according to claim 7, characterized in that: Step S33 specifically includes the following steps: S331, determine whether the number of defects to be confirmed is greater than 1, If so, extract the defect to be confirmed whose center point is closest to (r0, c0) as the suspected simulated defect applied to the image to be inspected with (r0, c0) as the center point, and then go to step S333; If not, go to step S332; S332, determine whether the number of defects to be confirmed is 1, If so, the defect to be confirmed is determined to be a suspected simulation defect, and then the process goes to step S333; If not, it is determined that the application of the simulated defect on the image to be inspected fails, and the result of determining the application of the simulated defect fails is recorded in the defect inspection verification report, and the remaining defects are output to the defect inspection result; S333, comparing the type and / or size of the suspected simulated defects with each of the simulated defect classification templates applied to the image to be detected, and recording the comparison results in the defect detection verification report, and outputting the remaining defects to the defect detection results.

9. A camera-level fully automatic trial and error method based on simulated defects, implemented by the camera-level fully automatic trial and error system based on simulated defects according to any one of claims 1 to 8, characterized in that: Including steps: S1, storing a plurality of image data collected for the workpiece to be inspected as an image to be inspected with M rows and N columns of pixels; S2, randomly selecting at least one simulated defect classification template image, then randomly selecting at least one area with the same size as the selected simulated defect template image from the randomly selected image to be detected, and then determining whether the selected area is the background image of the image to be detected, If yes, the simulated defect classification template image is superimposed on the selected area, and the image to be inspected is marked as a simulated defect image before proceeding to step S3; If not, go to step S3; S3, performing defect detection and verification on the image to be detected, If the verification is successful, one or more of the defect type, size, and position on the image to be inspected is recorded and recorded in a defect detection verification report; If the verification fails, the result of determining that the simulation defect application fails is recorded in the defect detection verification report, and the remaining defects are recorded in the defect detection results; The method of assigning the corresponding simulated defect feature value to each pixel in the pinhole type simulated defect classification template is as follows: The first simulated defect characteristic values ​​r1, g1, and b1 of each pixel in the R, G, and B color channels are all assigned a value of "1". The second simulated defect characteristic values ​​r2, g2, and b2 of each pixel in the R, G, and B color channels are assigned values ​​as follows: Each pixel is divided into several color levels from high to low according to the color of the pixel from dark to light, and then the second simulated defect feature values ​​r2, g2, and b2 of each pixel in the R, G, and B color channels are assigned corresponding defect feature values ​​in a manner such that the larger the color level, the smaller the second simulated defect feature value; The method for assigning simulated defect features to each pixel in the foreign fiber simulated defect classification template is as follows: Each pixel is divided into several color levels from high to low according to the color of the pixel. Then, the first simulation defect feature values ​​r1 and g1 of each pixel in the R and G color channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the larger the first simulation defect feature value. The first simulation defect feature value b1 of each pixel in the B color channel is assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the first simulation defect feature value. The second simulation defect feature values ​​r2, g2, and b2 of each pixel in the R, G, and B channels are assigned corresponding defect feature values ​​in a manner that the larger the color level, the smaller the second simulation defect feature value or the same.

Citation Information

Patent Citations

  • Industrial defect image generation method

    CN117315387A

  • Weak supervision machine vision detection method and system based on artificial defect simulation

    CN111982910A

  • Image processing method and device, electronic equipment and medium

    CN113887481A

  • Photomask defect identification method

    CN119540196A