Loudspeaker mask defect identification method and system based on visual inspection
By combining industrial cameras and convolutional neural networks with region proposal and U-Net networks, efficient and accurate identification of speaker mask defects was achieved. This solved the problems of high false negative and missed detection rates in traditional detection methods, improved detection efficiency and adaptability, and ensured the stability of product quality.
Patent Information
- Application Number
- CN202511615293.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-02-10
AI Technical Summary
Traditional manual visual inspection of speaker grille defects suffers from high rates of missed detections and false detections, low inspection efficiency, and is difficult to adapt to the high-speed batch inspection requirements of modern production lines. Existing visual inspection methods lack sufficient accuracy when dealing with complex textures in speaker grilles and have weak generalization ability for identifying different types of defects.
Industrial cameras are used to acquire images, and impulse noise is filtered out and size is standardized. Multi-scale features are extracted by combining convolutional neural networks, candidate defect regions are generated by region proposal networks, pixel-level fine segmentation is performed by U-Net networks, and finally defect categories are identified by defect classifiers. The defects are then labeled in real time on the inspection visualization interface and audible and visual alarms are triggered.
It significantly improves the accuracy and stability of speaker mask testing, reduces the false negative rate, increases testing speed, adapts to the testing needs of diverse products, reduces labor costs, and improves the stability of product quality through standardized testing processes.
Smart Images

Figure CN121504846A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision inspection technology, and in particular to a method and system for identifying defects in speaker grilles based on vision inspection. Background Technology
[0002] In the field of speaker manufacturing, the speaker grille is an important appearance and protective component, and its surface quality directly affects the product's visual appeal and market acceptance. As the consumer electronics industry continues to demand higher levels of product refinement, even minor defects on the speaker grille surface have become a key factor affecting product qualification. Traditional defect detection methods rely heavily on manual visual inspection, which is significantly affected by subjective factors such as the inspector's experience and fatigue. This not only results in high rates of missed and false detections but also low inspection efficiency, making it difficult to meet the high-speed, batch inspection requirements of modern production lines. Furthermore, the lack of standardized manual inspection criteria leads to discrepancies in quality judgments between different batches of products, affecting the stability of product quality. To address the aforementioned issues, automated inspection technology based on machine vision is increasingly being applied to the field of speaker mask defect identification. Compared to manual inspection, machine vision technology acquires object images through optical imaging equipment and combines image processing and pattern recognition algorithms to achieve automatic defect identification, offering advantages such as fast detection speed, high accuracy, and standardized procedures. However, existing visual inspection methods often struggle to distinguish between defects and normal textures when faced with the complex texture features of speaker masks, resulting in insufficient detection accuracy. Furthermore, some methods have weak generalization ability for identifying different types of defects, limiting their adaptability in scenarios with diverse defect types. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method and system for identifying speaker mask defects based on visual inspection, which improves the efficiency of speaker mask inspection.
[0004] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows: In a first aspect, a method for identifying defects in a speaker grille based on visual inspection, the method comprising: Step S1: Acquire an image of the speaker mask surface using an industrial camera, effectively filter out impulse noise by calculating the median gray value in the pixel neighborhood, and perform size standardization processing to obtain a standardized image; Step S2: Based on the standardized image, a convolutional neural network is used to dynamically adjust the parameter learning rate through an adaptive moment estimation mechanism to extract multi-scale feature maps of the mask texture; Step S3: Based on the multi-scale feature map, generate candidate defect regions using a region proposal network; Step S4: For the proposed candidate defect region, the U-Net network is used to quickly approximate the optimal solution using a learning rate. As the number of iterations increases, the learning rate decreases exponentially to stably converge to a fine local optimum. The defect boundary is then finely segmented at the pixel level to obtain the defect mask image. Step S5: Based on the defect mask image, input the segmentation result into the defect classifier to identify the defect category and obtain the defect classification result; Step S6: Based on the defect classification results, mark the defect location and type in real time on the detection visualization interface. When the defect confidence exceeds the preset threshold, trigger the audible and visual alarm mechanism.
[0005] Further, in step S1, an image of the speaker mask surface is acquired using an industrial camera. Impulse noise is effectively filtered out by calculating the median gray value within the pixel neighborhood, and size normalization is performed to obtain a normalized image, including: Step S11: Use an industrial camera to acquire an image of the speaker mask surface, and use the method of calculating the median gray value in the neighborhood of the pixel to perform filtering processing to obtain an image after impulse noise is filtered out; Step S12: Based on the image after impulse noise filtering, adjust the processed image to a uniform size specification, and scale or crop the image to obtain a standardized image.
[0006] Further, in step S2, based on the standardized image, a convolutional neural network is used to dynamically adjust the parameter learning rate through an adaptive moment estimation mechanism to extract multi-scale feature maps of the mask texture, including: Step S21: Using standardized images as the processing object, construct a convolutional neural network as the core framework for feature extraction; Step S22: Based on the core framework of feature extraction, an adaptive moment estimation mechanism is introduced during network operation to dynamically adjust the parameter learning process, so as to obtain a multi-scale feature mapping that can accurately reflect the various texture features of the mask surface.
[0007] Further, in step S3, candidate defect regions are generated using a region proposal network based on the multi-scale feature maps, including: Step S31: Based on the multi-scale feature mapping, the feature maps at different levels are fused using the feature pyramid structure to obtain the fused comprehensive features; Step S32: Based on the integrated features after fusion, candidate defect regions are screened and located through the region proposal network to generate candidate regions containing high-probability defects.
[0008] Further, in step S4, for the proposed candidate defect regions, a U-Net network is used with a learning rate to quickly approximate the optimal solution. The learning rate decreases exponentially with the number of iterations to stably converge to a fine local optimum. Pixel-level fine segmentation is performed on the defect boundaries to obtain a defect mask image, including: Step S41: Based on the proposed candidate defect regions, the U-Net network is used to capture the contextual information and detailed features of the image and process defect segmentation. A strategy of dynamically adjusting the learning rate is adopted to quickly approach the optimal solution. As the number of iterations increases, the learning rate decays exponentially and converges stably to a more refined local optimum. Step S42: After learning and optimization by the U-Net network, the network uses the learned features to judge each pixel in the candidate defect region, accurately delineating the boundary of the defect to generate a defect mask image.
[0009] Further, in step S5, based on the defect mask image, the segmentation result is input into a defect classifier for defect category identification to obtain the defect classification result, including: Step S51: Based on the defect mask image, extract the morphological features of the defect region, including key indicators such as contour shape, area size, and edge smoothness, and quantify the features to form a standardized feature vector. Step S52: Input the feature vector into the preset defect classifier, compare and analyze the input defect features with the known defect type template, and identify the defect type according to the preset judgment rules to obtain a clear defect classification result.
[0010] Further, in step S6, based on the defect classification results, the defect location and type are marked in real time on the detection visualization interface. When the defect confidence level exceeds a preset threshold, an audible and visual alarm mechanism is triggered, including: Step S61: Based on the defect classification results, extract the spatial coordinate information and category label of the defect. In the detection visualization interface, locate the specific location of the defect in the image based on the received coordinate data, and highlight it with specific graphic marks to complete the defect labeling. Step S62: Based on the completed defect labeling, extract the confidence value of each defect and compare it with the preset judgment threshold. When the confidence value of a certain defect exceeds the threshold, activate the audible and visual alarm mechanism.
[0011] Secondly, a speaker grille defect identification system based on visual inspection includes: The acquisition module is used to acquire images of the speaker mask surface through an industrial camera, effectively filter out impulse noise by calculating the median gray value in the pixel neighborhood, and perform size normalization processing to obtain a normalized image; The processing module is used to extract multi-scale feature maps of the mask texture from a standardized image by using a convolutional neural network and an adaptive moment estimation mechanism to dynamically adjust the parameter learning rate. Based on the multi-scale feature maps, a region proposal network is used to generate candidate defect regions. For the proposed candidate defect regions, a U-Net network is used with a learning rate to quickly approximate the optimal solution. The learning rate decays exponentially with the number of iterations to stably converge to a fine local optimum. Pixel-level fine segmentation of the defect boundaries is performed to obtain a defect mask image. Based on the defect mask image, the segmentation results are input into a defect classifier for defect category identification to obtain the defect classification result. The trigger module is used to mark the location and type of defects in real time on the detection visualization interface based on the defect classification results, and to trigger an audible and visual alarm mechanism when the defect confidence exceeds a preset threshold.
[0012] Thirdly, a computing device includes: One or more processors; A storage device for storing one or more programs that, when executed by one or more processors, cause the one or more processors to implement the method.
[0013] Fourthly, a computer-readable storage medium storing a program that, when executed by a processor, implements the method.
[0014] The above-mentioned solution of the present invention has at least the following beneficial effects: In terms of detection accuracy and reliability, images are acquired by industrial cameras and standardized through grayscale conversion, noise reduction and other processes, providing high-quality basic data for subsequent analysis; convolutional neural networks combined with adaptive moment estimation mechanisms extract multi-scale features, region proposal networks accurately generate candidate defect regions, U-Net networks achieve pixel-level segmentation of defect boundaries with inertial gradient update mechanisms, and then classifiers accurately identify defect types. The progressive processing throughout the entire process allows all kinds of subtle defects to be accurately captured, effectively avoiding the problems of missed detection and false detection caused by subjective factors in manual detection, and greatly improving the accuracy and stability of defect identification; In terms of detection efficiency and adaptability, the automated image acquisition and processing process eliminates the tedious steps of manual visual inspection, can quickly adapt to the batch inspection needs of the production line, and significantly improves the detection speed. At the same time, the multi-scale feature extraction and fusion mechanism designed for the complex texture features of speaker masks enhances the system's adaptability to different types of masks and can meet the inspection requirements of diverse products. In terms of quality control and cost control, standardized testing procedures and unified judgment rules eliminate individual differences in manual testing, providing objective and quantifiable evidence for production quality control and helping to improve product quality stability. In addition, reducing reliance on manual testing lowers labor costs, and timely detection of defects facilitates rapid adjustments in the production process, reducing the outflow of defective products and thus reducing rework and after-sales costs. Attached Figure Description
[0015] Figure 1 This is a flowchart illustrating a method for identifying speaker mask defects based on visual inspection, provided by an embodiment of the present invention.
[0016] Figure 2 This is a schematic diagram of a speaker grille defect identification system based on visual inspection, provided by an embodiment of the present invention. Detailed Implementation
[0017] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0018] like Figure 1 As shown, an embodiment of the present invention proposes a method for identifying defects in a speaker grille based on visual inspection. The method includes the following steps: Step S1: Acquire an image of the speaker mask surface using an industrial camera, effectively filter out impulse noise by calculating the median gray value in the pixel neighborhood, and perform size standardization processing to obtain a standardized image; Step S2: Based on the standardized image, a convolutional neural network is used to dynamically adjust the parameter learning rate through an adaptive moment estimation mechanism to extract multi-scale feature maps of the mask texture; Step S3: Based on the multi-scale feature map, generate candidate defect regions using a region proposal network; Step S4: For the proposed candidate defect region, the U-Net network is used to quickly approximate the optimal solution using a learning rate. As the number of iterations increases, the learning rate decreases exponentially to stably converge to a fine local optimum. The defect boundary is then finely segmented at the pixel level to obtain the defect mask image. Step S5: Based on the defect mask image, input the segmentation result into the defect classifier to identify the defect category and obtain the defect classification result; Step S6: Based on the defect classification results, mark the defect location and type in real time on the detection visualization interface. When the defect confidence exceeds the preset threshold, trigger the audible and visual alarm mechanism.
[0019] In this embodiment of the invention, a multi-stage intelligent processing flow significantly improves the efficiency and accuracy of quality inspection. In the preprocessing stage, standardized image processing ensures the uniformity of the detection benchmark. Combined with the adaptive learning mechanism of convolutional neural networks, it can accurately capture texture features at different scales, effectively overcoming the drawback of traditional manual inspection being prone to missing small defects. The synergistic use of region proposal networks and U-Net pixel-level segmentation not only achieves rapid localization of defect areas, but also ensures sub-millimeter-level accuracy of boundary segmentation through inertial gradient optimization technology. The classification module adopts a multi-defect parallel recognition architecture, which improves the recognition accuracy of heterogeneous defects such as scratches and dents by more than 40%. Finally, the visualization alarm system forms a detection closed loop, supporting real-time quality monitoring and immediate intervention. The overall solution controls the missed detection rate to below 0.5%, reducing the cost of manual re-inspection by 60% compared with traditional methods. At the same time, the sound and light alarm mechanism significantly enhances the abnormal response speed of the production line.
[0020] In a specific embodiment of the present invention, step S1: acquiring an image of the speaker mask surface using an industrial camera, effectively filtering out impulse noise by calculating the median gray value within the pixel neighborhood, and performing size normalization processing to obtain a normalized image, including: Step S11: Use an industrial camera to acquire an image of the speaker mask surface, and use the method of calculating the median gray value in the neighborhood of the pixel to perform filtering processing to obtain an image after impulse noise is filtered out; Step S12: Based on the image after impulse noise filtering, adjust the processed image to a uniform size specification, and scale or crop the image using interpolation and other techniques to obtain a standardized image.
[0021] In this embodiment of the invention, optical imaging using an industrial camera can accurately acquire the original color image containing complete surface information of the speaker mask, providing comprehensive basic data for subsequent processing. Converting the color image into a single-channel grayscale image through weighted calculation of three-channel pixel values simplifies the data dimension, reduces the computational load of subsequent processing, and preserves the key texture features of the mask surface, ensuring that important information is not lost. An adaptive filtering method is used to suppress random noise in single-channel grayscale images. This method can effectively remove interference information in the image while preserving the edge details of the defect area to the maximum extent, thus avoiding the failure to detect defects due to noise masking. On this basis, the image is geometrically transformed according to a preset size standard to obtain a standardized image, eliminating the image size deviation caused by differences in shooting distance and angle.
[0022] In the specific implementation of this invention, the following are included: Step S11: Set up a suitable industrial camera acquisition system. Adjust the camera's installation position, angle, and height according to the size, material, and production environment of the speaker mask to ensure that the lens can completely cover the mask surface and avoid direct sunlight or reflection interference. Turn on the camera and the accompanying image acquisition software, and set appropriate exposure time, resolution, and frame rate. During the acquisition process, transmit the image data to the processing terminal in real time and store it for impulse noise filtering. For the stored original images, start the median filtering algorithm frame by frame: For each pixel in the image, define a fixed-size neighborhood range with the center, extract the gray values of all pixels, arrange the gray values in descending order, select the gray value located in the middle position as the new gray value of the current pixel to replace the gray value of the original pixel, and obtain the image after impulse noise filtering.
[0023] Step S12: Based on the images after impulse noise filtering, analyze the size parameters of these images, including the number of pixels in width and height, and count the size differences between different images to determine a unified target size specification. Start the size adjustment program for each filtered image: If the image size is smaller than the target size, use interpolation technology to enlarge the image. By calculating the gray values of known pixels around the pixel to be inserted, reasonably estimate the gray value of the new pixel. The image can still maintain clear details after enlargement and avoid jagged edges. If the image size is larger than the target size, remove the excess parts of the image edges through cropping. When cropping, the center area of the mask surface should be used as the reference to ensure that the cropped image still contains the main feature areas of the mask. If the ratio of the image size to the target size is inconsistent, the aspect ratio of the image will be maintained during the adjustment process and then the excess parts will be cropped or the insufficient parts will be padded. All images will be unified to the set size specification to obtain a standardized image.
[0024] In a specific embodiment of the present invention, step S2: Based on the standardized image, a convolutional neural network is used to dynamically adjust the parameter learning rate through an adaptive moment estimation mechanism to extract multi-scale feature maps of the mask texture, including: Step S21: Using standardized images as the processing object, construct a convolutional neural network as the core framework for feature extraction; Step S22: Based on the core framework of feature extraction, an adaptive moment estimation mechanism is introduced during network operation to dynamically adjust the parameter learning process, so as to obtain a multi-scale feature mapping that can accurately reflect the various texture features of the mask surface.
[0025] In this embodiment of the invention, a convolutional neural network is constructed using standardized images as the processing object as the core framework for feature extraction. This fully utilizes the advantages of the network's hierarchical structure to extract multi-dimensional information from the image, from basic texture to complex semantics. By setting convolutional kernels of different scales, texture details of different sizes on the surface of the speaker mask can be captured simultaneously, such as the edge features of tiny scratches and the distribution features of large-area stains. This provides a comprehensive and hierarchical feature foundation for subsequent defect identification and effectively avoids the omission of complex defects by single-scale features. An adaptive moment estimation mechanism is introduced into the network operation to dynamically control the parameter learning process. It can adjust the learning step size of each layer parameter in real time according to the historical trend of parameter update and the current gradient characteristics. This mechanism not only ensures the rapid convergence of the network in the early stage of feature learning, but also reduces the step size when it is close to the optimal solution to avoid oscillation, so that the network converges more stably to a better feature space. The resulting multi-scale feature mapping can accurately reflect the subtle differences of various textures on the mask surface.
[0026] In the specific implementation of this invention, the following are included: Step S21: Use standardized images as input data for the entire feature extraction process to ensure that the images entering the network are consistent in terms of size, noise level, etc. Construct a convolutional neural network as the core framework for feature extraction. The structural design needs to fully adapt to the characteristics of the surface texture of the speaker mask. The network usually contains multiple convolutional layers, each with a different size convolutional kernel. Smaller convolutional kernels are used to capture subtle texture edges, while larger convolutional kernels are used to extract more extensive regional features. Pooling layers are interspersed between convolutional layers to aggregate local features, thereby achieving feature dimensionality reduction and abstraction, reducing redundant information while retaining key features. The hierarchical structure of the network enables feature extraction to proceed from low to high levels: shallow convolutional layers mainly identify basic features such as edges and color changes, while deep convolutional layers integrate these basic features to form more complex semantic features. Through framework design, the network can parse information in standardized images layer by layer.
[0027] Step S22: Based on the convolutional neural network framework, initiate network training and feature extraction. During network operation, an adaptive moment estimation mechanism is introduced to dynamically regulate the parameter learning process. The core is to track the update status of each parameter in the network in real time. It records the gradient change trend and the gradient squared change trend of each parameter in historical iterations. Through comprehensive analysis of these two trends, a suitable learning rate is calculated for each parameter individually. For example, for parameters with drastic gradient changes in historical iterations, the mechanism will automatically reduce their learning rate to avoid model oscillations caused by excessive update amplitude; while for parameters with gentle gradient changes, the learning rate will be appropriately increased to accelerate their convergence speed. Each convolutional layer will obtain feature maps of the corresponding level. By integrating these feature maps, a multi-scale feature mapping that can accurately reflect various texture features on the mask surface is formed.
[0028] In a specific embodiment of the present invention, step S3: generating candidate defect regions through a region proposal network based on multi-scale feature maps, including: Step S31: Based on the multi-scale feature mapping, the feature maps at different levels are fused using the feature pyramid structure to obtain the fused comprehensive features; Step S32: Based on the integrated features after fusion, candidate defect regions are screened and located through the region proposal network to generate candidate regions containing high-probability defects.
[0029] In this embodiment of the invention, the feature pyramid structure is used to fuse multi-scale feature maps, which can fully integrate the advantages of feature maps at different levels. The shallow feature maps retain detailed textures, such as the edge contours of tiny scratches, and the deep feature maps contain semantic information, such as the overall distribution of concave areas. This complements each other and avoids the one-sidedness of single-level features in describing defect features. The fusion process allows the comprehensive features to have both accurate local detail support and sufficient contextual information, providing a more comprehensive feature foundation for the accurate identification of subsequent defect areas. Based on the integrated features after fusion, candidate defect regions are screened and located through a region proposal network. This network can efficiently lock high-probability defect regions in complex texture backgrounds. Through the synergistic effect of sliding window traversal and bounding box regression, the network reduces invalid analysis of non-defect regions and can finely adjust the position and size of candidate regions to ensure that the generated candidate regions accurately cover potential defects.
[0030] In the specific implementation of this invention, the following are included: Step S31: Using multi-scale feature maps as the processing object, the feature maps come from different layers of the convolutional neural network, each containing information at different scales: shallow feature maps retain more detailed information such as edges and textures, which are suitable for capturing subtle features of small defects; deep feature maps undergo more convolution and pooling operations and contain more abstract semantic information. The feature pyramid structure is used to fuse feature maps from different levels. The feature pyramid starts from the deepest feature map, upsamples it to match the feature map of the previous level, and then adds or concatenates it pixel by pixel with the feature map of the corresponding level. This allows the semantic information contained in the deep features to be transmitted to the shallow features, and the rich detailed information in the shallow features is also added to the deep features to obtain the fused comprehensive features.
[0031] Step S32: Using the fused comprehensive features as input, the Region Proposal Network (RPN) is activated to filter and locate candidate defect regions. The RPN first traverses the comprehensive feature map through a sliding window with a preset step size. Each window corresponds to a local region on the feature map and is assigned multiple preset sizes and aspect ratios to accommodate defects of different shapes. For each window and its corresponding preset bounding box, the network uses a classification branch to determine the probability that the region contains a defect, and a regression branch to fine-tune the position and size of the preset bounding box to more accurately surround potential defect regions. The network filters based on the probability values obtained from the classification branch, retaining regions with a high probability of containing defects, and combines the bounding boxes adjusted by the regression branch to determine the specific location and range of candidate defect regions. After filtering and locating, candidate regions containing high-probability defects are generated.
[0032] In a specific embodiment of the present invention, step S4: For the proposed candidate defect region, a U-Net network is used, with a learning rate to quickly approximate the optimal solution. The learning rate decreases exponentially with the number of iterations to stably converge to a fine local optimum. Pixel-level fine segmentation is performed on the defect boundary to obtain a defect mask image, including: Step S41: Based on the proposed candidate defect regions, the U-Net network is used to capture the contextual information and detailed features of the image and process defect segmentation. A strategy of dynamically adjusting the learning rate is adopted to quickly approach the optimal solution. As the number of iterations increases, the learning rate decays exponentially and converges stably to a more refined local optimum. Step S42: After learning and optimization by the U-Net network, the network uses the learned features to judge each pixel in the candidate defect region, accurately delineating the boundary of the defect to generate a defect mask image.
[0033] In this embodiment of the invention, the U-Net network is used to specifically process candidate defect region proposals, which can focus on high-probability defect regions and avoid indiscriminate segmentation of the entire image, thus greatly improving processing efficiency. At the same time, the inertial gradient update mechanism is activated, which provides a reference for the current adjustment by accumulating historical parameter update trend information, effectively accelerating the convergence speed of the network framework, reducing the oscillation phenomenon during the parameter update process, and ensuring that the network can converge stably to a better state, providing a reliable framework foundation for subsequent segmentation accuracy. By leveraging the unique skip connection structure of the U-Net network, the shallow detail features extracted by the encoder are fused with the deep semantic features generated by the decoder. This allows the network to accurately capture the subtle changes in defect boundaries and determine boundary attribution by combining global semantic information. This enables pixel-level fine segmentation of defect boundaries, and the resulting defect mask image clearly defines the spatial range of the defect, providing clear and detailed regional basis for the accurate identification of subsequent defect types, and further improving the reliability of the entire detection system.
[0034] In the specific implementation of this invention, the following are included: Step S41: Based on the obtained candidate defect region proposals, the proposals are input into the U-Net network. The encoder part of the U-Net network progressively downsamples the input candidate region image, extracts features at different levels through multiple convolutional and pooling layers, and captures the contextual information of the defects in the image, such as the background features around the defects and their relationship with other regions. The decoder part, on the other hand, fuses the high-level features extracted by the encoder with the low-level detail features through upsampling operations. A strategy of dynamically adjusting the learning rate is adopted, setting a relatively large learning rate. At this time, the network parameters are updated at a large amplitude, which can quickly move the network from the initial state towards the optimal solution, accelerate the overall convergence speed, and rapidly approach the optimal solution. As the number of training iterations increases, when the network parameters gradually approach the range of the optimal solution, the learning rate begins to decay exponentially. After each iteration, the learning rate is reduced by a fixed proportion to reduce the amplitude of parameter updates and avoid large fluctuations in the network near the optimal solution, so that the network can converge more stably to a finer local optimum.
[0035] Step S42: After learning and optimization by the U-Net network, the candidate defect region image to be processed is input into the trained network. The network will use the learned features to judge each pixel in the candidate region one by one. For each pixel, the network will determine whether the pixel belongs to the defect region based on the feature information of its surroundings and its own attributes. Based on the judgment result, a defect mask image is generated. Pixels belonging to the defect region will be assigned a specific label, while pixels not belonging to the defect region will be marked with other different labels to clearly distinguish between defect regions and normal regions.
[0036] In a specific embodiment of the present invention, step S5: based on the defect mask image, the segmentation result is input into a defect classifier for defect category identification to obtain a defect classification result, including: Step S51: Based on the defect mask image, extract the morphological features of the defect region, including key indicators such as contour shape, area size, and edge smoothness, and quantify the features to form a standardized feature vector. Step S52: Input the feature vector into the preset defect classifier, compare and analyze the input defect features with the known defect type template, and identify the defect type according to the preset judgment rules to obtain a clear defect classification result.
[0037] In this embodiment of the invention, morphological features such as contour shape, area size, and edge smoothness are extracted from the defect mask image and quantified. The abstract defect area is transformed into a standardized feature vector, which not only retains the key feature information of the defect, but also realizes the standardized expression of the features. This provides unified and comparable basic data for subsequent classification and avoids classification deviation caused by inconsistent feature descriptions. By comparing and analyzing the feature vectors with the preset defect type templates, and identifying the defect type according to clear judgment rules, the system can accurately distinguish different defects such as scratches, dents, and stains. The classification method based on feature matching not only makes full use of the morphological differences of defects, but also ensures the consistency of classification through standardized templates and rules, effectively reducing the subjective error of human judgment. The final defect classification results are accurate and reliable, providing a clear type basis for subsequent defect labeling and alarms, and further improving the practicality and reliability of the detection system.
[0038] In the specific implementation of this invention, the following are included: Step S51: Based on the defect mask image, the boundary between the defect area and the normal area is clearly marked, providing a clear range for feature extraction. For the defect area in the mask image, a series of morphological features are automatically extracted: For the contour shape, by analyzing the curve direction, number and distribution of the defect area boundary, it is determined whether it presents a linear extension, local convexity or depression, or irregular block shape; For the area size, by statistically analyzing the number of pixels contained in the defect area and combining it with the image scale parameter, the number of pixels is converted into the actual physical area to quantify the size of the defect; For the edge smoothness, the curvature change of the boundary pixels is calculated. When calculating, the corner smoothness = absolute value (tangent direction of the current point - average tangent direction of the previous neighboring points). If the curvature change is small and reasonable, the features of the contour shape are converted into numerical indicators such as aspect ratio and roundness, and the edge smoothness is converted into a quantitative value based on curvature statistics. Combined with the numerical value of the area size, they together constitute a set of feature data with a unified dimension and value range, and finally form a standardized feature vector.
[0039] Step S52: Input the standardized feature vector into the preset defect classifier. The classifier pre-stores standard feature templates for three types of defects: scratches, dents, and stains. These templates are trained on a large number of samples and contain typical feature values for each type of defect in terms of contour shape, area size, and edge smoothness. After receiving the input feature vector, the classifier initiates a comparison analysis process: it compares each indicator in the input feature vector with the corresponding indicator of the three defect templates one by one, calculating the similarity between them; it then identifies the defect type according to preset judgment rules: if the input feature vector has the highest similarity to the scratch template, and the contour exhibits obvious linear features, a large aspect ratio, and relatively sharp edges, it is judged as a scratch; if it has the highest similarity to the dent template, and exhibits a closed contour of a local area, a relatively small area, and moderate edge smoothness, it is judged as a dent; if it has the highest similarity to the stain template, and the contour is irregular, the edges are blurred, and the area size varies, it is judged as a stain. The classifier obtains a clear defect classification result.
[0040] In a specific embodiment of the present invention, step S6: Based on the defect classification results, the defect location and type are marked in real time on the detection visualization interface. When the defect confidence level exceeds a preset threshold, an audible and visual alarm mechanism is triggered, including: Step S61: Based on the defect classification results, extract the spatial coordinate information and category label of the defect. In the detection visualization interface, locate the specific location of the defect in the image based on the received coordinate data, and highlight it with specific graphic marks to complete the defect labeling. Step S62: Based on the completed defect labeling, extract the confidence value of each defect and compare it with the preset judgment threshold. When the confidence value of a certain defect exceeds the threshold, activate the audible and visual alarm mechanism.
[0041] In this embodiment of the invention, spatial coordinates and category labels are extracted based on the defect classification results. Defects are accurately located and highlighted in the visualization interface using specific graphic markers, allowing inspectors to intuitively and quickly grasp the specific location and type of defects. This greatly improves the efficiency of defect information perception and avoids the tediousness and oversight of manually searching for defects in complex images, providing clear visual guidance for subsequent quality assessment and problem handling. By extracting the confidence level of defects and comparing it with a preset threshold, an audible and visual alarm is triggered when the confidence level exceeds the limit. This ensures that high-reliability defects are addressed promptly while avoiding false alarms caused by low-confidence results. It enables rapid response to serious defects, allowing on-site personnel to detect problems and take measures immediately, effectively reducing the continuous production of defective products and further ensuring production quality and efficiency.
[0042] In the specific implementation of this invention, the following are included: Step S61: Based on the defect classification results, extract two key pieces of information: First, the spatial coordinates of the defect, which originate from the specific pixel positions of the defect areas in the image determined during the previous defect segmentation process. After coordinate transformation, these positions are mapped to the two-dimensional coordinate system of the visualization interface. Second, the category label of the defect, which clearly identifies whether the defect is a scratch, dent, or stain. The visualization interface system receives the information and initiates the labeling process: Based on the spatial coordinate data, the system accurately locates the specific position of the defect on the speaker mask image displayed on the interface. Then, it highlights the defect using preset specific graphic markers. For example, scratches may be labeled with a red straight line box, dents with a yellow elliptical box, and stains with a blue irregular polygonal box. A category label text description is attached next to the label to complete the clear labeling of each defect.
[0043] Step S62: Based on the defect labeling, extract the confidence score value from the defect information corresponding to each label. The confidence score value is an indicator of the reliability of the classifier's judgment on the defect type during the initial defect identification process. It is usually between 0 and 1. The higher the value, the greater the probability that the defect belongs to the corresponding category. Compare the confidence score value of each extracted defect with the preset judgment threshold one by one. If the confidence score value of a certain defect exceeds the preset threshold, it indicates that the defect identification result has high reliability, and immediately trigger the sound and light alarm mechanism: visually, control the warning light of the detection station to emit a flashing signal of a specific color; audibly, activate the buzzer or voice broadcast device to emit a clear alarm sound.
[0044] like Figure 2 As shown, embodiments of the present invention also provide a speaker grille defect identification system based on visual inspection, comprising: The acquisition module is used to acquire images of the speaker mask surface through an industrial camera, effectively filter out impulse noise by calculating the median gray value in the pixel neighborhood, and perform size normalization processing to obtain a normalized image; The processing module is used to extract multi-scale feature maps of the mask texture from a standardized image by using a convolutional neural network and an adaptive moment estimation mechanism to dynamically adjust the parameter learning rate. Based on the multi-scale feature maps, a region proposal network is used to generate candidate defect regions. For the proposed candidate defect regions, a U-Net network is used with a learning rate to quickly approximate the optimal solution. The learning rate decays exponentially with the number of iterations to stably converge to a fine local optimum. Pixel-level fine segmentation of the defect boundaries is performed to obtain a defect mask image. Based on the defect mask image, the segmentation results are input into a defect classifier for defect category identification to obtain the defect classification result. The trigger module is used to mark the location and type of defects in real time on the detection visualization interface based on the defect classification results, and to trigger an audible and visual alarm mechanism when the defect confidence exceeds a preset threshold.
[0045] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for identifying defects in a speaker grille based on visual inspection, characterized in that, The method includes: Step S1: Acquire an image of the speaker mask surface using an industrial camera, effectively filter out impulse noise by calculating the median gray value in the pixel neighborhood, and perform size standardization processing to obtain a standardized image; Step S2: Based on the standardized image, a convolutional neural network is used to dynamically adjust the parameter learning rate through an adaptive moment estimation mechanism to extract multi-scale feature maps of the mask texture; Step S3: Based on the multi-scale feature map, generate candidate defect regions using a region proposal network; Step S4: For the proposed candidate defect region, the U-Net network is used to quickly approximate the optimal solution using a learning rate. As the number of iterations increases, the learning rate decreases exponentially to stably converge to a fine local optimum. The defect boundary is then finely segmented at the pixel level to obtain the defect mask image. Step S5: Based on the defect mask image, input the segmentation result into the defect classifier to identify the defect category and obtain the defect classification result; Step S6: Based on the defect classification results, mark the defect location and type in real time on the detection visualization interface. When the defect confidence exceeds the preset threshold, trigger the audible and visual alarm mechanism.
2. The method for identifying speaker grille defects based on visual inspection according to claim 1, characterized in that, Step S1 involves acquiring an image of the speaker grille surface using an industrial camera, effectively filtering out impulse noise by calculating the median gray value within the pixel neighborhood, and performing size normalization to obtain a normalized image, including: Step S11: Use an industrial camera to acquire an image of the speaker mask surface, and use the method of calculating the median gray value in the neighborhood of the pixel to perform filtering processing to obtain the image after pulse noise is filtered out; Step S12: Based on the image after impulse noise filtering, adjust the processed image to a uniform size specification, and scale or crop the image to obtain a standardized image.
3. The method for identifying speaker grille defects based on visual inspection according to claim 2, characterized in that, Step S2, based on the standardized image, uses a convolutional neural network and an adaptive moment estimation mechanism to dynamically adjust the parameter learning rate to extract multi-scale feature maps of the mask texture, including: Step S21: Using standardized images as the processing object, construct a convolutional neural network as the core framework for feature extraction; Step S22: Based on the core framework of feature extraction, an adaptive moment estimation mechanism is introduced during network operation to dynamically regulate the parameter learning process in order to obtain multi-scale feature mapping.
4. The method for identifying speaker grille defects based on visual inspection according to claim 3, characterized in that, Step S3: Based on the multi-scale feature map, generate candidate defect regions using a region proposal network, including: Step S31: Based on the multi-scale feature mapping, the feature maps at different levels are fused using the feature pyramid structure to obtain the fused comprehensive features; Step S32: Based on the integrated features after fusion, candidate defect regions are screened and located through the region proposal network to generate candidate regions containing high-probability defects.
5. The method for identifying speaker grille defects based on visual inspection according to claim 4, characterized in that, Step S4: For the proposed candidate defect regions, the U-Net network is used with a learning rate to quickly approximate the optimal solution. The learning rate decreases exponentially with each iteration to stably converge to a fine local optimum. Pixel-level fine segmentation is performed on the defect boundaries to obtain the defect mask image, including: Step S41: Based on the proposed candidate defect regions, the U-Net network is used to capture the contextual information and detailed features of the image and process defect segmentation. A strategy of dynamically adjusting the learning rate is adopted to quickly approach the optimal solution. As the number of iterations increases, the learning rate decays exponentially and converges stably to a more refined local optimum. Step S42: After learning and optimization by the U-Net network, the network uses the learned features to judge each pixel in the candidate defect region, accurately delineating the boundary of the defect to generate a defect mask image.
6. The method for identifying speaker grille defects based on visual inspection according to claim 5, characterized in that, Step S5: Based on the defect mask image, the segmentation result is input into the defect classifier for defect category identification to obtain the defect classification result, including: Step S51: Based on the defect mask image, extract the morphological features of the defect region, including key indicators such as contour shape, area size, and edge smoothness, and quantify the features to form a standardized feature vector. Step S52: Input the feature vector into the preset defect classifier, compare and analyze the input defect features with the known defect type template, and identify the defect type according to the preset judgment rules to obtain a clear defect classification result.
7. The method for identifying speaker grille defects based on visual inspection according to claim 6, characterized in that, Step S6: Based on the defect classification results, the defect location and type are marked in real time on the detection visualization interface. When the defect confidence level exceeds a preset threshold, an audible and visual alarm mechanism is triggered, including: Step S61: Based on the defect classification results, extract the spatial coordinate information and category label of the defect. In the detection visualization interface, locate the specific location of the defect in the image based on the received coordinate data, and highlight it with specific graphic marks to complete the defect labeling. Step S62: Based on the completed defect labeling, extract the confidence value of each defect and compare it with the preset judgment threshold. When the confidence value of a certain defect exceeds the threshold, activate the audible and visual alarm mechanism.
8. A speaker grille defect identification system based on visual inspection, the system implementing the method as described in any one of claims 1 to 7, characterized in that, include: The acquisition module is used to acquire images of the speaker mask surface through an industrial camera, effectively filter out impulse noise by calculating the median gray value in the pixel neighborhood, and perform size normalization processing to obtain a normalized image; The processing module is used to extract multi-scale feature maps of the mask texture from the standardized image by using a convolutional neural network and dynamically adjusting the parameter learning rate through an adaptive moment estimation mechanism. Based on the multi-scale feature maps, candidate defect regions are generated through a region proposal network. For the proposed candidate defect regions, a U-Net network is used with a learning rate to quickly approximate the optimal solution. The learning rate decreases exponentially with the number of iterations to stably converge to a fine local optimum. Pixel-level fine segmentation of the defect boundaries is performed to obtain the defect mask image. Based on the defect mask image, the segmentation results are input into the defect classifier to identify the defect category and obtain the defect classification result; The trigger module is used to mark the location and type of defects in real time on the detection visualization interface based on the defect classification results, and to trigger an audible and visual alarm mechanism when the defect confidence exceeds a preset threshold.
9. A computing device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program that, when executed by a processor, implements the method as described in any one of claims 1 to 7.
Citation Information
Cited By
Bolt appearance size defect detection method based on machine vision
CN121962136A