Door and window surface tiny flaw detection method and device, electronic equipment and storage medium

By using multi-angle dark field lighting devices and high-speed image sensors on high-speed production lines, lighting parameters are adjusted in real time to optimize the signal-to-noise ratio, solving the detection problems caused by uneven LED lighting and weak reflection on matte surfaces, and achieving rapid and accurate automated detection of small defects.

CN120070831AActive Publication Date: 2025-05-30FOSHAN XINHAOXUAN SMART HOME TECH CO LTD

Patent Information

Application Number
CN202510526120.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-05-30
Estimated Expiration
2045-04-25

AI Technical Summary

Technical Problem

On high-speed production lines, traditional machine vision detection methods are difficult to achieve fast, accurate and low-cost automated detection of tiny scratches and depression defects under the conditions of uneven LED lighting and weak reflection of matte paint.

Method used

Using a multi-angle ring dark field lighting device and high-speed image sensor, lighting parameters are dynamically optimized to maximize defect signal strength through real-time signal-to-noise ratio (SNR) evaluation and adaptive lighting adjustment.

Benefits of technology

The detection rate of tiny scratches and depression defects on the matte paint surface is significantly improved, and the problem of degradation of detection performance in traditional fixed lighting methods under complex lighting conditions is overcome, and rapid, accurate, economical and efficient automated identification is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120070831A_ABST
    Figure CN120070831A_ABST
Patent Text Reader

Abstract

The invention provides a door and window surface tiny flaw detection method and device, electronic equipment and a storage medium, and relates to the technical field of door and window flaw detection. The method comprises the following steps: illuminating a component according to preset light source parameters, and synchronously acquiring an initial image; calculating an SNR value according to the initial image; comparing the SNR value with a preset SNR threshold value, and if the SNR value is lower than the SNR threshold value, adjusting a light source parameter; calculating the SNR value and adjusting the light source parameters repeatedly until the SNR value reaches the optimal level or meets a preset iteration stopping condition; and collecting a current image and carrying out defect identification and segmentation to obtain a defect detection result. According to the method for detecting the tiny flaws on the surfaces of the doors and windows, weak reflection of the matte surface and uneven LED illumination interference are overcome, and rapid, accurate, economical and efficient automatic identification of tiny scratches and sunken flaws on the surfaces of the matte paint surface wooden door parts rotating at a high speed is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of door and window defect detection, and more particularly, to a method, device, electronic device and storage medium for detecting minute defects on the surface of doors and windows. Background Art

[0002] In the modern high-end customized wooden door manufacturing industry, high-speed production lines have become the key to improving efficiency and meeting market demands. After the spraying of matte paint on wooden door components, they are quickly transferred. To ensure the surface quality of the products, the factory needs to detect defects on the paint surface.

[0003] However, for energy conservation, factories generally use LED lighting systems. This lighting method is prone to uneven illumination and shadows on matte surfaces, making it difficult for manual visual inspection to detect minute scratches and concave defects. Traditional machine vision detection methods can be applied under uniform illumination, but under the conditions of uneven LED illumination and matte weak reflection surfaces, the detection accuracy and stability are significantly reduced.

[0004] Therefore, how to overcome the limitations of uneven LED illumination and weak reflection of matte surfaces on high-speed production lines and achieve rapid, accurate, low-cost and automated detection of minute defects has become a difficult problem urgently needed to be solved in the industry. Summary of the Invention

[0005] The purpose of the present invention is to provide a method, device, electronic device and storage medium for detecting minute defects on the surface of doors and windows, which can overcome the interference of weak reflection of matte surfaces and uneven LED illumination, and achieve rapid, accurate, economical and efficient automated identification of minute scratches and concave defects on the surface of high-speed transferred matte paint wooden door components.

[0006] In a first aspect, the present invention provides a method for detecting minute defects on the surface of doors and windows, including the steps of: S1. Using a multi-angle annular dark field lighting device to illuminate a high-speed transferred matte paint wooden door component with preset light source parameters, and synchronously collecting an initial image using a high-speed image sensor; the light source parameters include illumination angle, illumination intensity or light source grouping; S2. Calculating the SNR value under the current illumination condition according to the initial image; S3. Comparing the SNR value with a preset SNR threshold. If the SNR value is lower than the SNR threshold, adjusting the light source parameters of the multi-angle annular dark field lighting device according to a preset optimization strategy; S4. Repeatedly performing the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches the optimal level or meets a preset stop iteration condition; S5. After the SNR value reaches the optimal level or meets the preset stop iteration condition, collect the current image and perform defect recognition and segmentation to obtain the defect detection result; S6. Generate a detection report according to the defect detection result.

[0007] The method for detecting minute defects on the surface of doors and windows provided by the present invention overcomes the dual challenges of uneven illumination caused by energy-saving LED lighting and weak reflection of matte paint surfaces on the high-speed matte paint production line of high-end customized wooden door factories, and realizes the automatic recognition of minute scratches and dents on the surfaces of high-speed rotating components in a faster, more accurate, more economical and more efficient manner.

[0008] Further, the specific steps in step S3 include: S31. When the SNR value is lower than the SNR threshold, use the defect classification model to identify the defect type in the current image; the defect types include scratch defects and dent defects; S32. Select an optimization strategy from the preset optimization strategy library according to the defect type; the optimization strategy library includes a first light source parameter adjustment scheme for scratch defects and a second light source parameter adjustment scheme for dent defects; S33. If the recognition result is a scratch defect, select a set of light source parameters from the first light source parameter adjustment scheme, and adjust the light source irradiation angle and light intensity of the multi-angle annular dark field lighting device according to the set of light source parameters; S34. If the recognition result is a dent defect, select a set of light source parameters from the second light source parameter adjustment scheme, and adjust the light source grouping and light intensity of the multi-angle annular dark field lighting device according to the set of light source parameters.

[0009] It realizes the refined adjustment of light source parameters for different types of defects, can more effectively improve the signal-to-noise ratio of the image, provides more favorable lighting conditions for subsequent defect detection, and finally improves the defect detection accuracy.

[0010] Further, the specific steps in step S31 include: S311. Perform preprocessing on the initial image, use Gaussian filtering to reduce noise and histogram equalization to enhance contrast to obtain the first preprocessed image; S312. Input the first preprocessed image into the defect classification model, and calculate the probability values of the first preprocessed image belonging to scratch defects and dent defects through a Softmax classifier; the defect classification model is a deep convolutional neural network containing multiple convolutional layers and pooling layers; the deep convolutional neural network is trained using a sample set containing scratch defects and dent defects, and the training of the deep convolutional neural network uses a cross-entropy loss function and an Adam optimizer; S313. Compare the probability value with a preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, determine that the defect type is a scratch defect; if the probability value of the dent defect is greater than the probability threshold, determine that the defect type is a dent defect; if the probability values of both the scratch defect and the dent defect are less than the probability threshold, determine it as other type of defect.

[0011] It realizes the accurate identification of the defect type, overcomes the problem of misjudgment of defects caused by the interference of the matte surface texture, and provides accurate defect type information for adjusting the light source parameters according to the defect type subsequently.

[0012] Further, the specific steps in step S311 include: S3111. Analyze the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, use the histogram equalization algorithm with brightness compensation to enhance the contrast and obtain a brightness-equalized image. S3112. Calculate the gradient magnitude of the brightness-equalized image, adaptively adjust the filtering parameters of the Gaussian filter according to the gradient magnitude, and perform Gaussian filtering denoising on the brightness-equalized image using the adaptively adjusted filtering parameters to obtain the first preprocessed image.

[0013] It can effectively solve the problems of uneven brightness and noise interference of the initial image, and provide a preprocessed image with higher quality for the accurate identification of the subsequent defect classification model.

[0014] Further, the defect classification model is trained through the following steps: A1. Construct a deep convolutional neural network containing multiple convolutional layers and pooling layers. A2. Construct a data set containing a scratch defect sample set, a dent defect sample set, a wood texture sample set, and a paint surface particle noise sample set. A3. Extract defect images from the scratch defect sample set and the dent defect sample set respectively, and obtain enhanced training samples by randomly superimposing wood texture images extracted from the wood texture sample set and / or paint surface particle noise images extracted from the paint surface particle noise sample set. A4. Use the enhanced training samples to train the deep convolutional neural network to obtain the defect classification model.

[0015] Further, the specific steps in step S5 include: S51. Perform preprocessing on the current image, use median filtering to remove noise, and use adaptive histogram equalization to enhance the local contrast to obtain a second preprocessed image. S52. Use the trained Mask R-CNN model to perform defect recognition and segmentation on the second preprocessed image to obtain a defect mask image; the Mask R-CNN model includes a classification branch for defect classification, a bounding box regression branch for defect localization, and a mask branch for defect pixel-level segmentation; S53. According to the defect mask image, calculate the area, perimeter, and shape factor of the defect region, and use the area, perimeter, and shape factor as defect features; S54. According to the defect features, use a support vector machine classifier to perform fine classification on the defect type to obtain a defect detection result, where the defect detection result includes the defect location, defect type, and defect features.

[0016] Further, the specific steps in step S51 include: S511. Convert the current image to the HSV color space and extract the luminance component V; S512. Use guided filtering to smooth the luminance component V to obtain a luminance background image; the guidance image of the guided filtering is the luminance component V itself, and the filtering radius of the guided filtering is adaptively adjusted according to the resolution of the current image; S513. According to the luminance background image, calculate a luminance correction coefficient, and use the luminance correction coefficient to perform luminance correction on the three RGB color channels of the current image respectively to obtain a luminance-corrected image; S514. Use median filtering to remove noise from the luminance-corrected image to obtain a third preprocessed image; S515. Divide the third preprocessed image into multiple non-overlapping image blocks, and calculate the local contrast of each image block; S516. According to the local contrast of each image block, adaptively adjust the parameters of adaptive histogram equalization, and use the adaptively adjusted parameters to perform histogram equalization processing on each image block to obtain the second preprocessed image.

[0017] In a second aspect, the present invention provides a device for detecting minute defects on the surface of doors and windows, including: A control module, configured to use a multi-angle annular dark-field lighting device to illuminate a matte-painted wooden door component rotating at high speed with preset light source parameters, and use a high-speed image sensor to synchronously collect an initial image; the light source parameters include the irradiation angle, light intensity, or light source grouping; A calculation module, configured to calculate the SNR value under the current lighting conditions according to the initial image; A comparison module for comparing the SNR value with a preset SNR threshold. If the SNR value is lower than the SNR threshold, the light source parameters of the multi-angle annular dark-field illumination device are adjusted according to a preset optimization strategy; An adjustment module for repeatedly performing the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches the optimal level or meets a preset stop iteration condition; An identification module for collecting a current image and performing defect identification and segmentation to obtain a defect detection result after the SNR value reaches the optimal level or meets a preset stop iteration condition; A generation module for generating a detection report according to the defect detection result for quality monitoring and production traceability.

[0018] The device for detecting minute surface defects of doors and windows provided by the present invention realizes the adaptive optimization of the lighting conditions through SNR value feedback and iterative adjustment of the light source parameters, improves the stability and effectiveness of detecting minute surface defects of doors and windows under different lighting conditions, and solves the technical problem that the detection effect is easily affected by the lighting conditions.

[0019] In a third aspect, the present invention provides an electronic device, including a processor and a memory. The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method for detecting minute surface defects of doors and windows provided in the first aspect above are run.

[0020] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the method for detecting minute surface defects of doors and windows provided in the first aspect above are run.

[0021] As can be seen from the above, in the method for detecting minute surface defects of doors and windows provided by the present invention, through real-time signal-to-noise ratio evaluation and adaptive lighting adjustment, the system can dynamically optimize the lighting parameters, maximize the defect signal intensity, significantly improve the detection rate of minute scratches and dents on the matte paint surface, and overcome the problem of the decline in detection performance of the traditional fixed lighting method under complex lighting conditions; by using a high-speed image sensor and an optimized image processing algorithm, the adaptive lighting adjustment process is fast and efficient, can meet the rhythm requirements of a high-speed production line, and realizes real-time on-line detection; in addition, the high-quality image after SNR optimization reduces the false detection rate and missed detection rate of the defect detection algorithm, ensures the detection accuracy, and improves the surface quality of the products of high-end customized wooden doors; finally, the optimization adjustment of the lighting parameters is automatically completed without manual intervention, reduces the operation difficulty and labor cost, and improves the intelligent level of the detection system.

[0022] Other features and advantages of the present invention will be described in the subsequent specification, and in part, will be obvious from the specification, or can be understood by implementing the embodiments of the present invention. The objectives and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written specification and the drawings. Description of the Drawings

[0023] Figure 1 It is a flowchart of a method for detecting minute defects on the surface of doors and windows provided by an embodiment of the present invention.

[0024] Figure 2 It is a schematic structural diagram of a device for detecting minute defects on the surface of doors and windows provided by an embodiment of the present invention.

[0025] Figure 3 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.

[0026] Label Description: 100, control module; 200, calculation module; 300, comparison module; 400, adjustment module; 500, recognition module; 600, generation module; 13, electronic device; 1301, processor; 1302, memory; 1303, communication bus. Detailed Embodiments

[0027] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Usually, the components of the embodiments of the present invention described and illustrated in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the present invention to be protected, but only represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.

[0028] It should be noted that: similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.

[0029] Referring to the attached Figure 1 drawings, the present invention provides a method for detecting minute defects on the surface of doors and windows, including the steps of: S1. Use a multi-angle annular dark-field illumination device to illuminate the matte painted wooden door parts rotating at high speed with preset light source parameters, and synchronously collect the initial images using a high-speed image sensor; the light source parameters include the irradiation angle, light intensity, or light source grouping. S2. Calculate the SNR value (SNR stands for signal-to-noise ratio) under the current illumination conditions based on the initial images. S3. Compare the SNR value with the preset SNR threshold. If the SNR value is lower than the SNR threshold, adjust the light source parameters of the multi-angle annular dark-field illumination device according to the preset optimization strategy. S4. Repeat the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches the optimal level or meets the preset stop iteration condition. S5. After the SNR value reaches the optimal level or meets the preset stop iteration condition, collect the current images and perform defect recognition and segmentation to obtain the defect detection results. S6. Generate a detection report based on the defect detection results.

[0030] In step S1, the multi-angle annular dark-field illumination device is used to provide adjustable illumination. The selection of light source parameters includes adjusting the irradiation angle to adapt to different surface reflection characteristics, adjusting the light intensity to optimize the image contrast, or adjusting the light source grouping to change the illumination mode.

[0031] In step S2, the SNR value, as a quantitative index of image quality, is used to evaluate the ratio of the intensity of the defect signal to the noise level under the current illumination conditions.

[0032] Steps S3 and S4 constitute an iterative optimization process. By comparing the SNR value with the preset SNR threshold, it is judged whether the current image quality meets the detection requirements. If not, the light source parameters are adjusted according to the preset optimization strategy, and the steps of calculating the SNR value and adjusting the light source parameters are repeated until the SNR value reaches the optimal or meets the stop iteration condition. This iterative adjustment ensures that the illumination conditions can be adaptively optimized to meet the defect detection requirements of different types and degrees.

[0033] In step S5, after the illumination conditions are optimized, images are collected and defect recognition and segmentation are performed to obtain high-quality defect detection results.

[0034] In step S6, the generated detection report provides data support for quality monitoring and production traceability.

[0035] Specifically, the present application provides a method for detecting minute defects on the surface of doors and windows. This method first uses a multi-angle annular dark-field lighting device and a high-speed image sensor to illuminate and collect images of the matte paint surface wooden door components flowing at high speed. By calculating the SNR value of the initial image, the image quality under the current lighting conditions is evaluated. If the SNR value is lower than the preset threshold, the light source parameters of the multi-angle annular dark-field lighting device are adjusted according to the preset optimization strategy, and the iterative process of calculating the SNR value and adjusting the light source parameters is repeated until the SNR value reaches the optimal level or meets the preset iteration stop condition. When the SNR value meets the requirements, the current image is collected and defect recognition and segmentation are performed to obtain the defect detection result, and a detection report is generated for quality monitoring and production traceability. Through the feedback of the SNR value and the iterative adjustment of the light source parameters, this solution realizes the adaptive optimization of the lighting conditions, improves the stability and effectiveness of detecting minute defects on the surface of doors and windows under different lighting conditions, and solves the technical problem that the detection effect is easily affected by the lighting conditions.

[0036] In some specific embodiments, the multi-angle annular dark-field lighting device can be composed of multiple LED light sources. These LED light sources are divided into several groups, and the irradiation angle and light intensity of each group of LED light sources can be independently adjusted. The preset light source parameters can be a set of empirical parameters. For example, the initial irradiation angle is set to 45 degrees, the light intensity is set to medium, and the light source grouping is set to full group lighting. The signal-to-noise ratio SNR threshold can be set according to actual detection requirements. For example, it is set to 20 dB. The preset optimization strategy can be a look-up table, which stores the light source parameter adjustment schemes corresponding to different SNR value ranges. The iteration stop condition can be the maximum number of iterations. For example, it is set to 5 times. When the SNR value still does not reach the optimal level after multiple iterative adjustments, or when the maximum number of iterations is reached, the iterative process is stopped. Defect recognition and segmentation can use traditional image processing algorithms, such as threshold segmentation, edge detection, etc., or can also use deep learning algorithms, such as convolutional neural networks.

[0037] In certain embodiments, the specific steps in step S3 include: S31. When the SNR value is lower than the SNR threshold, use the defect classification model to identify the defect type in the current image; the defect types include scratch defects and depression defects; S32. Select an optimization strategy from the preset optimization strategy library according to the defect type; the optimization strategy library includes a first light source parameter adjustment scheme for scratch defects and a second light source parameter adjustment scheme for depression defects; S33. If the recognition result is a scratch defect, select a set of light source parameters from the first light source parameter adjustment scheme, and adjust the light source irradiation angle and light intensity of the multi-angle annular dark-field lighting device according to this set of light source parameters; S34. If the recognition result is a concave defect, select a set of light source parameters from the second light source parameter adjustment scheme, and adjust the light source grouping and light intensity of the multi-angle annular dark-field illumination device according to this set of light source parameters.

[0038] In step S31, the defect classification model is used to identify the type of defect in the image. As a possible implementation, the defect classification model can be a deep convolutional neural network model, which takes the initial image as input and outputs the type of defect in the image, such as a scratch defect or a concave defect.

[0039] In step S32, the preset optimization strategy library can be a look-up table that stores the optimization strategies corresponding to different defect types. When the defect type is identified, the system can search for and select the corresponding optimization strategy in the optimization strategy library.

[0040] Steps S33 and S34 describe the light source parameter adjustment schemes for different defect types. Specifically, for scratch defects, the first light source parameter adjustment scheme can include the specific parameter values or adjustment ranges for adjusting the light source irradiation angle and light intensity of the multi-angle annular dark-field illumination device. For example, the irradiation angle can be increased to more effectively highlight the scratch defect, and at the same time, the light intensity can be adjusted to optimize the image quality. Similarly, for concave defects, the second light source parameter adjustment scheme can include the specific parameter values or adjustment ranges for adjusting the light source grouping and light intensity. For example, the light source grouping can be adjusted to change the light direction, so as to better reveal the concave defect, and the light intensity can be adjusted to obtain a better image signal-to-noise ratio. Thus, through steps S31 to S34, it is possible to adaptively adjust the light source parameters of the multi-angle annular dark-field illumination device according to different defect types, and further provide more favorable lighting conditions for subsequent defect detection.

[0041] Specifically, when the SNR value of the initial image is lower than the preset SNR threshold, it indicates that the current lighting conditions may not be conducive to the effective detection of defects. To improve the image quality and defect detection accuracy, it is necessary to optimize and adjust the light source parameters. Different types of defects, such as scratch defects and depression defects, have different visual characteristics in the image and different requirements for lighting conditions. Scratch defects usually show linear brightness or color differences and are more sensitive to the lighting angle and intensity; depression defects may show shadows or deformations and are more sensitive to the lighting direction and grouping. Therefore, using a general light source parameter adjustment strategy may not achieve the optimal SNR improvement effect for all types of defects. In this solution, by introducing a defect classification model, the type of defect in the current image is first identified to distinguish between scratch defects and depression defects. Then, according to the identified defect type, the corresponding optimization strategy is selected from the preset optimization strategy library, which pre-stores the differential light source parameter adjustment schemes for scratch defects and depression defects. For scratch defects, the irradiation angle and light intensity are adjusted, and for depression defects, the light source grouping and light intensity are adjusted. Thus, the refined adjustment of light source parameters for different types of defects is realized, which can more effectively improve the image SNR, provide more favorable lighting conditions for subsequent defect detection, and ultimately improve the defect detection accuracy.

[0042] In some specific embodiments, it is assumed that in step S3, the calculated SNR value is lower than the preset SNR threshold. The system first executes step S31 to identify the defect type of the current image using a pre-trained defect classification model. For example, the defect classification model identifies the defect type in the current image as a scratch defect. Subsequently, in step S32, the system selects the first light source parameter adjustment scheme corresponding to the scratch defect from the preset optimization strategy library according to the type of the scratch defect. The first light source parameter adjustment scheme can be preset as follows: increase the irradiation angle of the multi-angle annular dark field illumination device by 5 degrees and increase the light intensity by 10%. Then, in step S33, the system controls the multi-angle annular dark field illumination device according to the selected first light source parameter adjustment scheme, adjusts its irradiation angle to the angle value after increasing by 5 degrees, and adjusts its light intensity to the intensity value after increasing by 10%. Conversely, if the defect classification model identifies the defect type as a dent defect in step S31, then in step S32, the system will select the second light source parameter adjustment scheme corresponding to the dent defect. The second light source parameter adjustment scheme can be preset as follows: adjust the light source grouping of the multi-angle annular dark field illumination device to turn on group A and group B simultaneously, and reduce the light intensity by 5%. In step S34, the system will adjust the light source grouping and the light intensity according to the second light source parameter adjustment scheme. Through the above embodiments, differential light source parameter adjustment can be realized according to different defect types, so as to more effectively improve the image signal-to-noise ratio and the accuracy of defect detection. Thus, by specifically adjusting the light source parameters, the defect features can be more effectively highlighted, the image signal-to-noise ratio can be improved, and further the accuracy and reliability of defect detection can be enhanced.

[0043] In some embodiments, the specific steps in step S31 include: S311. Perform preprocessing on the initial image, use Gaussian filtering to reduce noise and histogram equalization to enhance contrast, and obtain the first preprocessed image; S312. Input the first preprocessed image into the defect classification model, and calculate the probability values that the first preprocessed image belongs to the scratch defect and the dent defect through a Softmax classifier; the defect classification model includes a deep convolutional neural network with multiple convolutional layers and pooling layers; the deep convolutional neural network is trained using a sample set including scratch defects and dent defects, and the training of the deep convolutional neural network uses a cross-entropy loss function and an Adam optimizer; S313. Compare the probability values with the preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, it is determined that the defect type is a scratch defect; if the probability value of the dent defect is greater than the probability threshold, it is determined that the defect type is a dent defect; if the probability values of both the scratch defect and the dent defect are less than the probability threshold, it is determined as other types of defects.

[0044] For the preprocessing of the initial image, Gaussian filtering is used to reduce image noise, reduce the interference of texture and granular noise on defect detection, and improve image quality. Histogram equalization is used to enhance image contrast, making the defect features in the image more obvious and facilitating subsequent defect recognition. The defect classification model is a deep convolutional neural network, and this network structure can automatically extract deep features in the image to achieve accurate classification of defect types. The multiple convolutional layers included in the network are used to extract local features of the image, and the pooling layer is used to reduce the dimension of the feature map, reduce the computational amount, and improve the robustness of the model. The Softmax classifier is set at the output layer of the network to convert the network output into probability values of the image belonging to different defect types, facilitating classification decision-making. The training dataset of the deep convolutional neural network includes a scratch defect sample set and a dent defect sample set. Through the learning of a large number of samples, the network can effectively identify these two types of defects. The cross-entropy loss function is used to measure the gap between the model prediction result and the true label, and the Adam optimizer is used to optimize the network parameters, accelerate model convergence, and improve training efficiency and model performance. A probability threshold is preset to determine the defect type. By comparing the defect probability value with the probability threshold, scratches and dents can be effectively distinguished. When the probability value of a scratch or dent exceeds the corresponding threshold, it is determined as the corresponding defect type. For the case where the probability values are all lower than the threshold, it is determined as other types of defects, considering the possible unknown defect types in practical applications and improving the adaptability and reliability of the detection system.

[0045] Specifically, aiming at the problem that the surface texture of the matte painted wooden door components may interfere with defect recognition, the initial images collected are first preprocessed. In the preprocessing step, Gaussian filtering is used to denoise the images, smoothing the noise and fine textures in the images to reduce the interference of the textures on the extraction of defect features. At the same time, the histogram equalization method is used to enhance the contrast of the images, increasing the gray-scale difference between the defects and the background in the images and making the defect features more prominent. The first preprocessed image obtained after preprocessing has reduced noise and enhanced contrast, which is more conducive to subsequent defect classification. Then, the first preprocessed image is input into a pre-trained defect classification model. This model is a deep convolutional neural network that has learned the feature representations of scratch defects and dent defects after being trained with a large number of scratch defect and dent defect samples. Through the Softmax classifier, the model outputs the probability values of the image belonging to scratch defects and dent defects. By comparing the probability values of scratch defects and dent defects with a preset probability threshold, the determination of the defect type is carried out. If the probability value of the scratch defect is greater than the probability threshold, it is considered that the defect existing in the image is a scratch defect; if the probability value of the dent defect is greater than the probability threshold, it is considered that the defect existing in the image is a dent defect; if the probability values of both are less than the probability threshold, it is determined as other types of defects. Thus, the accurate recognition of the defect type is achieved, overcoming the problem of misjudgment of defects caused by the interference of the matte surface texture and providing accurate defect type information for subsequent adjustment of the light source parameters according to the defect type.

[0046] In some specific embodiments, the filter kernel size of the Gaussian filter is set to 3x3, and the standard deviation is set to 0.5 to achieve an effective noise reduction effect while retaining the detailed information of the images as much as possible. The histogram equalization adopts the global histogram equalization algorithm to enhance the overall contrast of the images. The deep convolutional neural network includes 3 convolutional layers and 2 pooling layers, the filter kernel sizes of which are all 3x3, and the activation functions are all ReLU functions. The Softmax classifier outputs the probability values of scratch defects, dent defects, and other types of defects. The probability threshold is set to 0.8, that is, when the probability value of the scratch defect or the dent defect is greater than 0.8, it is determined as the corresponding defect type. The training data set includes 1000 scratch defect sample images and 1000 dent defect sample images. During the training process, the cross-entropy loss function is used to calculate the error between the model prediction value and the true value, the Adam optimizer is used to update the network weights, the learning rate is set to 0.001, and the number of training epochs is set to 50. Through the above parameter settings and training process, the defect classification model can accurately identify the scratch defects and dent defects on the surface of the matte painted wooden door components, providing reliable defect type information for subsequent adjustment of the light source parameters.

[0047] In certain embodiments, the specific steps in step S311 include: S3111. Analyze the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, then use the histogram equalization algorithm with brightness compensation to enhance the contrast and obtain a brightness equalized image. S3112. Calculate the gradient magnitude of the brightness equalized image, adaptively adjust the filtering parameters of the Gaussian filter according to the gradient magnitude, and perform Gaussian filtering and noise reduction on the brightness equalized image using the adaptively adjusted filtering parameters to obtain a first preprocessed image.

[0048] In step S3111, the brightness distribution analysis can specifically be to calculate the brightness mean and brightness standard deviation of the initial image. The brightness mean reflects the overall brightness level of the image, and the brightness standard deviation reflects the degree of dispersion of the image brightness distribution. To determine that the brightness distribution is uneven, a threshold for the brightness standard deviation can be set. When the brightness standard deviation exceeds the threshold, it is determined that the brightness distribution is uneven. The histogram equalization algorithm with brightness compensation will consider the local brightness information of the image when performing histogram equalization, and perform brightness compensation on areas that are too dark or too bright to avoid over-enhancing the contrast of the uneven brightness areas.

[0049] In step S3112, the gradient magnitude can be obtained by calculating the gradients of the brightness equalized image in the horizontal and vertical directions, such as using the Sobel operator or the Prewitt operator. The gradient magnitude can reflect the richness of image details and the noise level. The adaptive adjustment of the Gaussian filter parameters can be performed according to the statistical characteristics of the gradient magnitude, such as calculating the mean or variance of the gradient magnitude. When the gradient magnitude is relatively high, it indicates that there are more details or less noise in the image. At this time, smaller Gaussian filter parameters can be selected to retain more image details; when the gradient magnitude is relatively low, it indicates that there are fewer details or more noise in the image. At this time, larger Gaussian filter parameters can be selected to enhance the noise reduction effect of the image. The Gaussian filter parameters can include the size and standard deviation of the filter.

[0050] Specifically, for the case of uneven initial image brightness distribution and varying noise levels, step S311 first analyzes the brightness distribution of the initial image to determine whether the brightness is uniform. If the brightness distribution is uneven, a histogram equalization algorithm with brightness compensation is used to enhance the image contrast while reducing the impact of uneven brightness. Thus, a brightness-equalized image is obtained. Then, the gradient magnitude of the brightness-equalized image is calculated. The gradient magnitude can reflect the detail information and noise level of the image. According to the magnitude of the gradient, the filtering parameters of the Gaussian filter are adaptively adjusted. When the gradient magnitude is high, smaller Gaussian filtering parameters are used to retain more detail information of the image. When the gradient magnitude is low, larger Gaussian filtering parameters are used to enhance the noise reduction ability of the image. The brightness-equalized image is Gaussian filtered and denoised using the adaptively adjusted filtering parameters to obtain the first preprocessed image. Through the above steps, the problems of uneven initial image brightness and noise interference can be effectively solved, providing a preprocessed image with higher quality for the accurate identification of the subsequent defect classification model.

[0051] In some specific embodiments, the determination threshold for uneven brightness distribution can be set to a brightness standard deviation of 30. The histogram equalization algorithm with brightness compensation can adopt the contrast-limited adaptive histogram equalization algorithm. The gradient magnitude is calculated using the Sobel operator. The specific method for adaptively adjusting the Gaussian filter parameters can be that when the mean of the gradient magnitude is greater than 50, the size of the Gaussian filter is selected as 3×3 and the standard deviation is selected as 0.5. When the mean of the gradient magnitude is less than or equal to 50, the size of the Gaussian filter is selected as 5×5 and the standard deviation is selected as 1.0. Through the setting of the above specific parameters, effective contrast enhancement and adaptive noise reduction of the uneven brightness image can be achieved, improving the accuracy of subsequent defect classification. Using the histogram equalization algorithm with brightness compensation can avoid the problem of over-enhancing noise in uneven brightness images by traditional histogram equalization, making the image maintain relative uniformity of brightness distribution while enhancing the contrast. Adaptively adjusting the Gaussian filter parameters according to the gradient magnitude can achieve a balance between noise reduction and detail retention, enabling the preprocessed image to effectively remove noise and retain the detail features of the defects as much as possible, providing a strong guarantee for the accurate identification of the subsequent defect classification model.

[0052] In certain embodiments, the defect classification model is trained through the following steps: A1. Construct a deep convolutional neural network containing multiple convolutional layers and pooling layers; A2. Construct a dataset containing a scratch defect sample set, a dent defect sample set, a wood texture sample set, and a paint particle noise sample set; A3. Defect images are respectively extracted from the scratch defect sample set and the dent defect sample set, and enhanced training samples are obtained by randomly superimposing wood texture images extracted from the wood texture sample set and / or paint surface particle noise images extracted from the paint surface particle noise sample set. A4. The enhanced training samples are used to train a deep convolutional neural network to obtain a defect classification model.

[0053] In step A1, the construction of the deep convolutional neural network is performed, and the network structure includes multiple convolutional layers and pooling layers. The convolutional layers are configured to extract the spatial features of the images, and the pooling layers are configured to reduce the resolution of the feature maps, reduce the computational complexity, and enhance the translational invariance of the features. The stacking of multiple convolutional layers and pooling layers enables the network to gradually extract the abstract features from shallow to deep in the images, thereby improving the accuracy of the model in classifying defect types.

[0054] In step A2, the construction of the data set is performed, and the data set includes a scratch defect sample set, a dent defect sample set, a wood texture sample set, and a paint surface particle noise sample set. The scratch defect sample set and the dent defect sample set respectively include various types of scratch defect and dent defect images, which are used to train the model to identify different types of defects. The wood texture sample set and the paint surface particle noise sample set include defect-free wood texture images and paint surface particle noise images, which are used to simulate the interference factors that may exist in the actual industrial scenario and improve the robustness of the model.

[0055] In step A3, the generation of enhanced training samples is performed. Defect images are respectively extracted from the scratch defect sample set and the dent defect sample set, and are superimposed with the images randomly extracted from the wood texture sample set and / or the paint surface particle noise sample set, so as to simulate the situation where defects and wood textures or paint surface noises appear simultaneously, increase the diversity of the training samples, and improve the generalization ability of the model.

[0056] In step A4, the training of the defect classification model is performed. The enhanced training samples are input into the constructed deep convolutional neural network for training. The cross-entropy loss function is used in the training process to measure the gap between the model prediction result and the true label, and the Adam optimizer is used to optimize the network parameters to minimize the loss function, and finally the trained defect classification model is obtained. Thus, through steps such as constructing a deep convolutional neural network, constructing a data set containing multiple samples, generating enhanced training samples, and using the enhanced training samples to train the deep convolutional neural network, the defect classification model can be effectively trained.

[0057] Specifically, the training method of the defect classification model aims to solve the problem of how to obtain a classification model for identifying defect types. In view of the lack of effective methods for training defect classification models in the prior art, this solution proposes a training method for defect classification models based on deep learning. The method first constructs a deep convolutional neural network, which is good at image feature extraction and classification tasks. Then, a dataset containing various types of samples is constructed, and the sample types cover the defect types to be identified and possible interference factors, ensuring the comprehensiveness and representativeness of the training data. To further improve the robustness and generalization ability of the model, a method for generating enhanced training samples is also proposed. By superimposing defect images on background noise images, the situation where defects may appear simultaneously with noise in the real scene is simulated. Finally, the generated enhanced training samples are used to train the deep convolutional neural network, and by optimizing the network parameters, the final defect classification model is obtained. The trained defect classification model can accurately identify the defect types in the image, providing reliable classification results for subsequent light source parameter optimization and defect detection.

[0058] In some specific embodiments, the deep convolutional neural network can adopt the ResNet-50 network structure, which has deeper network layers and residual connections, can effectively extract the deep features of the image, and alleviate the problem of gradient disappearance. The dataset can include 1000 scratch defect images, 1000 dent defect images, 500 wood texture images, and 500 paint surface particle noise images. When generating enhanced training samples, wood texture images or paint surface particle noise images can be randomly selected and superimposed on the defect images, and the transparency of the superimposition can be set between 0.3 and 0.7. During training, the Adam optimizer can be used, the learning rate can be set to 0.001, the batch size can be set to 32, and the training epoch can be set to 100. Through the above specific embodiments, a high-performance defect classification model can be obtained, which can accurately identify scratch defects and dent defects on the surface of matte paint wooden door components, providing support for subsequent defect detection.

[0059] In certain embodiments, the specific steps in step S5 include: S51. Preprocess the current image, use median filtering to remove noise, and use adaptive histogram equalization to enhance local contrast to obtain a second preprocessed image; S52. Use the trained Mask R-CNN model (i.e., the mask region convolutional neural network model) to perform defect recognition and segmentation on the second preprocessed image to obtain a defect mask image; The Mask R-CNN model includes a classification branch for defect classification, a bounding box regression branch for defect localization, and a mask branch for defect pixel-level segmentation; S53. Calculate the area, perimeter, and shape factor of the defect region based on the defect mask image, and use the area, perimeter, and shape factor as defect features; S54. Based on the defect features, use a support vector machine classifier to perform fine classification on the defect types to obtain the defect detection results, where the defect detection results include the defect location, defect type, and defect features.

[0060] In step S51, preprocess the current image. Specifically, use median filtering technology to remove image noise, and to enhance the local contrast of the image, use adaptive histogram equalization technology. Thus, a second preprocessed image with higher quality can be obtained, laying a foundation for subsequent defect recognition and segmentation.

[0061] In step S52, use the Mask R-CNN model to perform defect recognition and segmentation on the second preprocessed image. The Mask R-CNN model is pre-trained and can perform object detection and instance segmentation tasks simultaneously. The model includes a classification branch for initially identifying the defect type, a bounding box regression branch for accurately locating the position of the defect in the image, and a mask branch for achieving pixel-level segmentation of the defect, thereby obtaining an accurate defect mask image.

[0062] In step S53, based on the defect mask image obtained in step S52, calculate defect features such as the area, perimeter, and shape factor of the defect region. The area feature reflects the size of the defect, the perimeter feature describes the contour length of the defect, and the shape factor characterizes the regularity of the defect shape. These defect features can provide a quantitative basis for the fine classification of defects and quality monitoring.

[0063] In step S54, based on the defect features extracted in step S53, a support vector machine classifier is used to perform fine classification on the defect types. The support vector machine classifier is an effective classification algorithm that can achieve accurate classification of defect types based on defect features. The final defect detection results include detailed information such as the defect location, defect type, and defect features, which can meet the requirements of quality monitoring and production traceability.

[0064] Specifically, after completing the signal-to-noise ratio optimization, the currently acquired image first enters step S51 for preprocessing. The use of a median filter effectively reduces the noise in the image, such as salt-and-pepper noise. It eliminates isolated noise points and smooths the image by replacing the value of a pixel with the median of the gray values in its pixel neighborhood. Adaptive histogram equalization adaptively adjusts the histogram according to the local characteristics of different regions of the image, enhancing the local contrast of the image and making the defects that were originally difficult to distinguish more obvious. After the second preprocessed image undergoes preprocessing, the image quality is improved, providing a clearer input for subsequent defect recognition and segmentation. Subsequently, in step S52, the second preprocessed image is fed into a pre-trained Mask R-CNN model. The Mask R-CNN model, leveraging its powerful feature extraction ability and multi-task processing ability, can accurately identify the defects in the image and simultaneously provide the category, location, and pixel-level segmentation results of the defects. The classification branch initially determines whether the defect is a scratch, a dent, or other types. The bounding box regression branch determines the position of the circumscribed rectangle of the defect, and the mask branch generates a mask that is precisely aligned with the defect area, thereby achieving precise segmentation of the defect. In step S53, based on the defect mask image, characteristic parameters such as the area, perimeter, and shape factor of the defect are calculated. The area can directly reflect the size of the defect, the perimeter can describe the complexity of the defect contour, and the shape factor can quantify the regularity of the defect shape. For example, the shape factor of a circular defect is close to 1, while that of a long and narrow defect is smaller. These characteristic parameters provide a quantitative basis for subsequent fine classification of defects. Finally, in step S54, the extracted defect features are input into a support vector machine classifier. The support vector machine classifier can effectively perform fine classification of defect types by constructing an optimal classification hyperplane. For example, it can distinguish different types of scratches or dents, or further subdivide the defects into different grades. The final defect detection results not only include the position and preliminary type of the defect in the image but also feature descriptions such as area, perimeter, and shape factor, as well as the fine defect type given by the support vector machine classifier. These detailed detection results provide comprehensive data support for product quality monitoring and production process traceability.

[0065] In some specific embodiments, to more clearly demonstrate the technical solution, a specific embodiment is provided. In step S51, the median filter specifically uses a 3x3 filtering window, and the adaptive histogram equalization performs local histogram equalization on image blocks of size 8x8, and the contrast limit parameter is set to 0.03 to avoid over-enhancing noise. In step S52, the Mask R-CNN model uses ResNet50 as the backbone network to extract image features. During the training process, a dataset containing images of scratched defects, dented defects, and normal wooden door surfaces is used for training. The optimizer selects Adam, and the learning rate is set to 0.001. In step S53, the area of the defect region is obtained by counting the number of defect pixels in the defect mask image, the perimeter is obtained by extracting the defect contour pixels through the chain code tracking algorithm and calculating the contour length, and the shape factor is calculated through the area and perimeter. In step S54, the support vector machine classifier selects a linear kernel function and uses the area, perimeter, and shape factor calculated in step S53 as feature vectors for training to achieve fine classification of defect types. For example, scratched defects are further subdivided into minor scratches, moderate scratches, and severe scratches, etc.

[0066] In certain embodiments, the specific steps in step S51 include: S511. Convert the current image to the HSV color space and extract the brightness component V; S512. Smooth the brightness component V using guided filtering to obtain a brightness background image; the guidance image of the guided filtering is the brightness component V itself, and the filtering radius of the guided filtering is adaptively adjusted according to the resolution of the current image; S513. Calculate the brightness correction coefficient according to the brightness background image, and use the brightness correction coefficient to perform brightness correction on the three RGB color channels of the current image respectively to obtain a brightness-corrected image; S514. Remove noise from the brightness-corrected image using median filtering to obtain a third preprocessed image; S515. Divide the third preprocessed image into multiple non-overlapping image blocks and calculate the local contrast of each image block; S516. According to the local contrast of each image block, adaptively adjust the parameters of the adaptive histogram equalization, and use the adaptively adjusted parameters to perform histogram equalization processing on each image block to obtain a second preprocessed image.

[0067] In step S511, the current image is converted to the HSV color space and the brightness component V is extracted. This achieves the separation of the image brightness information and color information, enabling subsequent brightness processing to focus on the brightness component and avoiding color information interference.

[0068] In step S512, guided filtering is used to smooth the brightness component V, thereby obtaining a brightness background image. Guided filtering can effectively smooth the image while maintaining the edge information of the image. The brightness component V itself is used as the guided image, and the filter radius is adaptively adjusted according to the image resolution. The brightness background of the image can be estimated more accurately, providing a basis for subsequent brightness correction.

[0069] In step S513, a brightness correction coefficient is calculated based on the brightness background image. The coefficient is used to perform brightness correction on the three RGB color channels of the current image. The uneven brightness in the image can be weakened or eliminated, and the image brightness distribution is more uniform, creating more favorable lighting conditions for subsequent defect detection.

[0070] In step S514, after brightness correction, median filtering is used to remove image noise. Median filtering is very effective in removing impulse noise, and image quality can be further improved. Performing median filtering after brightness correction can avoid the adverse effect of noise on the brightness correction effect.

[0071] In steps S515 and S516, adaptive histogram equalization is introduced. The image is first divided into multiple non-overlapping image blocks, and the local contrast of each image block is calculated. Then, the parameters of the adaptive histogram equalization are adaptively adjusted according to the local contrast, and histogram equalization is performed on each image block. This local adaptive histogram equalization method can perform targeted enhancement according to the contrast conditions of different areas of the image, avoiding the problem of over-enhancement or under-enhancement that may be caused by global histogram equalization, and more effectively improving the local contrast of the image. The defect features are more obvious, which is more conducive to subsequent defect recognition and segmentation.

[0072] Specifically, to address the problems of uneven LED illumination and low image brightness and contrast caused by the reflection characteristics of the matte surface in the surface defect detection of matte painted wooden door components, in this embodiment, the image is first converted from the RGB color space to the HSV color space, and the V component is extracted to separate the brightness information. Then, a guided filter is used to smooth the V component to obtain a brightness background image. The guided filter can preserve edge information and adaptively adjust the filter radius according to the image resolution to accurately estimate the background brightness. Based on the brightness background image, a brightness correction coefficient is calculated and applied to the RGB channels to achieve image brightness correction and reduce the impact of uneven illumination. Next, median filtering is used to remove image noise and further improve the image quality. Finally, the image is divided into small blocks, the local contrast is calculated, and local histogram equalization is performed adaptively to enhance the local contrast and highlight the defect features. Through the above steps, the problem of uneven image brightness is effectively solved, the image contrast and quality are improved, providing high-quality image input for the subsequent Mask R-CNN model to perform defect recognition and segmentation, and the accuracy and robustness of the entire defect detection system are improved.

[0073] In some specific embodiments, for a wooden door surface image with a resolution of 1920x1080, the filter radius of the guided filter is set to 1 / 500 of the image resolution, i.e., 3 pixels. The median filter uses a 3x3 filter kernel. In adaptive histogram equalization, the image is divided into image blocks of 64x64 pixels in size. The local contrast is obtained by calculating the standard deviation of the pixel gray values within each image block. The clipLimit parameter of the adaptive histogram equalization is adaptively adjusted according to the local contrast. The specific adjustment strategy is as follows: when the local contrast is lower than the preset threshold, the clipLimit parameter is set to 2; when the local contrast is higher than the preset threshold, the clipLimit parameter is set to 1. Through the above parameter settings, the effect and efficiency of image preprocessing can reach an optimal balance.

[0074] In certain embodiments, the specific steps in step S53 include: S531. According to the defect mask image, extract the set of pixel coordinates of the defect area; S532. Calculate the minimum bounding rectangle of the set of pixel coordinates, and use the area of the minimum bounding rectangle as the area of the defect area; S533. According to the defect mask image, use the chain code tracking algorithm to extract the edge pixel coordinates of the defect area from the set of pixel coordinates, and calculate the length of the edge pixel coordinates to obtain the perimeter of the defect area; S534. Calculate the shape factor of the defect area based on the area and perimeter of the defect area.

[0075] For the extraction of the pixel coordinate set, a contour extraction algorithm can be used, such as the findContours function in the OpenCV library, to find the pixel set representing the defect area from the defect mask image. In terms of calculating the minimum bounding rectangle, the minimum area bounding rectangle algorithm can be adopted, with the aim of finding the rectangle with the smallest area that encloses the defect pixel set. One implementation method is to use the rotating calipers algorithm to effectively calculate the minimum bounding rectangle. The specific implementation process of the chain code tracking algorithm can be as follows: First, determine the starting edge pixel of the defect area, then search for adjacent edge pixels in a certain direction and record the direction information of the edge pixels to form a chain code. By analyzing the chain code, the edge pixel coordinates of the defect area can be obtained. The shape factor is calculated based on the two parameters of area and perimeter.

[0076] Specifically, after obtaining the defect mask image, first, the defect mask image is input into the contour extraction module to extract the pixel coordinate set that constitutes the defect area. Then, these pixel coordinate sets are sent to the minimum bounding rectangle calculation module to calculate the minimum rectangle that encloses the defect area, and the area of this minimum rectangle is determined as the area of the defect area. At the same time, the defect mask image is also sent to the chain code tracking module, which uses the chain code tracking algorithm to trace along the edge of the defect area, extract the coordinates of the edge pixels, and obtain the perimeter of the defect area by calculating the length of these coordinates. Finally, these two values of area and perimeter are input into the shape factor calculation module to calculate the shape factor according to the preset formula. Thus, the defect feature parameters such as the area, perimeter, and shape factor of the defect area are accurately calculated, providing reliable data support for the subsequent fine classification of defects.

[0077] In some specific embodiments, assuming that there is a defect area in the defect mask image, the contour extraction algorithm first extracts the set of pixel coordinates of the defect area. For example, the pixel coordinates {(10, 20), (11, 21), (12, 22),..., (30, 40)} are obtained. Then, the minimum bounding rectangle algorithm calculates the minimum rectangle enclosing these pixels. Assuming that the area of the calculated minimum bounding rectangle is 200 pixel units, the defect area is determined to be 200. The chain code tracking algorithm tracks along the edge pixels of the defect area. Assuming that the length of the calculated edge pixel coordinates is 60 pixel units, the defect perimeter is determined to be 60. Finally, the shape factor calculation module calculates the shape factor to be approximately 0.698 according to a preset formula. Through the above steps, characteristic parameters such as the area, perimeter, and shape factor of the defect are quantified for subsequent fine classification of defect types by the support vector machine classifier. Using the area of the minimum bounding rectangle as the defect area can effectively reduce the area calculation error caused by the irregular defect shape or edge noise and improve the robustness of the area feature. The application of the chain code tracking algorithm makes the perimeter calculation more accurate, overcomes the deficiencies of the simple pixel counting method, and provides a guarantee for the accurate calculation of the shape factor.

[0078] In certain embodiments, the specific steps in step S534 include: S5341. Calculate the shape factor of the defect area according to the following formula: ; where, is the shape factor of the defect area, is the area of the defect area, is the perimeter of the defect area.

[0079] The shape factor is calculated by the above formula. In the formula, the area S represents the area of the minimum bounding rectangle of the set of pixel coordinates of the defect area, the perimeter C is obtained by extracting the edge pixel coordinates of the defect area through the chain code tracking algorithm and calculating the length of the edge pixel coordinates, and the constant 4π is used to ensure the standardization of the shape factor calculation result. Thus, the shape factor can be quantified and used to characterize the shape feature of the defect area, providing a quantitative basis for subsequent defect fine classification.

[0080] Specifically, the calculation of the shape factor first determines the area S of the defect region. Generally, since the physical area of a single pixel is very small, the area of the minimum bounding rectangle of the pixel coordinate set of the defect region is approximately equal to the total area of all pixels included in the defect region in the defect mask image. That is, the area S can be obtained by counting the number of pixels included in the defect region in the defect mask image and multiplying the number of pixels by the actual physical area represented by each pixel (the error between the two can be ignored). Then, the chain code tracking algorithm is used to extract the edge pixel coordinates of the defect region from the defect mask image. After extracting the edge pixel coordinates, the perimeter C of the defect region is obtained by calculating the length of the edge pixel coordinates. Finally, the area S and the perimeter C are substituted into the shape factor calculation formula to calculate the shape factor F. The shape factor F can quantitatively describe the shape of the defect region and provide shape feature parameters for the subsequent fine classification of defect types by the support vector machine classifier. The introduction of the constant 4π makes the shape factor values of different-shaped defects comparable, ensuring the unity and accuracy of the shape feature quantization results.

[0081] In some specific embodiments, assume that the defect region in the defect mask image contains 100 pixels, and the actual area represented by each pixel is 0.01 square millimeters. Then the area S of the defect region is 1 square millimeter. A total of 40 edge pixel coordinates of the defect region are extracted by the chain code tracking algorithm, and the length represented by each edge pixel coordinate is approximately 0.1 millimeters. Then the perimeter C of the defect region is 4 millimeters. Substituting the area S = 1 square millimeter and the perimeter C = 4 millimeters into the shape factor calculation formula, the shape factor F≈0.785 is obtained. The calculated shape factor value can be used as a defect feature for the fine classification of defects by the support vector machine classifier. Using the above formula to calculate the shape factor ensures the clarity of the shape factor calculation method, improves the accuracy and consistency of defect shape feature extraction, and lays a foundation for defect fine classification.

[0082] Please refer to Figure 2 , Figure 2 which is a device for detecting minute surface defects of doors and windows in some embodiments of the present invention. The device for detecting minute surface defects of doors and windows is integrated in the backend control device in the form of a computer program, and includes: A control module 100, configured to use a multi-angle annular dark field lighting device to illuminate the matte paint surface wooden door component rotating at high speed with preset light source parameters, and synchronously collect an initial image using a high-speed image sensor; the light source parameters include the irradiation angle, the light intensity, or the light source grouping; A calculation module 200, configured to calculate the SNR value under the current lighting condition according to the initial image; A comparison module 300 is configured to compare the SNR value with a preset SNR threshold. If the SNR value is lower than the SNR threshold, the light source parameters of the multi-angle annular dark-field illumination device are adjusted according to a preset optimization strategy. An adjustment module 400 is configured to repeatedly execute the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches the optimal level or meets a preset stop iteration condition. An identification module 500 is configured to, after the SNR value reaches the optimal level or meets a preset stop iteration condition, collect the current image and perform defect identification and segmentation to obtain a defect detection result. A generation module 600 is configured to generate a detection report based on the defect detection result for quality monitoring and production traceability.

[0083] In some embodiments, when the comparison module 300 is configured to compare the SNR value with a preset SNR threshold and adjust the light source parameters of the multi-angle annular dark-field illumination device according to a preset optimization strategy if the SNR value is lower than the SNR threshold, the following operations are performed: S31. When the SNR value is lower than the SNR threshold, a defect classification model is used to identify the defect type in the current image; the defect types include scratch defects and depression defects. S32. An optimization strategy is selected from a preset optimization strategy library according to the defect type; the optimization strategy library includes a first light source parameter adjustment scheme for scratch defects and a second light source parameter adjustment scheme for depression defects. S33. If the identification result is a scratch defect, a set of light source parameters is selected from the first light source parameter adjustment scheme, and the light source irradiation angle and light intensity of the multi-angle annular dark-field illumination device are adjusted according to the set of light source parameters. S34. If the identification result is a depression defect, a set of light source parameters is selected from the second light source parameter adjustment scheme, and the light source grouping and light intensity of the multi-angle annular dark-field illumination device are adjusted according to the set of light source parameters.

[0084] In some embodiments, when the comparison module 300 is configured to use a defect classification model to identify the defect type in the current image, the following operations are performed: S311. The initial image is preprocessed, Gaussian filtering is used for noise reduction and histogram equalization is used to enhance the contrast to obtain a first preprocessed image. S312. The first preprocessed image is input into the defect classification model, and the probability values of the first preprocessed image belonging to scratch defects and depression defects are calculated through a Softmax classifier; the defect classification model is a deep convolutional neural network including multiple convolutional layers and pooling layers; the deep convolutional neural network is trained using a sample set including scratch defects and depression defects, and the training of the deep convolutional neural network uses a cross-entropy loss function and an Adam optimizer. S313. Compare the probability value with a preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, determine that the defect type is a scratch defect; if the probability value of the dent defect is greater than the probability threshold, determine that the defect type is a dent defect; if the probability values of both the scratch defect and the dent defect are less than the probability threshold, determine that it is a defect of other types.

[0085] In some embodiments, when the comparison module 300 is used to preprocess the initial image, perform Gaussian filtering for noise reduction and histogram equalization for contrast enhancement to obtain the first preprocessed image, it executes: S3111. Analyze the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, use the histogram equalization algorithm with brightness compensation to enhance the contrast and obtain the brightness equalized image; S3112. Calculate the gradient magnitude of the brightness equalized image, adaptively adjust the filtering parameters of the Gaussian filter according to the gradient magnitude, and perform Gaussian filtering on the brightness equalized image using the adaptively adjusted filtering parameters to obtain the first preprocessed image.

[0086] In some embodiments, when the recognition module 500 is used to collect the current image and perform defect recognition and segmentation to obtain the defect detection result after the SNR value reaches the optimal level or meets the preset stop iteration condition, it executes: S51. Preprocess the current image, use median filtering to remove noise, and use adaptive histogram equalization to enhance the local contrast to obtain the second preprocessed image; S52. Use the trained Mask R-CNN model to perform defect recognition and segmentation on the second preprocessed image to obtain the defect mask image; the Mask R-CNN model includes a classification branch for defect classification, a bounding box regression branch for defect localization, and a mask branch for defect pixel-level segmentation; S53. According to the defect mask image, calculate the area, perimeter, and shape factor of the defect region, and use the area, perimeter, and shape factor as defect features; S54. According to the defect features, use a support vector machine classifier to perform fine classification of the defect type to obtain the defect detection result, and the defect detection result includes the defect location, defect type, and defect features.

[0087] In some embodiments, when the recognition module 500 is used to preprocess the current image, use median filtering to remove noise, and use adaptive histogram equalization to enhance the local contrast to obtain the second preprocessed image, it executes: S511. Convert the current image to the HSV color space and extract the brightness component V; S512. Smooth the luminance component V using guided filtering to obtain a luminance background image; the guidance image of the guided filtering is the luminance component V itself, and the filtering radius of the guided filtering is adaptively adjusted according to the resolution of the current image; S513. Calculate a luminance correction coefficient based on the luminance background image, and perform luminance correction on each of the RGB three color channels of the current image using the luminance correction coefficient to obtain a luminance-corrected image; S514. Remove noise from the luminance-corrected image using median filtering to obtain a third preprocessed image; S515. Divide the third preprocessed image into multiple non-overlapping image blocks, and calculate the local contrast of each image block; S516. Adaptively adjust the parameters of adaptive histogram equalization according to the local contrast of each image block, and perform histogram equalization processing on each image block using the adaptively adjusted parameters to obtain a second preprocessed image.

[0088] In some embodiments, when the recognition module 500 is used to calculate the area, perimeter, and shape factor of the defect region based on the defect mask image and use the area, perimeter, and shape factor as defect features, it performs: S531. Extract the set of pixel coordinates of the defect region based on the defect mask image; S532. Calculate the minimum bounding rectangle of the set of pixel coordinates, and use the area of the minimum bounding rectangle as the area of the defect region; S533. Based on the defect mask image, use the chain code tracking algorithm to extract the edge pixel coordinates of the defect region from the set of pixel coordinates, and calculate the length of the edge pixel coordinates to obtain the perimeter of the defect region; S534. Calculate the shape factor of the defect region based on the area and perimeter of the defect region.

[0089] In some embodiments, when the recognition module 500 is used to calculate the shape factor of the defect region based on the area and perimeter of the defect region, it performs: S5341. Calculate the shape factor of the defect region according to the following formula: ; where, is the shape factor of the defect region, is the area of the defect region, is the perimeter of the defect region.

[0090] Please refer to Figure 3 , Figure 3A schematic structural diagram of an electronic device provided by an embodiment of the present invention. The present invention provides an electronic device 13, including: a processor 1301 and a memory 1302. The processor 1301 and the memory 1302 are interconnected and communicate with each other through a communication bus 1303 and / or other forms of connection mechanisms (not marked). The memory 1302 stores computer-readable instructions executable by the processor 1301. When the electronic device runs, the processor 1301 executes the computer-readable instructions to execute the method for detecting minute defects on the surface of doors and windows in any optional implementation manner of the above embodiments to achieve the following functions: using a multi-angle annular dark-field lighting device to illuminate a high-speed rotating matte paint wooden door component with preset light source parameters, and using a high-speed image sensor to synchronously collect an initial image; the light source parameters include irradiation angle, light intensity or light source grouping; calculating the SNR value under the current lighting conditions according to the initial image; comparing the SNR value with a preset SNR threshold. If the SNR value is lower than the SNR threshold, adjusting the light source parameters of the multi-angle annular dark-field lighting device according to a preset optimization strategy; repeatedly executing the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches the optimal level or meets the preset stop iteration condition; after the SNR value reaches the optimal level or meets the preset stop iteration condition, collecting the current image and performing defect recognition and segmentation to obtain a defect detection result; generating a detection report according to the defect detection result.

[0091] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it executes the method for detecting minute defects on the surface of doors and windows in any optional implementation manner of the above embodiments to achieve the following functions: using a multi-angle annular dark-field lighting device to illuminate a high-speed rotating matte paint wooden door component with preset light source parameters, and using a high-speed image sensor to synchronously collect an initial image; the light source parameters include irradiation angle, light intensity or light source grouping; calculating the SNR value under the current lighting conditions according to the initial image; comparing the SNR value with a preset SNR threshold. If the SNR value is lower than the SNR threshold, adjusting the light source parameters of the multi-angle annular dark-field lighting device according to a preset optimization strategy; repeatedly executing the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches the optimal level or meets the preset stop iteration condition; after the SNR value reaches the optimal level or meets the preset stop iteration condition, collecting the current image and performing defect recognition and segmentation to obtain a defect detection result; generating a detection report according to the defect detection result.

[0092] Among them, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM for short), electrically erasable programmable read-only memory (EEPROM for short), erasable programmable read-only memory (EPROM for short), programmable read-only memory (PROM for short), read-only memory (ROM for short), magnetic memory, flash memory, magnetic disk or optical disk.

[0093] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or units can be electrical, mechanical or other forms.

[0094] In addition, the units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0095] Furthermore, in each embodiment of the present invention, the functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0096] In this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0097] The above are only embodiments of the present invention and are not intended to limit the protection scope of the present invention. For those skilled in the art, various modifications and changes can be made to the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for detecting minor defects on the surface of doors and windows, characterized in that: The following steps are involved: S1. Using a multi-angle annular dark field lighting device, illuminating the matte painted wooden door components in high-speed circulation with preset light source parameters, and synchronously capturing an initial image using a high-speed image sensor; the light source parameters include illumination angle, light intensity or light source grouping; S2. Calculate the SNR value under the current lighting conditions according to the initial image; S3. Compare the SNR value with a preset SNR threshold, and if the SNR value is lower than the SNR threshold, adjust the light source parameters of the multi-angle annular dark field illumination device according to a preset optimization strategy; S4. Repeat the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches an optimal level or satisfies a preset stop iteration condition; S5. When the SNR value reaches the optimal level or satisfies the preset stop iteration condition, the current image is collected and defect recognition and segmentation are performed to obtain defect detection results; S6. Generate a test report based on the defect detection results.

2. The method for detecting minor defects on the surface of doors and windows according to claim 1, characterized in that: The specific steps in step S3 include: S31. When the SNR value is lower than the SNR threshold, the defect type in the current image is identified using a defect classification model; the defect type includes a scratch defect and a dent defect; S32. Selecting an optimization strategy from a preset optimization strategy library according to the defect type; the optimization strategy library includes a first light source parameter adjustment scheme for scratch defects and a second light source parameter adjustment scheme for concave defects; S33. If the identification result is a scratch defect, a set of light source parameters is selected from the first light source parameter adjustment scheme, and the light source irradiation angle and light intensity of the multi-angle annular dark field illumination device are adjusted according to the set of light source parameters; S34. If the identification result is a concave defect, a set of light source parameters is selected from the second light source parameter adjustment scheme, and the light source grouping and illumination intensity of the multi-angle annular dark field illumination device are adjusted according to the set of light source parameters.

3. The method for detecting minor defects on the surface of doors and windows according to claim 2, characterized in that: The specific steps in step S31 include: S311. Preprocessing the initial image, using Gaussian filtering to reduce noise and using histogram equalization to enhance contrast, to obtain a first preprocessed image; S312. Input the first preprocessed image into the defect classification model, and calculate the probability value of the first preprocessed image belonging to a scratch defect and a dent defect through a Softmax classifier; the defect classification model comprises a deep convolutional neural network with multiple convolutional layers and pooling layers; the deep convolutional neural network is trained using a sample set containing scratch defects and dent defects, and the training of the deep convolutional neural network adopts a cross entropy loss function and an Adam optimizer; S313. Compare the probability value with the preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, determine that the defect type is a scratch defect; if the probability value of the recess defect is greater than the probability threshold, determine that the defect type is a recess defect; if the probability values ​​of the scratch defect and the recess defect are both less than the probability threshold, determine that they are other types of defects.

4. The method for detecting minor defects on the surface of doors and windows according to claim 3, characterized in that: The specific steps in step S311 include: S3111. Analyze the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, use a histogram equalization algorithm with brightness compensation to enhance the contrast and obtain a brightness-equalized image. S3112. Calculate the gradient amplitude of the brightness equalized image, and adaptively adjust the filtering parameters of the Gaussian filter according to the gradient amplitude, and use the adaptively adjusted filtering parameters to perform Gaussian filtering and denoising on the brightness equalized image to obtain the first preprocessed image.

5. The method for detecting minor defects on the surface of doors and windows according to claim 3, characterized in that: The defect classification model is trained by the following steps: A1. Build a deep convolutional neural network with multiple convolutional layers and pooling layers; A2. Construct a dataset containing a scratch defect sample set, a dent defect sample set, a wood texture sample set, and a paint particle noise sample set; A3. extracting defect images from the scratch defect sample set and the dent defect sample set respectively, and obtaining enhanced training samples by randomly superimposing wood texture images extracted from the wood texture sample set and / or paint particle noise images extracted from the paint particle noise sample set; A4. Use the enhanced training samples to train the deep convolutional neural network to obtain the defect classification model.

6. The method for detecting minor defects on the surface of doors and windows according to claim 1, characterized in that: The specific steps in step S5 include: S51. Preprocessing the current image, removing noise by using median filtering, and enhancing local contrast by using adaptive histogram equalization to obtain a second preprocessed image; S52. Using the trained Mask R-CNN model to perform defect recognition and segmentation on the second preprocessed image to obtain a defect mask image; the Mask R-CNN model includes a classification branch for defect classification, a bounding box regression branch for defect location, and a mask branch for defect pixel-level segmentation; S53. Calculate the area, perimeter and shape factor of the defect area according to the defect mask image, and use the area, perimeter and shape factor as defect features; S54. Based on the defect characteristics, use a support vector machine classifier to perform fine classification on the defect type to obtain a defect detection result, which includes a defect location, a defect type and a defect characteristic.

7. The method for detecting minor defects on the surface of doors and windows according to claim 6, characterized in that: The specific steps in step S51 include: S511. Convert the current image to the HSV color space and extract the brightness component V; S512. Smoothing the brightness component V by using guided filtering to obtain a brightness background image; the guided image of the guided filtering is the brightness component V itself, and the filtering radius of the guided filtering is adaptively adjusted according to the resolution of the current image; S513. Calculate a brightness correction coefficient according to the brightness background image, and use the brightness correction coefficient to perform brightness correction on the three RGB color channels of the current image respectively to obtain a brightness-corrected image; S514. Using median filtering to remove noise from the brightness-corrected image to obtain a third preprocessed image; S515. Divide the third preprocessed image into a plurality of non-overlapping image blocks, and calculate the local contrast of each image block; S516. Adaptively adjust the parameters of adaptive histogram equalization according to the local contrast of each image block, and perform histogram equalization processing on each image block using the adaptively adjusted parameters to obtain the second preprocessed image.

8. A device for detecting minor defects on the surface of doors and windows, characterized in that: include: A control module is used to illuminate the matte painted wooden door components that are rotating at high speed using a multi-angle annular dark field lighting device with preset light source parameters, and synchronously collect an initial image using a high-speed image sensor; the light source parameters include illumination angle, light intensity or light source grouping; A calculation module, used for calculating the SNR value under current lighting conditions according to the initial image; A comparison module, used for comparing the SNR value with a preset SNR threshold, and if the SNR value is lower than the SNR threshold, adjusting the light source parameters of the multi-angle annular dark field lighting device according to a preset optimization strategy; An adjustment module, used for repeatedly performing the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches an optimal level or satisfies a preset stop iteration condition; The recognition module is used to collect the current image and perform defect recognition and segmentation to obtain defect detection results when the SNR value reaches an optimal level or meets a preset stop iteration condition; The generation module is used to generate a test report based on the defect detection results for use in quality monitoring and production traceability.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps of the method for detecting minute defects on the surface of doors and windows as described in any one of claims 1 to 7 are executed.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, the steps of the method for detecting minute defects on the surface of doors and windows as described in any one of claims 1 to 7 are executed.

Citation Information

Patent Citations

  • Defect detection method for wood-plastic new material door based on optical vision

    CN115359042A

  • Intelligent door and window defect detection device and detection method thereof

    CN118392660A

  • Appearance defect detection method and system based on adaptive illumination

    CN118408939A

  • Detection device and detection method based on multifunctional integrated light source

    CN118731044A

  • Magnet surface defect detection equipment control method for AI optimization and controller

    CN119290894A

Cited By

  • Surface detection method for shaft part machining

    CN120833513A

  • Metal surface identification identification method and system based on multi-modal parameter fusion and active optical adjustment

    CN122116055A