Image-based product quality detection method and device, and electronic equipment

By conducting the connection domain detection and area comparison of product images with unqualified initial inspection results, combined with the re-checking of classification models, the problems of high false alarm rate and low detection accuracy in the existing technology are solved, and efficient and accurate product quality inspection is achieved.

CN120013845APending Publication Date: 2025-05-16BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311527248.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-15
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

When detecting product quality defects, existing image detection equipment lacks sufficient sensitivity, resulting in high false alarm rate and low accuracy of detection results.

Method used

By detecting the connection domain of the product image whose initial inspection results are unqualified, the area of ​​each connection domain is calculated, and compared with the preset threshold value, the re-inspection results of the product are determined. Optionally, the target product image is further input to the pre-trained classification model for re-checking.

Benefits of technology

It improves the accuracy of product quality inspection, reduces the false alarm rate and missed detection rate, achieves high consistency detection results, and reduces the detection cost and re-inspection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120013845A_ABST
    Figure CN120013845A_ABST
Patent Text Reader

Abstract

The invention relates to an image-based product quality detection method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring an initial inspection result of a product, and determining a product image corresponding to a product with an unqualified initial inspection result as a target product image; performing connected domain detection on the target product image, and determining each connected domain contained in the target product image; and calculating a connected domain area corresponding to each connected domain, comparing the calculated connected domain area with a threshold value of the connected domain area corresponding to the product, and determining a first reinspection result of the product according to a comparison result. According to the method and the device, the product is rechecked based on the area of the connected domain of the product image which is unqualified in initial check, on one hand, the rechecking efficiency can be improved, the detection cost can be reduced, and the detection result has high consistency, and on the other hand, due to the fact that the detection logic has interpretability, the detection accuracy can be improved, zero leak detection is realized, and the detection efficiency is improved. And the false alarm rate of detection can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of detection technology, and in particular to an image-based product quality detection method, device, electronic device and storage medium. Background Art

[0002] With the continuous integration of information technology and manufacturing, information technology can be introduced in various links of manufacturing to transform existing processes, thereby achieving the advantages of improving production efficiency, ensuring product quality and reliability, and reducing production costs.

[0003] At present, image detection equipment can be used to capture images of products and detect the images of products to determine whether the products have quality defects, and if quality defects exist, relevant personnel can be notified in a timely manner to handle them.

[0004] However, since the detection algorithms of image detection devices often lack sufficient sensitivity, images with quality defects determined by the image detection devices are mixed with a large number of images of qualified products, that is, there are many false alarms.

[0005] Therefore, it is necessary to improve the accuracy of detection and reduce the false alarm rate. Summary of the invention

[0006] The present disclosure provides an image-based product quality detection method, device, electronic device and storage medium to address deficiencies in the related art.

[0007] According to a first aspect of an embodiment of the present disclosure, a product quality detection method based on an image is proposed, the method comprising:

[0008] Obtaining the initial inspection result of the product, and determining the product image corresponding to the product with the initial inspection result being unqualified as the target product image;

[0009] Performing connected domain detection on the target product image to determine each connected domain contained in the target product image;

[0010] The connected domain areas corresponding to the connected domains are calculated, the calculated connected domain areas are compared with a threshold of the connected domain area corresponding to the product, and a first re-inspection result of the product is determined according to the comparison result.

[0011] Optionally, before performing connected domain detection on the product image, the method further includes:

[0012] The target product image is input into a pre-trained classification model, so that the classification model outputs a second re-inspection result for the target product image.

[0013] Optionally, the performing connected domain detection on the target product image to determine each connected domain contained in the target product image includes:

[0014] The product image corresponding to the product with the second re-inspection result of being qualified is determined as the target product image, and a connected domain detection is performed on the target product image to determine each connected domain included in the target product image.

[0015] Optionally, the classification model is a deep learning model that supports a variable penalty coefficient; wherein, among the samples used in training the deep learning model, the penalty coefficient corresponding to the samples whose second re-inspection results are qualified is smaller than the penalty coefficient corresponding to the samples whose second re-inspection results are unqualified.

[0016] Optionally, the performing connected domain detection on the target product image to determine each connected domain contained in the target product image includes:

[0017] Traversing each pixel contained in the target product image to determine the connection relationship between the pixels;

[0018] Determine adjacent pixels according to the connection relationship between the pixels, and divide the adjacent pixels into the same connected domain;

[0019] The calculating the connected domain areas corresponding to the connected domains respectively includes:

[0020] Determine the number of pixels contained in each of the connected domains;

[0021] Based on the number of pixels respectively included in each of the connected domains, the connected domain areas respectively corresponding to the each of the connected domains are calculated.

[0022] Optionally, comparing the calculated connected domain area with a threshold value of a connected domain area corresponding to the product, and determining a first re-inspection result of the product according to the comparison result, includes:

[0023] Determine a maximum value among the calculated connected domain areas, and compare the maximum value with a threshold value of the connected domain area corresponding to the product;

[0024] In response to the maximum value reaching a threshold value of a preset connected domain area corresponding to the product, determining that the first re-inspection result of the product is qualified;

[0025] In response to the maximum value being smaller than a threshold of a preset connected domain area corresponding to the product, it is determined that the first re-inspection result of the product is unqualified.

[0026] Optionally, the first re-inspection result includes a detection result of whether any parts are missing from the product during the production process.

[0027] Optionally, the threshold of the connected domain area is determined by the following methods, including:

[0028] Acquire a plurality of product images with qualified initial inspection results, and respectively determine the maximum value of the connected domain area in the connected domain contained in each of the plurality of product images with qualified initial inspection results;

[0029] Taking the maximum value corresponding to each product image as a sample in a statistical sample set;

[0030] Statistical analysis is performed on the statistical sample set to determine a threshold value of the connected domain area.

[0031] Optionally, performing statistical analysis on the statistical sample set to determine the threshold of the connected domain area includes:

[0032] For the statistical sample set, statistical analysis is performed according to the interquartile range statistical method based on the following formula: τ = Q1-K*IQR, IQR = Q3-Q1;

[0033] Among them, τ represents the threshold of the connected domain area, Q1 represents the first quartile in the statistical sample set, Q3 represents the third quartile in the statistical sample set, IQR represents the interquartile range, K represents the weight parameter, and the value of K is 1.5 or 3.

[0034] Optionally, before obtaining the initial inspection result of the product, the method further includes:

[0035] A preliminary inspection is performed on the initial inspection product image of the product collected by the optical inspection equipment on the product production line to determine the initial inspection result.

[0036] Optionally, the product includes a circuit board, and the target product image includes an image of a circuit board that has been found unqualified in an initial inspection.

[0037] Optionally, the performing connected domain detection on the target product image includes:

[0038] The target product image is binarized, and connected domain detection is performed on the binarized target product image.

[0039] Optionally, the binarization processing of the target product image includes:

[0040] Determine the grayscale of each pixel contained in the target product image;

[0041] According to a preset grayscale threshold, the grayscale of each pixel included in the target product image is binarized.

[0042] Optionally, the preset grayscale threshold includes a grayscale threshold pre-specified by an inspector, or a grayscale threshold determined according to a numerical range corresponding to the grayscale of each pixel contained in the target product image.

[0043] Optionally, before performing connected domain detection on the binarized product image, the method further includes:

[0044] Image erosion is performed on the target product image after the binarization process to eliminate noise points in the target product image.

[0045] According to a second aspect of an embodiment of the present disclosure, a product quality detection device based on an image is provided, the device comprising:

[0046] The first acquisition module is used to obtain the initial inspection result of the product, and determine the product image corresponding to the product with the initial inspection result being unqualified as the target product image;

[0047] A first connected domain detection module, configured to perform connected domain detection on the target product image to determine each connected domain contained in the target product image;

[0048] The comparison module is used to calculate the connected domain areas corresponding to the respective connected domains, compare the calculated connected domain areas with the threshold of the connected domain areas corresponding to the product, and determine the first re-inspection result of the product according to the comparison result.

[0049] Optionally, the device further comprises:

[0050] The classification module is used to input the target product image into a pre-trained classification model so that the classification model outputs a second re-inspection result for the target product image.

[0051] Optionally, the first connected domain detection module includes:

[0052] The second connected domain detection module is used to determine the product image corresponding to the product with the second re-inspection result as qualified as the target product image, and perform connected domain detection on the target product image to determine each connected domain contained in the target product image.

[0053] Optionally, the first connected domain detection module includes:

[0054] A pixel traversal module, used to traverse each pixel contained in the target product image and determine the connection relationship between the pixels;

[0055] A division module, used for determining adjacent pixels according to the connection relationship between the pixels, and dividing the adjacent pixels into the same connected domain;

[0056] The comparison module comprises:

[0057] A number determination module, used to determine the number of pixels contained in each of the connected domains;

[0058] The number calculation module is used to calculate the connected domain areas corresponding to each of the connected domains based on the number of pixels respectively included in each of the connected domains.

[0059] Optionally, the comparison module includes:

[0060] An area comparison module, used to determine the maximum value among the calculated connected domain areas, and compare the maximum value with a threshold value of the connected domain area corresponding to the product;

[0061] A first result module, configured to determine that a first re-inspection result of the product is qualified in response to the maximum value reaching a threshold value of a preset connected domain area corresponding to the product;

[0062] The second result module is used to determine that the first re-inspection result of the product is unqualified in response to the maximum value being smaller than a threshold value of a preset connected domain area corresponding to the product.

[0063] Optionally, the device further comprises:

[0064] A second acquisition module is used to acquire a plurality of product images with qualified initial inspection results, and respectively determine the maximum value of the connected domain area in the connected domain contained in each of the plurality of product images with qualified initial inspection results;

[0065] A sample module, used to take the maximum value corresponding to each product image as a sample in a statistical sample set;

[0066] The analysis module is used to perform statistical analysis on the statistical sample set to determine the threshold value of the connected domain area.

[0067] Optionally, the device further comprises:

[0068] The initial inspection module is used to perform preliminary inspection on the product images of the product collected by the optical inspection equipment on the product production line to determine the initial inspection results.

[0069] Optionally, the first connected domain detection module includes:

[0070] The binarization processing module is used to perform binarization processing on the target product image and perform connected domain detection on the target product image after the binarization processing.

[0071] Optionally, the binarization processing module includes:

[0072] A grayscale determination module, used to determine the grayscale of each pixel contained in the target product image;

[0073] The grayscale binarization processing module is used to perform binarization processing on the grayscale of each pixel contained in the target product image according to a preset grayscale threshold.

[0074] Optionally, the device further comprises:

[0075] The image erosion module is used to perform image erosion on the target product image after the binarization process to eliminate noise points in the target product image.

[0076] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0077] processor;

[0078] a memory for storing processor-executable instructions;

[0079] Wherein, the processor is used to implement the above-mentioned image-based product quality detection method.

[0080] According to a fourth aspect of an embodiment of the present disclosure, there is provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is used to implement the above-mentioned image-based product quality inspection method when executed by a processor.

[0081] The technical solution provided by the embodiments of the present disclosure may at least include the following beneficial effects:

[0082] According to an embodiment of the present disclosure, a connected domain detection is performed on the product image corresponding to the product with an unqualified initial inspection result, and the connected domain area corresponding to each detected connected domain is calculated, and compared with the threshold value of the connected domain area, so as to obtain the first re-inspection result of the product. In the above process, by re-inspecting the product based on the area of ​​the connected domain of the product image that failed the initial inspection, on the one hand, the efficiency of the re-inspection can be improved, the detection cost can be reduced, and the detection results have high consistency. On the other hand, because the detection logic is explainable, the accuracy of the detection can be improved, zero missed detection can be achieved, and the false alarm rate of the detection can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0084] Figure 1It is a schematic flow chart of an image-based product quality detection method according to an embodiment of the present disclosure.

[0085] Figure 2 The figure is a flow chart showing a method of detecting connected domains on a product image according to an embodiment of the present disclosure.

[0086] Figure 3 The figure is a flowchart showing a method of binarizing a product image according to an embodiment of the present disclosure.

[0087] Figure 4 It is a flowchart of another image-based product quality detection method according to an embodiment of the present disclosure.

[0088] Figure 5 It is a flowchart of another image-based product quality detection method according to an embodiment of the present disclosure.

[0089] Figure 6 The present invention is a flowchart showing a threshold value for determining the area of ​​a connected domain according to an embodiment of the present invention.

[0090] Figure 7 It is a flowchart of another image-based product quality detection method according to an embodiment of the present disclosure.

[0091] Figure 8 A schematic block diagram of an image-based product quality detection device is shown according to an embodiment of the present disclosure.

[0092] Fig. 9 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0093] Fig.10 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0094] Fig.11 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0095] Fig.12 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0096] Fig.13 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0097] Fig.14 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0098] Fig.15 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0099] Fig.16 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0100] Fig.17 A schematic block diagram of another image-based product quality detection device according to an embodiment of the present disclosure is shown.

[0101] Fig.18 A schematic block diagram of a device for image-based product quality inspection is shown according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0102] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.

[0103] In the process of product production, in order to ensure the quality of the product, the product is usually re-inspected. And, as mentioned above, since the images with quality defects detected by the current image detection equipment are mixed with a large number of images of qualified products, it is necessary to kick out the images of qualified products through re-inspection and retain the images of unqualified products.

[0104] In the related art, re-inspection can be performed manually, with the re-inspection personnel manually judging whether the product actually has quality problems based on the images with quality defects detected by the image detection equipment. If there are no quality problems, the re-inspection personnel manually correct the detection results.

[0105] However, manual re-inspection is not only inefficient but also has high labor costs. It may also lead to poor consistency in re-inspection results due to differences in the working conditions and work experience of the re-inspectors.

[0106] Furthermore, re-inspection can be performed based on a detection model. By acquiring a certain number of images of qualified products and images of unqualified products to construct samples, a detection model that can identify unqualified products can be trained to replace manual re-inspection.

[0107] However, the essence of the detection model is a "black box" method that cannot be clearly quantified. The model has poor interpretability and the re-inspection results are uncertain, which leads to actually unqualified products being judged as qualified, causing serious hidden dangers.

[0108] It can be seen that in the above-mentioned embodiments of the related technology, there are still cases of low detection accuracy and false alarms.

[0109] The following is an introduction to the image-based product quality detection method provided by the present disclosure through specific embodiments.

[0110] See also Figure 1 , Figure 1 FIG. 1 is a flowchart of a method for detecting product quality based on an image according to an embodiment of the present disclosure. Figure 1 As shown, the image-based product quality detection method may include the following steps:

[0111] In step 110, the initial inspection result of the product may be obtained, and the product image corresponding to the product with the initial inspection result being unqualified may be determined as the target product image.

[0112] For example, after the initial inspection of the product, the initial inspection result of the product can be obtained. The initial inspection result can include two results: qualified and unqualified. The purpose of the re-inspection is to screen out qualified products from the products with unqualified initial inspection results. Therefore, the product image corresponding to the product with unqualified initial inspection results can be determined as the target product image.

[0113] In an embodiment shown, before step 110, a preliminary inspection may be performed on the initial inspection product image of the product collected by the optical inspection equipment on the product production line to determine the initial inspection result.

[0114] For example, on a product production line, an Automated Optical Inspection (AOI) device can be used to collect product images and conduct an initial inspection of the product images to determine whether the product is qualified. However, as mentioned above, due to the limited detection accuracy of the AOI device, the product images of unqualified products determined by the AOI device are still mixed with a large number of qualified product images, resulting in a large number of false positives, which require re-inspection.

[0115] During re-inspection, it can be completed based on the image-based product quality inspection method disclosed in the present invention.

[0116] In one embodiment shown, the product includes a circuit board, and the target product image includes an image of a circuit board that is found to be unqualified in a preliminary inspection.

[0117] For example, the above-mentioned product can be a printed circuit board (PCB). In the production process of the product, electronic components need to be deployed on the circuit board. However, since components may be missing or offset during the deployment process, defective products may be produced. Therefore, AOI equipment can be used to collect circuit board images and compare them with normal circuit board images to find abnormal and unqualified circuit boards. The images of the circuit boards with unqualified initial inspection results are used as the target product images to further re-inspect the target product images.

[0118] In step 120, connected domain detection may be performed on the target product image to determine each connected domain included in the target product image.

[0119] For example, connected domain detection may be performed on the determined target product image to determine each connected domain included in the target product image, thereby determining the number of connected domains and the position of each connected domain in the product image.

[0120] In one embodiment shown, see Figure 2 , Figure 2 The figure is a flow chart showing a method of detecting connected domains on a product image according to an embodiment of the present disclosure.

[0121] like Figure 2 As shown, in step 120, the connected domain detection on the target product image may include:

[0122] Step 210, performing binarization processing on the target product image;

[0123] Step 230 , performing connected domain detection on the target product image after binarization processing.

[0124] The above-mentioned binarization process is an image segmentation method. Before the binarization process, the target product image may be pre-processed by color channel filtering to obtain a grayscale image corresponding to the target product image.

[0125] For example, in a product image, different parts of the product have different reflective levels, such as the reflective level of the components on the PCB is much higher than that of the base plate itself. Therefore, the grayscale image can be binarized in step 210 to segment the grayscale image, and then connected domain detection can be performed on the binarized grayscale image in step 220.

[0126] In one embodiment shown, see Figure 3 , Figure 3 The figure is a flowchart showing a method of binarizing a target product image according to an embodiment of the present disclosure.

[0127] like Figure 3 As shown, in step 210, the binarization process of the target product image may include:

[0128] Step 310, determining the grayscale of each pixel included in the target product image;

[0129] Step 320: binarize the grayscale of each pixel in the target product image according to a preset grayscale threshold.

[0130] For example, the grayscale corresponding to each pixel can be determined by measuring the brightness of each pixel in a single electromagnetic wave spectrum such as visible light, and then the grayscale of each pixel is compared with a preset grayscale threshold. Pixels with grayscale greater than the grayscale threshold are marked as 1, and pixels with grayscale less than the grayscale threshold are marked as 0, thereby achieving binarization processing.

[0131] In an illustrated embodiment, the preset grayscale threshold may include a grayscale threshold pre-specified by an inspector, or a grayscale threshold determined according to a numerical range corresponding to the grayscale of each pixel included in the target product image.

[0132] In one example, a fixed threshold binarization method may be used, with the grayscale threshold pre-specified by the inspector.

[0133] In another example, an adaptive threshold binarization method may be used to perform statistical analysis based on the grayscale of each pixel included in the target product image to obtain an adaptive value.

[0134] In one embodiment shown, Figure 2 As shown, before step 220, the method may further include:

[0135] Step 220: performing image erosion on the target product image after the binarization process to eliminate noise points in the target product image.

[0136] For example, the target product image after binarization processing can be eroded, and the erosion operation can be performed on the pixels marked as 1 to eliminate the noise in the target product image, thereby segmenting the areas in the image that are adhered and interfered with each other due to background noise.

[0137] Then, after the image erosion in step 220 is completed, connected domain detection may be performed on the target product image after the binarization process in step 230, so as to determine each connected domain contained in the target product image.

[0138] In step 130, for each connected domain included in the target product image, the connected domain area corresponding to each connected domain can be calculated, the calculated connected domain area is compared with the threshold of the connected domain area corresponding to the product, and the first re-inspection result of the product is determined based on the comparison result.

[0139] For example, assuming that four connected domains are detected in the target product image, the connected domain areas corresponding to the four connected domains can be calculated respectively, and the four connected domain areas can be compared with the threshold of the connected domain area set for the product to obtain a comparison result, and the product quality inspection result can be determined based on the comparison result.

[0140] When comparing, the connected domain area of ​​the connected domain with the largest area among the four connected domains may be determined from the connected domain area calculation result to compare with the above threshold.

[0141] In one embodiment shown, see Figure 4 , Figure 4 It is a flowchart of another image-based product quality detection method according to an embodiment of the present disclosure.

[0142] like Figure 4 As shown, in step 120, the connected domain detection is performed on the target product image to determine each connected domain included in the target product image, which may include:

[0143] Step 410, traversing each pixel contained in the target product image to determine the connection relationship between the pixels;

[0144] Step 420, determining adjacent pixels according to the connection relationship between the pixels, and dividing the adjacent pixels into the same connected domain;

[0145] In step 130, calculating the connected domain areas corresponding to the connected domains may include:

[0146] Step 430, determining the number of pixels contained in each of the connected domains;

[0147] Step 440: Calculate the connected domain areas corresponding to the connected domains based on the numbers of pixels contained in the connected domains.

[0148] For example, each pixel in the target product image can be traversed to determine whether the grayscale value of each pixel is the same as that of other pixels or meets a specific similarity criterion. If the grayscale is the same or meets a specific similarity criterion, it can be determined that there is a connection relationship between the pixels. Then, based on the connection relationship between the pixels, the adjacent pixels with a connection relationship can be determined, and the pixels and the adjacent pixels with a connection relationship can be divided into the same connected domain.

[0149] Continuing with the example, after dividing each connected domain, the number of pixels contained in each connected domain can be determined, and then based on the number of pixels contained in each connected domain, the area of ​​the connected domain corresponding to each connected domain is calculated. It can be understood that the more pixels a connected domain contains, the larger the area of ​​the connected domain.

[0150] In one embodiment shown, see Figure 5 , Figure 5 It is a flowchart of another image-based product quality detection method according to an embodiment of the present disclosure.

[0151] like Figure 5 As shown, in step 130, comparing the calculated connected domain area with the threshold value of the connected domain area corresponding to the product, and determining the first re-inspection result of the product according to the comparison result may include:

[0152] Step 510, determining the maximum value among the calculated connected domain areas, and comparing the maximum value with a threshold value of the connected domain area corresponding to the product;

[0153] Step 520, in response to the maximum value reaching a threshold of a preset connected domain area corresponding to the product, determining that the first re-inspection result of the product is qualified;

[0154] Step 530: In response to the maximum value being smaller than a threshold of a preset connected domain area corresponding to the product, determining that the first re-inspection result of the product is unqualified.

[0155] For example, for each product, a threshold of the connected domain area corresponding to the product can be determined based on the model or type of the product, and then the maximum value of the connected domain areas corresponding to the connected domains contained in the product can be compared with the threshold of the connected domain area.

[0156] If the comparison result is that the maximum value is greater than or equal to the threshold value of the connected domain area, the first re-inspection result of the product can be determined to be qualified. If the comparison result is that the maximum value is less than the threshold value of the connected domain area, the first re-inspection result of the product can be determined to be unqualified.

[0157] In one embodiment shown, the first re-inspection result includes a re-inspection result of whether any parts are missing from the product during the production process.

[0158] Taking circuit boards as an example, in the product image of qualified products, the largest connected domain should be the area where the components are located. When a component is missing from the circuit board, since there are no components in the missing area in the product image, the area of ​​the connected domain will be smaller than the area of ​​the connected domain of the same qualified product. Therefore, by setting a threshold for the area of ​​the connected domain, area-based missing component detection can be achieved to obtain the first re-inspection result of the product.

[0159] In one embodiment shown, see Figure 6 , Figure 6 The present invention is a flowchart showing a threshold value for determining the area of ​​a connected domain according to an embodiment of the present invention.

[0160] like Figure 6 As shown, the threshold of the connected domain area can be determined by the following steps:

[0161] Step 610, obtaining a plurality of product images with qualified detection results, and determining the maximum value of the connected domain area in the connected domain contained in each of the plurality of product images with qualified detection results;

[0162] Step 620, taking the maximum value corresponding to each product image as a sample in a statistical sample set;

[0163] Step 630: Perform statistical analysis on the statistical sample set to determine a threshold value of the connected domain area.

[0164] For example, in order to determine a threshold value of the connected domain area that can be used to distinguish qualified products from unqualified products, product images of qualified products can be obtained first. For each product image, the connected domain area of ​​each connected domain contained in the product image can be determined, thereby determining the maximum value of the connected domain area of ​​the connected domains contained in each product image.

[0165] Continuing with the example, for each product image, the maximum value of the connected domain area of ​​each product image can be used as a sample in a statistical sample set, and then the threshold value of the connected domain area is determined by performing statistical analysis on the statistical sample set.

[0166] In the above process, by statistically analyzing the maximum value of the connected domain area of ​​the product image of the qualified product, a threshold value of the connected domain area for dividing the product into qualified and unqualified products can be determined, thereby improving the accuracy of quality detection.

[0167] In one embodiment shown, in step 630, performing statistical analysis on the statistical sample set to determine the threshold of the connected domain area may include:

[0168] For the statistical sample set, statistical analysis is performed according to the interquartile range statistical method based on the following formula: τ = Q1-K*IQR, IQR = Q3-Q1;

[0169] Among them, τ represents the threshold of the connected domain area, Q1 represents the first quartile in the statistical sample set, Q3 represents the third quartile in the statistical sample set, IQR represents the interquartile range, K represents the weight parameter, and the value of K is 1.5 or 3.

[0170] For example, taking the interquartile range statistical method as an example, the connected domain areas in the statistical sample set can be sorted from small to large according to the numerical value, and then the sorted connected domain areas are divided into 4 parts in equal proportion, and the connected domain area located in the 1 / 4 is selected as Q1, and the connected domain area located in the 3 / 4 is selected as Q3. The difference between Q3 and Q1 is taken as the interquartile range IQR, and the threshold of the connected domain area is calculated by the above formula.

[0171] K can be selected as 1.5 or 3. The larger K is, the higher the success rate of determining whether a product is qualified or not based on the threshold value.

[0172] In addition, in addition to the interquartile range statistical method, other statistical methods can also be used, such as control chart method, local anomaly factor method, etc.

[0173] In one embodiment shown, see Figure 7 , Figure 7 It is a flowchart of another image-based product quality detection method according to an embodiment of the present disclosure.

[0174] like Figure 7 As shown, before step 120, the method further includes:

[0175] Step 710, inputting the target product image into a pre-trained classification model;

[0176] Step 720: The classification model outputs a second re-inspection result for the target product image.

[0177] For example, the above-mentioned classification model can be a machine learning model. By training based on samples of qualified product images and samples of unqualified product images, a trained classification model that can be used to predict the input product image can be obtained. The classification model can output a second re-inspection result for the target product image.

[0178] It should be noted that since the above-mentioned steps 710 and 720 are before step 120, the process of inputting the target product image into the classification model to obtain the result of the second re-inspection implemented by steps 710 and 720 can be called the first re-inspection, and the process of determining the first re-inspection result based on the comparison result of the connected domain area implemented by steps 120 and 130 can be called the second re-inspection.

[0179] Further, in one embodiment shown, step 120 may include:

[0180] Step 730, obtaining a second re-inspection result output by the classification model, and determining a product image corresponding to a product for which the second re-inspection result is qualified as a target product image;

[0181] Step 740, performing connected domain detection on the target product image;

[0182] Step 750: determine each connected domain contained in the target product image.

[0183] Then, the aforementioned step 130 may be continued to be performed. Through the aforementioned steps, two re-inspections of the product image may be implemented. The first re-inspection is based on the classification model, and the second re-inspection is based on the comparison of the connected domain area threshold.

[0184] It should be noted that when re-inspecting based on the classification model, although the detection efficiency and accuracy are relatively high, due to the "black box" characteristics of the model itself, there may be missed detections. Therefore, a second re-inspection is conducted after the first re-inspection to ensure that there will be no missed detections. Through two re-inspections, the advantages of the two methods can be combined, which not only ensures high accuracy, but also ensures that there will be no missed detections.

[0185] It is worth noting that in the actual production process, by using the above steps to test the quality of the product, the results shown in Table 1 below can be obtained;

[0186] Table 1

[0187] Evaluation Metrics Product Type 1 Product Type 2 Product Type 3 Product Type 4 Accuracy 95.8% 97.4% 91.7% 97.5% False positive rate 4.2% 2.6% 8.3% 2.5% Missed detection rate 0 0 0 0

[0188] As can be seen from Table 1, when the above method is used for product quality inspection, zero missed detection can be achieved, and the accuracy rate can reach the level of manual re-inspection. However, unlike manual re-inspection, which has the problems of low efficiency, high cost and poor consistency, this method also has high precision, high efficiency and high consistency.

[0189] In one embodiment shown, the classification model is a deep learning model that supports a variable penalty coefficient; wherein, among the samples used in training the deep learning model, the penalty coefficient corresponding to the samples whose second re-inspection results are qualified is smaller than the penalty coefficient corresponding to the samples whose second re-inspection results are unqualified.

[0190] For example, the above classification model can be a deep learning model that supports variable penalty coefficients, such as ResNet (Residual Network) deep residual network, convolutional neural network, ViT (Vision Transformer) visual self-attention model, etc.

[0191] Continuing with the example, the samples used in the training of the deep learning model may include samples with qualified results in the second re-examination and samples with unqualified results in the second re-examination. In order to enhance the model's ability to distinguish unqualified images, a larger penalty coefficient may be imposed on unqualified samples.

[0192] It can be seen from the above embodiments that by performing connected domain detection on the product images corresponding to the products with unqualified initial inspection results, the connected domain areas corresponding to the detected connected domains are calculated, and compared with the threshold of the connected domain area, the first re-inspection result of the product is obtained. In the above process, by re-inspecting the product based on the area of ​​the connected domain of the product image that failed the initial inspection, on the one hand, the efficiency of the re-inspection can be improved, the detection cost can be reduced, and the detection results have high consistency. On the other hand, because the detection logic is explainable, the accuracy of the detection can be improved, zero missed detection can be achieved, and the false alarm rate of the detection can be reduced.

[0193] Corresponding to the aforementioned embodiment of the image-based product quality detection method, the present disclosure also provides an embodiment of an image-based product quality detection device.

[0194] See also Figure 8 , Figure 8 FIG. 1 is a schematic block diagram of an image-based product quality detection device according to an embodiment of the present disclosure. Figure 8 As shown, the device may include:

[0195] The first acquisition module 801 is used to acquire the initial inspection result of the product, and determine the product image corresponding to the product with the initial inspection result being unqualified as the target product image;

[0196] A first connected domain detection module 802 is used to perform connected domain detection on the target product image to determine each connected domain contained in the target product image;

[0197] The comparison module 803 is used to calculate the connected domain areas corresponding to the respective connected domains, compare the calculated connected domain areas with the threshold of the connected domain areas corresponding to the product, and determine the first re-inspection result of the product according to the comparison result.

[0198] See also Fig. 9 , Fig. 9 is based on Figure 8 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig. 9 As shown, the device also includes:

[0199] The classification module 901 is used to input the target product image into a pre-trained classification model so that the classification model outputs a second re-inspection result for the target product image.

[0200] See also Fig.10 , Fig.10 is based on Fig. 9 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.10 As shown, the first connected domain detection module 802 may include:

[0201] The second connected domain detection module 1001 is used to determine the product image corresponding to the product with the second re-inspection result as qualified as the target product image, and perform connected domain detection on the target product image to determine each connected domain contained in the target product image.

[0202] See also Fig.11 , Fig.11 is based on Figure 8 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.12 As shown, the first connected domain detection module 802 may include:

[0203] A pixel traversal module 1101 is used to traverse each pixel contained in the target product image and determine the connection relationship between the pixels;

[0204] A division module 1102 is used to determine adjacent pixels according to the connection relationship between the pixels, and divide the adjacent pixels into the same connected domain;

[0205] The comparison module 803 may include:

[0206] A number determination module 1103 is used to determine the number of pixels contained in each connected domain;

[0207] The number calculation module 1104 is used to calculate the connected domain areas corresponding to the connected domains based on the numbers of pixels respectively included in the connected domains.

[0208] See also Fig.12 , Fig.12 is based on Figure 8 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.12 As shown, the comparison module 803 may include:

[0209] An area comparison module 1201 is used to determine the maximum value among the calculated connected domain areas, and compare the maximum value with a threshold value of the connected domain area corresponding to the product;

[0210] A first result module 1202 is used to determine that the first re-inspection result of the product is qualified in response to the maximum value reaching a threshold value of a preset connected domain area corresponding to the product;

[0211] The second result module 1203 is used to determine that the first re-inspection result of the product is unqualified in response to the maximum value being smaller than a threshold value of a preset connected domain area corresponding to the product.

[0212] See also Fig.13 , Fig.13 is based on Figure 8 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.13 As shown, the device also includes:

[0213] The second acquisition module 1301 is used to acquire a plurality of product images with qualified initial inspection results, and respectively determine the maximum value of the connected domain area in the connected domain contained in each of the plurality of product images with qualified initial inspection results;

[0214] A sample module 1302 is used to take the maximum value corresponding to each product image as a sample in a statistical sample set;

[0215] The analysis module 1303 is used to perform statistical analysis on the statistical sample set to determine the threshold value of the connected domain area.

[0216] See also Fig.14 , Fig.14 is based on Figure 8 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.14 As shown, the device also includes:

[0217] The initial inspection module 1401 is used to perform a preliminary inspection on the product image of the product collected by the optical inspection equipment on the product production line to determine the initial inspection result.

[0218] See also Fig.15 , Fig.15 is based on Figure 8 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.15 As shown, the first connected domain detection module 802 may include:

[0219] The binarization processing module 1501 is used to perform binarization processing on the target product image and perform connected domain detection on the target product image after the binarization processing.

[0220] See also Fig.16 , Fig.16 is based on Fig.15 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.16 As shown, the binarization processing module 1501 may include:

[0221] A grayscale determination module 1601 is used to determine the grayscale of each pixel included in the target product image;

[0222] The grayscale binarization processing module 1602 is used to perform binarization processing on the grayscale of each pixel included in the target product image according to a preset grayscale threshold.

[0223] See also Fig.17 , Fig.17 is based on Fig.15 A schematic block diagram of another image-based product quality detection device is shown based on the embodiment shown in FIG. Fig.17 As shown, the device also includes:

[0224] The image erosion module 1701 is used to perform image erosion on the target product image after the binarization process to eliminate noise points in the target product image.

[0225] Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment of the relevant method, and will not be elaborated here.

[0226] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0227] Accordingly, the present disclosure also provides an electronic device, including:

[0228] processor;

[0229] a memory for storing processor-executable instructions;

[0230] Wherein, the processor is used to implement the above-mentioned image-based product quality detection method.

[0231] Accordingly, the present disclosure also provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned image-based product quality detection method is implemented.

[0232] like Fig.18 As shown, Fig.18 1 is a schematic block diagram of an apparatus 1800 for image-based product quality detection according to an embodiment of the present disclosure. For example, the apparatus 1800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0233] Reference Fig.18 , device 1800 may include one or more of the following components: a processing component 1802 , a memory 1804 , a power component 1806 , a multimedia component 1808 , an audio component 1810 , an input / output (I / O) interface 1812 , a sensor component 1814 , and a communication component 1816 .

[0234] The processing component 1802 generally controls the overall operation of the device 1800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1802 may include one or more processors 1820 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 1802 may include one or more modules to facilitate interaction between the processing component 1802 and other components. For example, the processing component 1802 may include a multimedia module to facilitate interaction between the multimedia component 1808 and the processing component 1802.

[0235] The memory 1804 is configured to store various types of data to support the operation of the device 1800. Examples of such data include instructions for any application or method operating on the device 1800, contact data, phone book data, messages, pictures, videos, etc. The memory 1804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0236] The power supply component 1806 provides power to the various components of the device 1800. The power supply component 1806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device 1800.

[0237] The multimedia component 1808 includes a screen that provides an output interface between the device 1800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1808 includes a front camera and / or a rear camera. When the device 1800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0238] The audio component 1810 is configured to output and / or input audio signals. For example, the audio component 1810 includes a microphone (MIC), and when the device 1800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1804 or sent via the communication component 1816. In some embodiments, the audio component 1810 also includes a speaker for outputting audio signals.

[0239] I / O interface 1812 provides an interface between processing component 1802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0240] The sensor assembly 1814 includes one or more sensors for providing various aspects of the status assessment of the device 1800. For example, the sensor assembly 1814 can detect the open / closed state of the device 1800, the relative positioning of components, such as the display and keypad of the device 1800, the sensor assembly 1814 can also detect the position change of the device 1800 or a component of the device 1800, the presence or absence of user contact with the device 1800, the orientation or acceleration / deceleration of the device 1800, and the temperature change of the device 1800. The sensor assembly 1814 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1814 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1814 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0241] The communication component 1816 is configured to facilitate wired or wireless communication between the device 1800 and other devices. The device 1800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G LTE, 5G NR, or a combination thereof. In an exemplary embodiment, the communication component 1816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0242] In an exemplary embodiment, the device 1800 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the methods described in any of the above embodiments.

[0243] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1804 including instructions, and the instructions can be executed by a processor 1820 of the device 1800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0244] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0245] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

[0246] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprises a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0247] The method and device provided in the embodiments of the present disclosure are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method of the present disclosure and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present disclosure, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present disclosure.

Claims

1. A product quality detection method based on image, characterized in that: The method comprises: Obtaining the initial inspection result of the product, and determining the product image corresponding to the product with the initial inspection result being unqualified as the target product image; Performing connected domain detection on the target product image to determine each connected domain contained in the target product image; The connected domain areas corresponding to the connected domains are calculated, the calculated connected domain areas are compared with a threshold of the connected domain area corresponding to the product, and a first re-inspection result of the product is determined according to the comparison result.

2. The method according to claim 1, characterized in that Before performing connected domain detection on the product image, the method further includes: The target product image is input into a pre-trained classification model, so that the classification model outputs a second re-inspection result for the target product image.

3. The method according to claim 2, characterized in that The performing connected domain detection on the target product image to determine each connected domain contained in the target product image includes: The product image corresponding to the product with the qualified result of the second re-inspection is determined as the target product image, and a connected domain detection is performed on the target product image to determine each connected domain included in the target product image.

4. The method according to claim 2, characterized in that: The classification model is a deep learning model that supports a variable penalty coefficient; wherein, among the samples used in training the deep learning model, the penalty coefficient corresponding to the samples whose second re-inspection results are qualified is smaller than the penalty coefficient corresponding to the samples whose second re-inspection results are unqualified.

5. The method according to claim 1, characterized in that The performing connected domain detection on the target product image to determine each connected domain contained in the target product image includes: traversing each pixel contained in the target product image to determine the connection relationship between the pixels; Determine adjacent pixels according to the connection relationship between the pixels, and divide the adjacent pixels into the same connected domain; The calculating the connected domain areas corresponding to the connected domains respectively includes: Determine the number of pixels contained in each of the connected domains; Based on the number of pixels respectively included in each of the connected domains, the connected domain areas respectively corresponding to the each of the connected domains are calculated.

6. The method according to claim 1, characterized in that The step of comparing the calculated connected domain area with a threshold value of a connected domain area corresponding to the product, and determining a first re-inspection result of the product according to the comparison result, includes: Determine a maximum value among the calculated connected domain areas, and compare the maximum value with a threshold value of the connected domain area corresponding to the product; In response to the maximum value reaching a threshold value of a preset connected domain area corresponding to the product, determining that the first re-inspection result of the product is qualified; In response to the maximum value being smaller than a threshold of a preset connected domain area corresponding to the product, it is determined that the first re-inspection result of the product is unqualified.

7. The method according to claim 6, characterized in that The first re-inspection result includes a re-inspection result of whether any parts are missing from the product during the production process.

8. The method according to claim 1, characterized in that The threshold of the connected domain area is determined by the following methods, including: Acquire a plurality of product images with qualified initial inspection results, and respectively determine the maximum value of the connected domain area in the connected domain contained in each of the plurality of product images with qualified initial inspection results; Taking the maximum value corresponding to each product image as a sample in a statistical sample set; Statistical analysis is performed on the statistical sample set to determine a threshold value of the connected domain area.

9. The method according to claim 8, characterized in that The performing statistical analysis on the statistical sample set to determine the threshold of the connected domain area includes: For the statistical sample set, statistical analysis is performed according to the interquartile range statistical method based on the following formula: τ = Q1-K*IQR, IQR = Q3-Q1; Among them, τ represents the threshold of the connected domain area, Q1 represents the first quartile in the statistical sample set, Q3 represents the third quartile in the statistical sample set, IQR represents the interquartile range, K represents the weight parameter, and the value of K is 1.5 or 3.

10. The method according to claim 1, characterized in that Before obtaining the initial inspection result of the product, the method further includes: A preliminary inspection is performed on the product image of the product collected by the optical inspection equipment on the product production line to determine the preliminary inspection result.

11. The method according to claim 10, characterized in that The product includes a circuit board, and the target product image includes an image of a circuit board that is found unqualified in an initial inspection result.

12. The method according to claim 1, characterized in that The performing connected domain detection on the target product image includes: The target product image is binarized, and connected domain detection is performed on the binarized target product image.

13. The method according to claim 12, characterized in that The binarization process of the target product image includes: Determine the grayscale of each pixel contained in the target product image; According to a preset grayscale threshold, the grayscale of each pixel included in the target product image is binarized.

14. The method according to claim 13, characterized in that The preset grayscale threshold includes a grayscale threshold pre-specified by an inspector, or a grayscale threshold determined according to a numerical range corresponding to the grayscale of each pixel contained in the target product image.

15. The method according to claim 12, characterized in that Before performing connected domain detection on the binarized product image, the method further includes: Image erosion is performed on the target product image after the binarization process to eliminate noise points in the target product image.

16. A product quality detection device based on an image, characterized in that: The device comprises: The first acquisition module is used to obtain the initial inspection result of the product, and determine the product image corresponding to the product with the initial inspection result being unqualified as the target product image; A first connected domain detection module, configured to perform connected domain detection on the target product image to determine each connected domain contained in the target product image; The comparison module is used to calculate the connected domain areas corresponding to the connected domains respectively, compare the calculated connected domain areas with the threshold of the connected domain areas corresponding to the product, and determine the first re-inspection result of the product according to the comparison result.

17. The device according to claim 16, characterized in that The device also includes: The classification module is used to input the target product image into a pre-trained classification model so that the classification model outputs a second re-inspection result for the target product image.

18. The device according to claim 17, characterized in that The first connected domain detection module includes: The second connected domain detection module is used to determine the product image corresponding to the product with the second re-inspection result as qualified as the target product image, and perform connected domain detection on the target product image to determine each connected domain contained in the target product image.

19. The device according to claim 16, characterized in that The first connected domain detection module includes: A pixel traversal module, used to traverse each pixel contained in the target product image and determine the connection relationship between the pixels; A division module, used for determining adjacent pixels according to the connection relationship between the pixels, and dividing the adjacent pixels into the same connected domain; The comparison module comprises: A number determination module, used to determine the number of pixels contained in each of the connected domains; The number calculation module is used to calculate the connected domain areas corresponding to each of the connected domains based on the number of pixels respectively included in each of the connected domains.

20. The device according to claim 16, characterized in that The comparison module comprises: An area comparison module, used to determine the maximum value among the calculated connected domain areas, and compare the maximum value with a threshold value of the connected domain area corresponding to the product; A first result module, configured to determine that a first re-inspection result of the product is qualified in response to the maximum value reaching a threshold value of a preset connected domain area corresponding to the product; The second result module is used to determine that the first re-inspection result of the product is unqualified in response to the maximum value being smaller than a threshold value of a preset connected domain area corresponding to the product.

21. The device according to claim 16, characterized in that The device also includes: A second acquisition module is used to acquire a plurality of product images with qualified initial inspection results, and respectively determine the maximum value of the connected domain area in the connected domain contained in each of the plurality of product images with qualified initial inspection results; A sample module, used to take the maximum value corresponding to each product image as a sample in a statistical sample set; The analysis module is used to perform statistical analysis on the statistical sample set to determine the threshold value of the connected domain area.

22. The device according to claim 16, characterized in that The device also includes: The initial inspection module is used to perform preliminary inspection on the product images of the product collected by the optical inspection equipment on the product production line to determine the initial inspection results.

23. The device according to claim 16, characterized in that The first connected domain detection module includes: The binarization processing module is used to perform binarization processing on the target product image and perform connected domain detection on the target product image after the binarization processing.

24. The device according to claim 23, characterized in that The binarization processing module comprises: A grayscale determination module, used to determine the grayscale of each pixel contained in the target product image; The grayscale binarization processing module is used to perform binarization processing on the grayscale of each pixel contained in the target product image according to a preset grayscale threshold.

25. The device according to claim 23, characterized in that The device also includes: The image erosion module is used to perform image erosion on the target product image after the binarization process to eliminate noise points in the target product image.

26. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is used to implement the method according to any one of claims 1 to 15.

27. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 15 is implemented.