Industrial quality inspection method, system and equipment based on machine vision and medium
By introducing an image segmentation model to perform refined analysis of the defect boxes output by the quality inspection model, and combining the proportion of the defect target contour area with the image structure similarity assessment of background regions in multiple locations, the problem of numerous false alarm boxes in existing technologies is solved, and efficient and accurate defect identification is achieved.
Patent Information
- Application Number
- CN202511557110.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-01-13
AI Technical Summary
Existing machine vision-based industrial quality inspection methods tend to generate a large number of false alarm boxes in complex industrial scenarios, resulting in low efficiency and the need for manual re-inspection. Existing methods cannot effectively distinguish between real defects and false alarms.
A pre-trained quality inspection model is used to predict defects. An image segmentation model is used to segment local images. The image structure similarity between the proportion of the defect target contour area and the background area in multiple locations is used to determine whether the defect indicator box corresponds to the real defect.
It effectively reduces manual re-inspection steps, improves the automation level and economic efficiency of the quality inspection process, and enhances the accuracy and efficiency of defect identification.
Smart Images

Figure CN121329950A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision, and more specifically to an industrial quality inspection method, system, equipment, and medium based on machine vision. Background Technology
[0002] Machine vision-based industrial quality inspection technology refers to an intelligent method that acquires product surface images through optical imaging systems and automatically detects defects using computer algorithms. In high-end manufacturing, this technology has become a core means of replacing manual visual inspection, especially in fields such as precision electronics, automotive parts, and semiconductor packaging. The accurate identification of defects such as micron-level scratches, foreign object residue, and assembly misalignment directly affects product yield and production safety. Traditional manual quality inspection suffers from inherent bottlenecks such as low efficiency, high subjectivity, and susceptibility to fatigue. In contrast, machine vision systems, through the combination of high-resolution industrial cameras and AI algorithms, can achieve millisecond-level single-piece inspection speeds, micron-level defect resolution accuracy, and continuous, undiminished operation 24 hours a day.
[0003] Existing methods primarily rely on end-to-end deep learning detection models, directly outputting defect prediction boxes by inferring from the entire industrial product image. However, to ensure a high defect detection rate, these models often need to lower the classification threshold, leading to a large number of false alarm boxes in complex industrial scenarios, misclassifying normal textures, optical reflections, dust adhesion, and other non-defect features as defects. Existing methods require manual review of all defect prediction boxes output by the model, resulting in high efficiency and cost. Summary of the Invention
[0004] To address the aforementioned problems, this invention provides an industrial quality inspection method, system, equipment, and medium based on machine vision.
[0005] The first aspect of this invention discloses an industrial quality inspection method based on machine vision, comprising: Pre-trained quality inspection models are used to predict defects in images of industrial products, resulting in defect indicator boxes. Based on the defect indicator box, the image is cropped to obtain a partial image; Based on the local image and the defect indicator box, the local image is segmented using an image segmentation model to obtain the defect target outline and its inscribed rectangle; Based on the inscribed rectangle, multiple comparison rectangles are extracted from the local image; wherein the size of the comparison rectangles is the same as that of the inscribed rectangle. Based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles, it is determined whether the defect indicator box corresponds to a real defect.
[0006] Furthermore, the step of cropping the image based on the defect indicator box to obtain a local image includes: The boundary of the defect indicator box is extended outward by a preset number of pixels, and the extended boundary is used as the cropping range to extract the local image from the image.
[0007] Furthermore, the plurality of contrast rectangles include: a contrast rectangle located at a vertex of the local image, and / or a contrast rectangle whose side coincides with one side of the local image.
[0008] Furthermore, the step of determining whether the defect indicator box corresponds to a real defect based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles, includes: Calculate the area ratio between the image corresponding to the defect target contour and the local image, determine whether the calculation result exceeds a preset ratio threshold, and obtain a first judgment result; After calculating the similarity between the inscribed rectangle and each comparison rectangle, the average similarity is obtained by taking the mean value. Determine whether the average similarity is less than a preset similarity threshold to obtain a second determination result; Determine whether both the first judgment result and the second judgment result are yes: If so, then the defect indicator box is determined to correspond to a real defect; Otherwise, the image corresponding to the defect indicator box is determined to be not a real defect.
[0009] Furthermore, the step of calculating the similarity between the inscribed rectangle and each comparison rectangle includes: The inscribed rectangle is calculated using the following formula. With each contrasting rectangle similarity : ; in, This represents the function for calculating the image mean. This represents the function for calculating the standard deviation of an image. The function represents the covariance calculation between two images. This is a preset brightness stability constant. This is the preset contrast stability constant.
[0010] Furthermore, the image mean calculation function for: ; And, image standard deviation calculation function for: ; in, , , These represent the inscribed rectangles of the input. Height, width, and number of channels, Represents the inscribed rectangle At an altitude of Width is The channel is The pixel value at that time.
[0011] Furthermore, the covariance calculation function for: ; in, , , These represent the inscribed rectangles of the input. Height, width, and number of channels, Represents the inscribed rectangle At an altitude of Width is The channel is The pixel value at that time, Represents the contrast rectangle At an altitude of Width is The channel is The pixel value at that time.
[0012] A second aspect of this invention discloses an industrial quality inspection system based on machine vision, comprising: The prediction module is used to predict defects in images of industrial products using a pre-trained quality inspection model, and to obtain defect indicator boxes. The first cropping module is used to crop the image based on the defect indicator box to obtain a partial image; The segmentation module is used to segment the local image based on the local image and the defect indicator box using an image segmentation model to obtain the defect target outline and its inscribed rectangle; The second cropping module is used to crop multiple comparison rectangles in the local image based on the inscribed rectangle; wherein the size of the comparison rectangle is the same as that of the inscribed rectangle; The judgment module is used to determine whether the defect indicator box corresponds to a real defect based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles.
[0013] A third aspect of the present invention discloses an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the steps of any of the machine vision-based industrial quality inspection methods disclosed in the first aspect of the present invention.
[0014] The fourth aspect of the present invention discloses a storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, it implements the steps of any of the machine vision-based industrial quality inspection methods disclosed in the first aspect of the present invention.
[0015] This invention introduces an image segmentation model to perform refined analysis of the defect boxes output by the quality inspection model. By combining the proportion of the defect target contour area with the image structure similarity assessment of background regions in multiple locations, it effectively distinguishes between real defects and false alarm boxes, thereby reducing the manual re-inspection process and improving the automation and economic efficiency of the quality inspection process. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic flowchart of an industrial quality inspection method based on machine vision disclosed in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of an industrial quality inspection system based on machine vision disclosed in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of the electronic device disclosed in the embodiments of the present invention. Detailed Implementation
[0018] To enable those skilled in the art to better understand the present invention, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, or product comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, apparatus, or products.
[0020] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0021] Please see Figure 1 As shown, Figure 1 This is a flowchart illustrating an industrial quality inspection method based on machine vision disclosed in an embodiment of the present invention. Figure 1 As shown, this machine vision-based industrial quality inspection method may include the following operations: S101. Use a pre-trained quality inspection model to predict defects in images of industrial products and obtain defect indicator boxes. In this optional embodiment, the quality control model can be a pre-trained single-stage anchor-free detection model (YOLO, You Only Look Once), a pre-trained two-stage region proposal detection model (Faster R-CNN, Region-based Convolutional Neural Network), or a pre-trained detection model based on a self-attention mechanism (DETR, Detection Transformer). This embodiment of the invention is not limited to any particular model.
[0022] A defect indicator box (DIC) is a rectangular boundary marker generated by a quality inspection model during an automated quality inspection process. It is used to locate suspected defective areas in product images. The DIC is output after the quality inspection model performs pixel-level analysis on the input image. Its geometric representation uses a quadruple coordinate format, representing the positions of the top-left and bottom-right corners of the rectangle in the image coordinate system. For example, in the quality inspection of mobile phone screens, when the model detects a micron-level scratch on the glass surface, it generates a minimum bounding rectangle enclosing the scratch as the DIC. The pixel area within the rectangle is the defect target to be verified. Essentially, the DIC is a probabilistic prediction of the defect location by the quality inspection model. Due to environmental interference and inherent model errors in industrial settings, some DICs may actually correspond to normal areas.
[0023] S102. Based on the defect indicator box, the image is cropped to obtain a partial image; In an optional embodiment, the step of cropping the image based on the defect indicator box to obtain a partial image includes: The boundary of the defect indicator box is extended outward by a preset number of pixels, and the extended boundary is used as the cropping range to extract the local image from the image.
[0024] In industrial settings, real defects such as scratches and bubbles exhibit edge diffusion effects: the boundary between the defect area and the normal area has a pixel-level gradual transition. Directly cropping according to the original defect bounding box may lead to feature truncation: for example, the end of a crack may be cut off; segmentation distortion: image segmentation models need complete edge information to generate accurate contours; similarity misjudgment: the background contrast area needs to include the normal texture reference around the defect.
[0025] Different preset pixels can be set for different industrial products. For example, the defects in the electronics industry may be at the micrometer level, so the preset pixels can be set to 5-10 pixels; the defects in the metal casting industry may be at the millimeter level with pores, so the preset pixels can be set to 10-15 pixels.
[0026] As can be seen, this optional embodiment effectively ensures that the local image contains contextual information around the defect target, reducing the probability of missing background information due to the edge of the detection box being close to the defect contour, thereby providing more sufficient regional support for subsequent image segmentation and similarity comparison, and improving the stability and accuracy of the judgment.
[0027] S103. Based on the local image and the defect indicator box, the local image is segmented using an image segmentation model to obtain the defect target outline and its inscribed rectangle; In this optional embodiment, the image segmentation model can use a general segmentation model (Segment Anything Model, SAM), a mask region-based convolutional neural network (Mask R-CNN), DeepLabv3+, etc., and the embodiments of the present invention are not limited thereto. SAM achieves accurate contour extraction of any industrial target through prompt-driven zero-sample transfer capability, and its ViT-H-based encoder can generalize to handle unknown defect types; Mask R-CNN uses a two-stage framework to generate defect detection boxes and pixel-level masks in parallel, maintaining a high recall rate in the segmentation of oil stains on automotive parts; DeepLabv3+ uses dilated convolution and spatial pyramid pooling to capture multi-scale features, and combines the encoding and decoding structure to improve the edge segmentation accuracy of micro-cracks in electronic components.
[0028] The local image and the defect indicator box are input into an image segmentation model, whereby the defect indicator box serves as a prompt for the image segmentation model. The image segmentation model then segments the local image to obtain a corresponding segmentation mask. Subsequently, the contour information of the defect target is extracted from the segmentation mask using an image processing library. Based on this contour information, its minimum bounding rectangle is calculated. Image processing libraries such as OpenCV are not limited in this embodiment of the invention.
[0029] S104. Based on the inscribed rectangle, extract multiple comparison rectangles from the local image; wherein the size of the comparison rectangles is the same as that of the inscribed rectangle; In an optional embodiment, the plurality of contrast rectangles includes: a contrast rectangle located at a vertex of the local image, and / or a contrast rectangle whose side coincides with one side of the local image.
[0030] For example: Let the coordinates of the top-left corner of the local image be (0,0), the width of the local image be w1, and the height be h1. Let the coordinates of the top-left corner of the inscribed rectangle be (a,b), the width be w2, and the height be h2. Then all comparison rectangles have a width of w and a height of h. The coordinates of the top-left corner of the comparison rectangle located at a vertex of the local image can be: (0,0), (w1-w2,0), (0,h1-h2), (w1-w2,h1-h2). The coordinates of the top-left corner of a comparison rectangle whose edge coincides with an edge of the local image can be: (a,0), (0,b), (a, h1-h2), (w1-w2,b).
[0031] As can be seen, this optional embodiment can systematically select the background area as the comparison benchmark by generating multiple comparison rectangles located at the vertices or edges of the local image based on the inscribed rectangle. It can enhance the distinction between real and fake defects by utilizing the consistency features of the background and the differences between potential defect areas, avoid random errors caused by comparison at a single location, and improve the robustness of the evaluation results.
[0032] S105. Based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles, determine whether the defect indicator box corresponds to a real defect.
[0033] In an optional embodiment, the step of determining whether the defect indicator box corresponds to a real defect based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles, includes: Calculate the area ratio between the image corresponding to the defect target contour and the local image, determine whether the calculation result exceeds a preset ratio threshold, and obtain a first judgment result; After calculating the similarity between the inscribed rectangle and each comparison rectangle, the average similarity is obtained by taking the mean value. Determine whether the average similarity is less than a preset similarity threshold to obtain a second determination result; Determine whether both the first judgment result and the second judgment result are yes: If so, then the defect indicator box is determined to correspond to a real defect; Otherwise, the image corresponding to the defect indicator box is determined to be not a real defect.
[0034] This optional embodiment utilizes the physical property that real defects inevitably occupy a significant spatial area, filtering out small non-defect targets by the ratio of the defect outline area to the original predicted bounding box; it also utilizes the fact that real defects inevitably disrupt material continuity, while false alarm boxes, lacking physical deformation, are highly similar to the background, identifying misjudged normal textures by comparing the structural similarity between the defect area and the edge background. The dual-threshold joint determination forms a cross-validation of the defect's spatial occupancy and texture disruption.
[0035] In this optional embodiment, the area of the image corresponding to the defect target contour is the number of pixels within the defect target contour. The proportion threshold can be set based on the minimum effective area proportion of the target defect. By statistically analyzing the area distribution of over-inspection targets such as dust and reflections in multiple good product samples, a preset proportion quantile plus a safety margin is taken as the filter line. The similarity threshold is determined based on the material texture damage characteristics. By comparing the similarity distribution of multiple sets of real defects and the background, the median of the intersection interval of the two distributions is taken as the similarity threshold. In this embodiment of the invention, both the proportion threshold and the similarity threshold are set to 0.8.
[0036] As can be seen, this optional embodiment, by integrating the dual judgment mechanism of area proportion and structural similarity, combines the proportion threshold to screen significant areas and excludes false alarm areas that are highly consistent with the background based on the average similarity. It can significantly reduce over-detection while ensuring high recall. The overall evaluation process is logically rigorous and the indicators are quantifiable, thereby improving the reliability and efficiency of defect judgment.
[0037] In an optional embodiment, the step of calculating the similarity between the inscribed rectangle and each comparison rectangle includes: The inscribed rectangle is calculated using the following formula. With each contrasting rectangle similarity : ; in, This represents the function for calculating the image mean. This represents the function for calculating the standard deviation of an image. The function represents the covariance calculation between two images. This is a preset brightness stability constant. This is the preset contrast stability constant.
[0038] In this optional embodiment, and The values are set to (0.01×255)² and (0.03×255)² respectively. These two constants are introduced to improve the similarity... A stability constant is introduced into the calculation to avoid mathematical instability where the denominator is zero in uniform regions of the image. Furthermore, considering that the typical range of image pixel values is 0 to 255, this setting ensures that the constant adapts to the dynamic range of the image data, guaranteeing similarity. It exhibits robustness and comparability in various image comparisons.
[0039] As can be seen, this optional embodiment introduces a brightness stabilizing constant. and contrast stability constant This effectively reduces the computational instability caused by the denominator approaching zero in uniform image regions. At the same time, normalization ensures that the similarity measurement results always fall within a reasonable range of [0,1], enhancing the algorithm's robustness to changes in illumination and contrast. It is more in line with the human visual system's perception of image quality, significantly improving the accuracy and reliability of image quality assessment, and is especially suitable for the refined discrimination of the similarity between defective areas and the background in industrial quality inspection.
[0040] In an optional embodiment, the image mean calculation function for: ; And, image standard deviation calculation function for: ; in, , , These represent the inscribed rectangles of the input. Height, width, and number of channels, Represents the inscribed rectangle At an altitude of Width is The channel is The pixel value at that time.
[0041] As can be seen, this optional embodiment defines standardized image mean and standard deviation calculation functions, ensuring that the extraction process of brightness and contrast features is mathematically consistent and comparable regardless of the size or number of channels of the input image region. This provides a stable and unified statistical basis for subsequent structural similarity calculation, ensures the effective generalization of evaluation indicators in different practical scenarios, provides stable and reliable input for structural similarity calculation, and thus ensures the generalization ability of evaluation indicators in practical applications.
[0042] In an optional embodiment, the covariance calculation function for: ; in, , , These represent the inscribed rectangles of the input. Height, width, and number of channels, Represents the inscribed rectangle At an altitude of Width is The channel is The pixel value at that time, Represents the contrast rectangle At an altitude of Width is The channel is The pixel value at that time.
[0043] As can be seen, this optional embodiment accurately quantifies the structural correlation between two image regions through a covariance calculation function. This function can effectively capture the cooperative change trend between pixel values. Combined with preset brightness and contrast stability constants, the final similarity measurement is insensitive to imaging conditions such as illumination changes and noise interference. This enhances the model's ability to distinguish between real defects and background interference, and further significantly improves the robustness and accuracy of the model in distinguishing between real defects and background pseudo-features in complex industrial environments.
[0044] Please see Figure 2 As shown, Figure 2 This is a schematic diagram of the structure of an industrial quality inspection system based on machine vision disclosed in an embodiment of the present invention, including: The prediction module 201 is used to predict defects in images of industrial products using a pre-trained quality inspection model to obtain defect indicator boxes. The first cropping module 202 is used to crop the image based on the defect indicator box to obtain a partial image; The segmentation module 203 is used to segment the local image based on the local image and the defect indicator box using an image segmentation model to obtain the defect target outline and its inscribed rectangle; The second cropping module 204 is used to crop multiple comparison rectangles in the local image based on the inscribed rectangle; wherein the size of the comparison rectangle is the same as that of the inscribed rectangle; The judgment module 205 is used to determine whether the defect indicator box corresponds to a real defect based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles. Specific limitations regarding machine vision-based industrial quality inspection systems can be found in the above section on limitations of machine vision-based industrial quality inspection methods, and will not be repeated here. The modules in the aforementioned machine vision-based industrial quality inspection system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in an electronic device, or stored in the memory of the electronic device in software format, so that the processor can call the corresponding operations of each module.
[0045] It should be noted that, in order to highlight the innovative aspects of this invention, this embodiment does not include modules that are not closely related to solving the technical problems proposed by this invention, but this does not mean that there are no other modules in this embodiment.
[0046] like Figure 3 As shown, the electronic device 1 provided by the present invention may include a memory 12, a processor 13 and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13, such as a machine vision-based industrial quality inspection program.
[0047] The memory 12 includes at least one type of readable storage medium, such as flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 1, such as a portable hard drive. In other embodiments, the memory 12 can be an external storage device of the electronic device 1, such as a plug-in portable hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 1. Furthermore, the memory 12 can include both internal and external storage units of the electronic device 1. The memory 12 can be used not only to store application software and various types of data installed on the electronic device 1, such as machine vision-based industrial quality inspection codes, but also to temporarily store data that has been output or will be output.
[0048] In some embodiments, the processor 13 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits packaged with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 13 is the control unit of the electronic device 1, connecting various components of the electronic device 1 via various interfaces and lines. It executes programs or modules stored in the memory 12 (e.g., machine vision-based industrial quality inspection programs) and calls data stored in the memory 12 to perform various functions and process data in the electronic device 1.
[0049] The processor 13 executes the operating system of the electronic device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the machine vision-based industrial quality inspection method described above.
[0050] For example, the computer program may be divided into one or more modules, which are stored in the memory 12 and executed by the processor 13 to complete this application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into a prediction module 201, a first interception module 202, a segmentation module 203, a second interception module 204, and a judgment module 205.
[0051] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium, which can be non-volatile or volatile. The software functional module stored in the storage medium includes several instructions to cause a computer device (which may be a personal computer, computer equipment, or network device, etc.) or processor to execute some functions of the machine vision-based industrial quality inspection method described in the various embodiments of this application.
[0052] In summary, the machine vision-based industrial quality inspection method, system, equipment, and medium disclosed in this invention refines the defect bounding boxes output by the quality inspection model by introducing an image segmentation model. Combined with the image structure similarity assessment of the defect target contour area ratio and multiple background regions, it effectively distinguishes between real defects and false alarm boxes, thereby reducing manual re-inspection and improving the automation and economic efficiency of the quality inspection process. Therefore, this invention effectively overcomes the various shortcomings of existing technologies and has high industrial application value.
[0053] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.
Claims
1. A machine vision-based industrial quality inspection method, characterized in that, The method includes: Pre-trained quality inspection models are used to predict defects in images of industrial products, resulting in defect indicator boxes. Based on the defect indicator box, the image is cropped to obtain a partial image; Based on the local image and the defect indicator box, the local image is segmented using an image segmentation model to obtain the defect target outline and its inscribed rectangle; Based on the inscribed rectangle, multiple comparison rectangles are extracted from the local image; wherein the size of the comparison rectangles is the same as that of the inscribed rectangle. Based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles, it is determined whether the defect indicator box corresponds to a real defect.
2. The machine vision-based industrial quality inspection method of claim 1, wherein, The steps of cropping the image based on the defect indicator box to obtain a local image include: The boundary of the defect indicator box is extended outward by a preset number of pixels, and the extended boundary is used as the cropping range to extract the local image from the image. 3.The machine vision-based industrial quality inspection method of claim 1, wherein, The plurality of contrast rectangles includes: a contrast rectangle located at a vertex of the local image, and / or a contrast rectangle whose side coincides with one side of the local image.
4. The industrial quality inspection method based on machine vision according to claim 1, characterized in that, The steps for determining whether the defect indicator box corresponds to a real defect based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles, include: Calculate the area ratio between the image corresponding to the defect target contour and the local image, determine whether the calculation result exceeds a preset ratio threshold, and obtain a first judgment result; After calculating the similarity between the inscribed rectangle and each comparison rectangle, the average similarity is obtained by taking the mean value. Determine whether the average similarity is less than a preset similarity threshold to obtain a second determination result; Determine whether both the first judgment result and the second judgment result are yes: If so, then the defect indicator box is determined to correspond to a real defect; Otherwise, the image corresponding to the defect indicator box is determined to be not a real defect.
5. The industrial quality inspection method based on machine vision according to claim 4, characterized in that, The steps for calculating the similarity between the inscribed rectangle and each comparison rectangle include: The inscribed rectangle is calculated using the following formula. With each contrasting rectangle similarity : ; in, This represents the function for calculating the image mean. This represents the function for calculating the standard deviation of an image. The function represents the covariance calculation between two images. This is a preset brightness stability constant. This is the preset contrast stability constant.
6. The industrial quality inspection method based on machine vision according to claim 5, characterized in that, The image mean calculation function for: ; And, image standard deviation calculation function for: ; in, , , These represent the inscribed rectangles of the input. Height, width, and number of channels, Represents the inscribed rectangle At an altitude of Width is The channel is The pixel value at that time.
7. The industrial quality inspection method based on machine vision according to claim 5, characterized in that, The covariance calculation function for: ; in, , , These represent the inscribed rectangles of the input. Height, width, and number of channels, Represents the inscribed rectangle At an altitude of Width is The channel is The pixel value at that time, Represents the contrast rectangle At an altitude of Width is The channel is The pixel value at that time.
8. An industrial quality inspection system based on machine vision, characterized in that, include: The prediction module is used to predict defects in images of industrial products using a pre-trained quality inspection model, and to obtain defect indicator boxes. The first cropping module is used to crop the image based on the defect indicator box to obtain a partial image; The segmentation module is used to segment the local image based on the local image and the defect indicator box using an image segmentation model to obtain the defect target outline and its inscribed rectangle; The second cropping module is used to crop multiple comparison rectangles in the local image based on the inscribed rectangle; wherein the size of the comparison rectangle is the same as that of the inscribed rectangle; The judgment module is used to determine whether the defect indicator box corresponds to a real defect based on the area ratio of the image corresponding to the defect target contour to the local image, and the similarity between the inscribed rectangle and all comparison rectangles.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the machine vision-based industrial quality inspection method as described in any one of claims 1 to 7.
10. A storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the machine vision-based industrial quality inspection method as described in any one of claims 1 to 7.