Injection mold defect detection method and system based on machine vision
By constructing a feature vector containing a structured anomaly index and combining it with Hough transform analysis in injection mold defect detection, the problem of high false alarm rate in injection mold detection is solved, and high-precision defect identification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DONGGUAN HUIJING PLASTIC PROD CO LTD
- Filing Date
- 2025-11-19
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies for injection mold defect detection lack global context information, making it difficult to effectively distinguish between isolated defects and structured normal textures, resulting in a high false alarm rate and reducing the reliability of the detection system.
By acquiring images of the injection mold surface, defect candidate regions are segmented and located. Feature vectors containing geometric shape, grayscale texture, and structured anomaly index are constructed. The structure of the heat map is analyzed using Hough transform, and a classifier is used to identify defects.
It significantly reduces the false alarm rate, improves the accuracy and reliability of injection mold defect detection, and can effectively identify isolated anomalies and repetitive regular textures.
Smart Images

Figure CN121921244A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of industrial automation and machine vision technology. More specifically, this invention relates to a machine vision-based method and system for detecting defects in injection molds. Background Technology
[0002] As a key component in precision manufacturing, the surface quality of injection molds directly affects the yield rate and appearance quality of the final product. During the production process, defects such as scratches, pits, and rust can occur on the mold surface due to various reasons. To ensure production quality, automated defect detection technology has emerged.
[0003] Currently, due to the scarcity of defect samples, end-to-end networks are difficult to train. Therefore, a two-stage strategy of "high recall and high accuracy" is adopted. Specifically, the first step is to quickly locate potential abnormal regions, i.e. defect candidate regions, through image segmentation algorithms. Then, features are extracted from these candidate regions and classified to determine whether they are real defects.
[0004] However, existing methods typically isolate candidate regions from the original image for analysis when classifying them. This approach severs the intrinsic connection between the candidate region and its surrounding environment, causing the analysis process to lose crucial global contextual information. In particular, injection mold surfaces often contain a large number of normal textures or structures with regular repetitive characteristics, generated by machining processes (such as CNC milling and EDM). When local areas of these normal textures are incorrectly identified as candidate regions by the algorithm, the classifier cannot refer to the distribution of the texture across the entire mold surface because the subsequent analysis is performed in isolation.
[0005] Therefore, existing methods cannot effectively distinguish between an isolated, abnormal texture and a normal texture that is part of an overall regular structure, resulting in a high false alarm rate and reducing the reliability of the detection system. Summary of the Invention
[0006] The purpose of this invention is to propose a machine vision-based method and system for detecting defects in injection molds, in order to solve the problem that it is difficult to accurately detect defects in injection molds in the prior art; to this end, this invention provides solutions in the following two aspects.
[0007] In a first aspect, the present invention provides a machine vision-based method for detecting defects in injection molds, comprising: Acquire an image of the surface of the injection mold to be inspected; The image is segmented to locate at least one candidate defect region; Construct feature vectors for each defect candidate region and use a classifier to identify defects; The feature vector includes geometric morphological features, grayscale texture features, and structured anomaly index; The structured anomaly index is negatively correlated with the pre-obtained maximum peak value; the process of obtaining the maximum peak value is as follows: extract the deep texture feature vector of the defect candidate region, use the deep texture feature vector as a template, perform sliding matching on the image, calculate the similarity between the template and the deep texture feature vector in each image block, and generate a heat map; use Hough transform to obtain the maximum peak value in the accumulator value of the heat map.
[0008] The aforementioned scheme introduces a "structured anomaly index" into the constructed feature vector. This index extracts the deep texture features of candidate regions and uses them as templates for sliding matching across the entire image to generate a heatmap. The Hough transform is then used to analyze the structure of the heatmap, thereby quantifying the degree of repetition of the candidate region's texture globally. This method combines the local features of defects with global contextual information, enabling the classifier to effectively distinguish between isolated real defects and normal regions that are part of a large area of regular texture. This significantly reduces the false alarm rate and greatly improves the accuracy and reliability of injection mold defect detection.
[0009] Optionally, the structured anomaly index is: ; in, Let be the structured anomaly index of the i-th defect candidate region. This is the accumulator array obtained after performing a Hough transform on the highlighted regions in the heatmap of the i-th defect candidate region. This is a heatmap of the i-th defect candidate region. This indicates the operation of retrieving the maximum value. The scaling factor is a positive value.
[0010] The aforementioned structured anomaly index ensures the effectiveness of this feature in distinguishing defects from normal textures.
[0011] Optionally, extracting the deep texture feature vector of the defect candidate region includes: The image patch corresponding to the defect candidate region is input into a pre-trained convolutional neural network, and the activation map of the intermediate layer of the convolutional neural network is extracted; global average pooling is performed on the activation map to obtain the depth texture feature vector.
[0012] The above method can automatically learn and capture deeper, more abstract, and more discriminative texture information in images. Its feature representation capability far exceeds that of traditional methods, thus laying a solid foundation for the subsequent generation of high-quality heatmaps and the calculation of accurate structured anomaly indices, and further improving the ability to analyze complex textures.
[0013] Optionally, performing sliding matching on the image to calculate the similarity between the template and the depth texture feature vector within each image block to generate a heatmap includes: traversing the image using a sliding window approach and calculating the cosine similarity between the depth texture feature vector and the depth texture feature vector of each image block within the sliding window to obtain the heatmap.
[0014] The accurate heatmaps generated by the above scheme provide high-quality input for subsequent Hough transform analysis of texture structure.
[0015] Optionally, obtaining the maximum peak value in the accumulator values of the heatmap using the Hough transform includes: The heatmap is binarized to obtain a binary image, and the highlighted areas are retained; then, Hough transform is applied to the highlighted areas to detect the maximum peak value in the accumulator array. Specifically, the heatmap is binarized by setting the pixel values in the heatmap that are greater than a set threshold to 1, and the rest to 0.
[0016] This approach can more accurately capture linear or structured patterns formed by regular textures (such as machining marks). Compared to analyzing directly on the original heatmap, this can effectively filter out noise and interference from irrelevant weakly similar regions, allowing the accumulator peaks to more accurately reflect the structured repetition intensity of the texture, thereby improving the calculation accuracy of the structured anomaly index.
[0017] Optionally, feature vectors are constructed for each defect candidate region and a classifier is used to identify defects, including: inputting geometric morphological features, grayscale texture features and structured anomaly index into the classifier to output true defects and achieve defect classification.
[0018] Optionally, the classifier is a support vector machine.
[0019] Optionally, before locating the candidate defect region, the image is preprocessed, the preprocessing including: decomposing the image using bilateral filtering to obtain the decomposed image, and denoising the decomposed image using guided filtering.
[0020] Optionally, the image is segmented to locate at least one candidate defect region, including: The preprocessed image is input into an attention segmentation network to obtain multiple binary masks containing the defect candidate regions.
[0021] In the second aspect, a machine vision-based injection mold defect detection system includes: processor; The memory stores computer instructions for machine vision-based injection mold defect detection, which, when executed by the processor, cause the system to perform the machine vision-based injection mold defect detection method described above.
[0022] The beneficial effects of this invention are as follows: The present invention extracts texture features of candidate regions through deep learning, generates heatmaps by matching them on a global image, and combines Hough transform to quantify the structured repetition of the texture. By combining this global contextual information with local features, the detection system can effectively identify isolated anomalies (true defects) and repetitive patterns (normal textures), thereby significantly reducing the false alarm rate and greatly improving the accuracy and reliability of automated defect detection. Attached Figure Description
[0023] Figure 1 The flowchart illustrating the steps of the machine vision-based injection mold defect detection method in this embodiment is shown in the schematic diagram. Figure 2 The schematic diagram illustrates the structural block diagram of the machine vision-based injection mold defect detection system in this embodiment. Detailed Implementation
[0024] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0025] like Figure 1 As shown, the machine vision-based injection mold defect detection method in this embodiment includes the following steps: This invention provides a machine vision-based method for detecting defects in injection molds, aiming to solve the problem in the prior art where the lack of global context information makes it difficult to distinguish between isolated defects and structured normal textures, resulting in a high false alarm rate, and to achieve high-precision identification of surface defects in molds.
[0026] Specifically, such as Figure 1 As shown, the machine vision-based injection mold defect detection method in this embodiment includes the following steps: Step S1: Acquire and preprocess an image of the surface of the injection mold to be inspected.
[0027] In this embodiment, a high-resolution digital image of the surface of the injection mold to be inspected is acquired using an image acquisition device such as an industrial camera.
[0028] The aforementioned injection mold can be a component of the robot vacuum cleaner, such as the outer shell, bottom cover, dust collection box, water tank, etc.; in this embodiment, the injection mold is for the outer shell of the robot vacuum cleaner.
[0029] To eliminate noise that may be introduced during the acquisition process and enhance the effective information in the image, preprocessing of the original image is necessary. This preprocessing includes image decomposition and denoising.
[0030] Specifically, bilateral filtering can be used to process the original image, decomposing it into a base layer and a detail layer, which facilitates subsequent analysis of features at different levels.
[0031] Among them, the bilateral filter is a non-linear filtering method that can simultaneously consider the spatial proximity and gray-level similarity between pixels, thereby effectively protecting edge and other details while smoothing the image and removing noise.
[0032] Subsequently, in order to further improve image quality, guided filtering can be used to denoise the decomposed image.
[0033] Among them, guided filtering uses a guide image to influence the filtering process, which can transfer the structural information of the guide image to the image to be filtered, achieving a better edge preservation effect than traditional filters.
[0034] In this embodiment, after preprocessing, a clear image with low noise level and well-defined edge structure is obtained, laying the foundation for subsequent defect localization and feature extraction.
[0035] Step S2: Segment the preprocessed image to locate candidate defect regions.
[0036] After obtaining the preprocessed image, it needs to be segmented to quickly and accurately locate the regions that may contain defects, i.e., defect candidate regions.
[0037] In one embodiment, an attention segmentation network is used to segment the preprocessed image to obtain defect candidate regions.
[0038] Specifically, the preprocessed image is input into a pre-trained attention segmentation network, which outputs a series of binary masks, each of which corresponds to a defect candidate region.
[0039] The attention segmentation network mentioned above can be a U-Net network, which, through an encoder-decoder structure and attention mechanism, is able to learn and identify regions in an image that are significantly different from the background.
[0040] Step S3: Construct feature vectors for each defect candidate region.
[0041] In order to accurately identify defects in each defect candidate region, it is necessary to extract features that can comprehensively describe its characteristics and construct a multi-dimensional feature vector.
[0042] In this embodiment, the feature vector includes geometric morphological features, grayscale texture features, and structured anomaly index.
[0043] Among them, geometric morphological features are used to describe the shape and size information of the defect candidate region, such as its area, perimeter, roundness, aspect ratio, and density.
[0044] Gray-scale texture features are used to describe the pixel gray-scale distribution and texture pattern within a region. They can be described by using the gray-level co-occurrence matrix (GLCM) to extract statistics such as contrast, correlation, energy, and homogeneity, or by using operators such as local binary mode (LBP).
[0045] Among them, the structured anomaly index characterizes the repeatability and regularity of the texture pattern of the defect candidate region on the entire injection mold surface.
[0046] It should be noted that the texture pattern of a real, isolated defect (such as a scratch or dent) should be isolated in the global image. However, a texture generated by a normal manufacturing process (such as CNC milling) may appear abnormal locally, but it should exhibit regular repetition in the global scope. Therefore, it is necessary to calculate the structured anomaly index for each defect candidate region.
[0047] Specifically, the calculation process for the structured anomaly index is as follows: First, the deep texture feature vector of the defect candidate region is extracted.
[0048] In this embodiment, the first Image patches representing candidate defect regions are input into a pre-trained convolutional neural network, and the activation maps output from its intermediate convolutional layers are extracted. Global average pooling is then performed on these activation maps to obtain a fixed-length one-dimensional vector, which represents the depth texture feature vector of the candidate defect region.
[0049] The convolutional neural network can be either VGG-16 or ResNet-50. The activation map extracted from the output of its intermediate convolutional layer can be the activation map of the block3_conv3 layer of VGG-16.
[0050] Secondly, heatmaps are generated based on the deep texture feature vectors of each defect candidate region.
[0051] In one embodiment, the process of obtaining a heatmap is as follows: Using the extracted depth texture feature vector as a template, a sliding window approach is used for matching across the entire preprocessed image. For each image patch within the sliding window, its depth texture feature vector is extracted, and the similarity between the template and the depth texture feature vector corresponding to each sliding window is calculated. The similarity of each sliding window is used as the pixel value at the corresponding position to obtain a heatmap of each defect candidate region.
[0052] In this embodiment, cosine similarity is used to measure the relationship between the template and the depth texture feature vectors corresponding to each sliding window, and its value range is [value range missing]. The closer the value is A higher similarity indicates a higher degree of similarity.
[0053] In this heatmap, areas with higher brightness indicate that their texture pattern is similar to the first... The more similar the texture patterns of the candidate defect regions, the better.
[0054] In another embodiment, the depth texture feature vector of each defect candidate region can be used as a convolution kernel and convolved with the depth texture feature vector of the preprocessed image to obtain a heatmap of each defect candidate region.
[0055] Then, the Hough transform was used to analyze the structure of each heatmap to obtain the degree of structural repetition of the heatmap for each defect candidate region.
[0056] It's important to note that if a texture is regularly repeating, then on a heatmap, highly similar bright spots will exhibit a linear or grid-like distribution. If it's a non-linear repeating pattern, the heatmap will show numerous high-brightness responses, resulting in a large number of bright areas. Even if these areas are not collinear, it indicates that the feature is heavily repeated globally. Therefore, the more bright areas there are, the higher the texture repetition rate in the heatmap.
[0057] Therefore, the process for obtaining the structural repetition degree of the heatmap for each defect candidate region in this embodiment is as follows: First, the heatmap is binarized to obtain a binary image, retaining high-similarity regions (highlighted areas). Hough transform is used to map the bright spots in the highlighted areas to the parameter space, the number of collinear points is counted, and the maximum peak value in the accumulator array is obtained. This maximum peak value is used as the degree of structural repetition. In this embodiment, pixels with grayscale values greater than a preset threshold in the heatmap are set as... The rest are set as .
[0058] The preset threshold can be 0.8. Of course, as another implementation method, it can be set according to the actual situation.
[0059] The Hough transform maps bright spots in a highlighted region to a parameter space (such as polar coordinates). In the parameter space, voting is accumulated within this space; if multiple points are collinear, their corresponding curves in the parameter space will intersect at a point, forming a peak.
[0060] The intensity of the peaks (i.e. the maximum values) in the accumulator array directly reflects the degree of collinearity of the bright spots in the heatmap, that is, the degree of structured repetition of the texture.
[0061] Finally, the structured anomaly index is calculated.
[0062] The structured anomaly index is: ; in, For the first The structured anomaly index of each defect candidate region; For the first The accumulator array is obtained by performing a Hough transform on the heatmaps of the candidate defect regions. This is a heatmap of the i-th defect candidate region; This indicates the operation of retrieving the maximum value in the array, i.e., the peak value of the accumulator; This is a positive scaling factor used to adjust the rate of exponential decay. As a preferred option, The range of values for can be: .
[0063] As can be seen from the above formula, the maximum peak value obtained by the Hough transform is... When the value increases, it indicates that the texture of the defect candidate region has stronger structured repeatability globally, and the exponential function at this time... The value approaches The degree of abnormality is low. Conversely, if Smaller, then The value approaches This indicates that the region is highly likely to be an isolated anomaly.
[0064] The higher the degree of structured repetition, the larger the peak value of the Hough accumulator, and the lower its probability of being a defect, i.e., the smaller the anomaly index should be. Conversely, if the texture pattern is isolated, the distribution of bright spots on the heatmap is random, the peak value of the Hough accumulator is very small, and its anomaly index should be large.
[0065] Step S4: Use a classifier to identify defects in order to detect defects in the injection mold.
[0066] In one embodiment, after constructing a feature vector containing geometric morphological features, grayscale texture features, and structured anomaly index for each defect candidate region, the feature vector is input into a pre-trained classifier for final defect discrimination.
[0067] The classifier can be a support vector machine (SVM), a random forest, or a multilayer perceptron (MLP), etc.
[0068] Taking Support Vector Machine (SVM) as an example, its specific training process is as follows: Obtain the training set, which includes the feature vectors of each defect candidate region in the historical injection mold set and the label of whether the corresponding defect candidate region is a defect, where 1 represents a defect and 0 represents no defect.
[0069] The support vector machine is trained using the training set to obtain a well-trained support vector machine.
[0070] Since the training process is based on existing technology, it will not be elaborated on further here.
[0071] In this embodiment, the classifier outputs the category of each defect candidate region (e.g., "real defect" or "normal texture"), thereby completing the entire detection process.
[0072] The present invention introduces a structured anomaly index to analyze the local features of the defect candidate region in combination with its contextual consistency in the global image. This effectively distinguishes isolated real defects from normal processing textures with regular repetition, significantly reducing the false alarm rate and improving the reliability and accuracy of the automated detection system.
[0073] This invention also provides a machine vision-based injection mold defect detection system. For example... Figure 2 As shown, the system includes a processor and a memory, the memory storing computer program instructions, which, when executed by the processor, implement the machine vision-based injection mold defect detection method according to the present invention.
[0074] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and therefore will not be described in detail here.
[0075] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device. Any application or module described in this invention can be implemented by computer-readable / executable instructions stored or otherwise maintained on such a computer-readable medium.
[0076] In the description of this specification, "multiple" means at least two, such as two, three or more, etc., unless otherwise expressly and specifically defined.
[0077] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.
Claims
1. A machine vision-based method for detecting defects in injection molds, characterized in that, include: Acquire an image of the surface of the injection mold to be inspected; The image is segmented to locate at least one candidate defect region; Construct feature vectors for each defect candidate region and use a classifier to identify defects; The feature vector includes geometric morphological features, grayscale texture features, and structured anomaly index; The structured anomaly index is negatively correlated with the pre-obtained maximum peak value; the process of obtaining the maximum peak value is as follows: extract the deep texture feature vector of the defect candidate region, use the deep texture feature vector as a template, perform sliding matching on the image, calculate the similarity between the template and the deep texture feature vector in each image block, and generate a heat map; use Hough transform to obtain the maximum peak value in the accumulator value of the heat map.
2. The machine vision-based injection mold defect detection method according to claim 1, characterized in that, The structured anomaly index is: ; in, Let be the structured anomaly index of the i-th defect candidate region. This is the accumulator array obtained after performing a Hough transform on the highlighted regions in the heatmap of the i-th defect candidate region. This is a heatmap of the i-th defect candidate region. This indicates the operation of retrieving the maximum value. The scaling factor is a positive value.
3. The machine vision-based injection mold defect detection method according to claim 1, characterized in that, Extracting the deep texture feature vector of the defect candidate region includes: The image patch corresponding to the defect candidate region is input into a pre-trained convolutional neural network, and the activation map of the intermediate layer of the convolutional neural network is extracted; global average pooling is performed on the activation map to obtain the depth texture feature vector.
4. The machine vision-based injection mold defect detection method according to claim 1, characterized in that, Performing sliding matching on the image and calculating the similarity between the template and the depth texture feature vector within each image block to generate a heatmap includes: traversing the image using a sliding window approach and calculating the cosine similarity between the depth texture feature vector and the depth texture feature vector of each image block within the sliding window to obtain the heatmap.
5. The machine vision-based injection mold defect detection method according to claim 1, characterized in that, The step of obtaining the maximum peak value in the accumulator values of the heatmap using Hough transform includes: The heatmap is binarized to obtain a binary image, and the highlighted areas are retained; then, Hough transform is applied to the highlighted areas to detect the maximum peak value in the accumulator array. Specifically, the heatmap is binarized by setting the pixel values in the heatmap that are greater than a set threshold to 1, and the rest to 0.
6. The machine vision-based injection mold defect detection method according to claim 1, characterized in that, Feature vectors are constructed for each defect candidate region and a classifier is used to identify defects. This includes inputting geometric morphological features, grayscale texture features, and structured anomaly index into the classifier to output the true defects and achieve defect classification.
7. The machine vision-based injection mold defect detection method according to claim 6, characterized in that, The classifier is a support vector machine.
8. The machine vision-based injection mold defect detection method according to claim 1, characterized in that, Before locating the candidate defect region, the image is preprocessed. The preprocessing includes: decomposing the image using bilateral filtering to obtain the decomposed image, and denoising the decomposed image using guided filtering.
9. The machine vision-based injection mold defect detection method according to claim 8, characterized in that, Segmenting the image to locate at least one candidate defect region includes: The preprocessed image is input into an attention segmentation network to obtain multiple binary masks containing the defect candidate regions.
10. A machine vision-based injection mold defect detection system, characterized in that, include: processor; A memory storing computer instructions for machine vision-based injection mold defect detection, which, when executed by the processor, cause the system to perform the machine vision-based injection mold defect detection method according to any one of claims 1-9.