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

By using a multi-angle annular dark-field lighting device and a deep convolutional neural network, combined with real-time signal-to-noise ratio optimization and the Mask R-CNN model, the detection challenges of tiny defects under uneven LED lighting and weak reflections on matte surfaces were resolved, achieving efficient and accurate automated detection.

CN120070831BActive Publication Date: 2025-10-10FOSHAN XINHAOXUAN SMART HOME TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the manufacturing of high-end custom wooden doors, traditional machine vision inspection methods have difficulty achieving fast, accurate, and low-cost automated detection of tiny scratches and dents under conditions of uneven LED lighting and matte, weakly reflective surfaces.

Method used

A multi-angle annular dark-field lighting device and a high-speed image sensor are used to optimize lighting conditions through real-time signal-to-noise ratio evaluation and adaptive light source parameter adjustment. Defect recognition and segmentation are performed in combination with a deep convolutional neural network and Mask R-CNN model.

Benefits of technology

It achieves fast, accurate, economical and efficient automatic recognition of tiny scratches and dents on the surface of matte painted wooden door components under complex lighting conditions, reduces the false detection rate and missed detection rate, and improves the intelligence level of the detection system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120070831B_ABST
    Figure CN120070831B_ABST
Patent Text Reader

Abstract

The application provides a door and window surface tiny defect detection method and device, electronic equipment and storage medium, and relates to the technical field of door and window defect detection. The method comprises the following steps: illuminating the component with preset light source parameters, and synchronously collecting an initial image; calculating an SNR value according to the initial image; comparing the SNR value with a preset SNR threshold value, if the SNR value is lower than the SNR threshold value, adjusting the light source parameters; 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 meets a preset stop iteration condition; collecting a current image and performing defect recognition and segmentation to obtain a defect detection result. The door and window surface tiny defect detection method overcomes the interference of the weak reflection of the matte surface and the uneven LED illumination, realizes the rapid, accurate, economic and efficient automatic recognition of the tiny scratches and concave defects on the surface of the high-speed flowing matte paint wooden door component.
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 in particular to a method, device, electronic equipment and storage medium for detecting minute defects on the surface of doors and windows. Background Art

[0002] In the modern, high-end, custom-made wooden door manufacturing industry, high-speed production lines have become crucial for improving efficiency and meeting market demand. Wooden door components are rapidly moved after being painted with a matte finish. To ensure surface quality, factories need to inspect the paint for defects.

[0003] However, to save energy, factories generally use LED lighting systems. This type of lighting easily creates uneven lighting and shadows on matte surfaces, making it difficult for human visual inspection to detect small scratches and dents. Traditional machine vision inspection methods are still applicable under uniform lighting, but the uneven LED lighting and matte, weakly reflective surfaces significantly reduce detection accuracy and stability.

[0004] Therefore, how to overcome the limitations of uneven LED lighting and weak reflection of matte surfaces on high-speed production lines and achieve fast, accurate, and low-cost automated detection of tiny defects has become a difficult problem that the industry urgently needs to solve. Summary of the Invention

[0005] The purpose of the present invention is to provide a method, device, electronic equipment and storage medium for detecting minor defects on the surface of doors and windows, which can overcome the weak reflection of matte surfaces and the interference of uneven LED lighting, and realize the rapid, accurate, economical and efficient automatic identification of minor scratches and dents on the surface of high-speed matte painted wooden door components.

[0006] In a first aspect, the present invention provides a method for detecting minor defects on the surface of doors and windows, comprising the steps of:

[0007] S1. Utilize a multi-angle annular dark-field illumination device to illuminate a high-speed rotating matte-finished wooden door component using preset light source parameters, and simultaneously capture an initial image using a high-speed image sensor; the light source parameters include illumination angle, light intensity, or light source grouping;

[0008] S2. Calculate the SNR value under the current lighting conditions based on the initial image;

[0009] S3 compares 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;

[0010] 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 satisfies the preset stop iteration condition;

[0011] S5. When the SNR value reaches the optimal level or meets the preset stop iteration condition, the current image is collected and defect recognition and segmentation are performed to obtain a defect detection result;

[0012] S6. Generate a test report based on the defect detection results.

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

[0014] Furthermore, the specific steps in step S3 include:

[0015] S31. When the SNR value is lower than the SNR threshold, the defect classification model is used to identify the defect type in the current image; the defect type includes a scratch defect and a dent defect;

[0016] 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 depression defects;

[0017] 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 illumination angle and light intensity of the multi-angle annular dark field illumination device are adjusted according to the set of light source parameters;

[0018] 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 lighting device are adjusted according to the set of light source parameters.

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

[0020] Furthermore, the specific steps in step S31 include:

[0021] S311. Preprocessing the initial image by using Gaussian filtering to reduce noise and histogram equalization to enhance contrast to obtain a first preprocessed image;

[0022] S312. Input the first pre-processed image into the defect classification model, and calculate the probability value of the first pre-processed image being a scratch defect or a dent defect using 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 deep convolutional neural network is trained using a cross-entropy loss function and an Adam optimizer;

[0023] S313. Compare the probability value with the preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, the defect type is determined to be a scratch defect; if the probability value of the dent defect is greater than the probability threshold, the defect type is determined to be a dent defect; if the probability values ​​of the scratch defect and the dent defect are both less than the probability threshold, they are determined to be other types of defects.

[0024] It achieves accurate identification of defect types, overcomes the problem of defect misjudgment caused by matte surface texture interference, and provides accurate defect type information for subsequent adjustment of light source parameters according to defect types.

[0025] Furthermore, the specific steps in step S311 include:

[0026] S3111. Analyze the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, a histogram equalization algorithm with brightness compensation is used to enhance the contrast to obtain a brightness-balanced image.

[0027] 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.

[0028] It can effectively solve the problems of uneven brightness and noise interference in the initial image, and provide higher quality pre-processed images for accurate identification of subsequent defect classification models.

[0029] Furthermore, the defect classification model is trained by the following steps:

[0030] A1. Build a deep convolutional neural network consisting of multiple convolutional and pooling layers.

[0031] A2. Construct a dataset containing scratch defect sample sets, dent defect sample sets, wood texture sample sets, and paint particle noise sample sets.

[0032] 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 particle noise images extracted from the paint particle noise sample set;

[0033] A4. Use the enhanced training samples to train the deep convolutional neural network to obtain the defect classification model.

[0034] Furthermore, the specific steps in step S5 include:

[0035] S51. Preprocessing the current image by using median filtering to remove noise and adaptive histogram equalization to enhance local contrast to obtain a second preprocessed image;

[0036] S52. Using the trained Mask R-CNN model, 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 pixel-level defect segmentation;

[0037] S53. Calculate the area, perimeter, and shape factor of the defect region according to the defect mask image, and use the area, perimeter, and shape factor as defect features;

[0038] S54. Based on the defect characteristics, use a support vector machine classifier to finely classify the defect type to obtain a defect detection result, which includes the defect location, defect type and defect characteristics.

[0039] Furthermore, the specific steps in step S51 include:

[0040] S511. Convert the current image to the HSV color space and extract the brightness component V;

[0041] S512. Smoothing the luminance component V using a guided filter to obtain a luminance background image; the guided image of the guided filter is the luminance component V itself, and the filter radius of the guided filter is adaptively adjusted according to the resolution of the current image;

[0042] S513. Calculate a brightness correction coefficient based on the brightness background image, and use the brightness correction coefficient to perform brightness correction on the three RGB color channels of the current image to obtain a brightness-corrected image;

[0043] S514. Using median filtering to remove noise from the brightness-corrected image to obtain a third preprocessed image;

[0044] S515. Dividing the third pre-processed image into a plurality of non-overlapping image blocks, and calculating the local contrast of each image block;

[0045] S516. Adaptively adjust the parameters of the 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.

[0046] In a second aspect, the present invention provides a device for detecting minor defects on the surface of doors and windows, comprising:

[0047] A control module is configured to illuminate the matte lacquer wooden door components rotating at high speed using a multi-angle annular dark-field lighting device with preset light source parameters, and to synchronously capture an initial image using a high-speed image sensor; the light source parameters include illumination angle, light intensity, or light source grouping;

[0048] A calculation module, configured to calculate an SNR value under current lighting conditions based on the initial image;

[0049] a comparison module, configured to 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;

[0050] an adjustment module, configured to repeatedly calculate the SNR value and adjust the light source parameters until the SNR value reaches an optimal level or satisfies a preset stop iteration condition;

[0051] 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;

[0052] The generation module is used to generate a test report based on the defect detection results for use in quality monitoring and production traceability.

[0053] The device for detecting minor defects on the surface of doors and windows provided by the present invention realizes adaptive optimization of lighting conditions through SNR value feedback and iterative adjustment of light source parameters, improves the stability and effectiveness of detecting minor 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 lighting conditions.

[0054] In a third aspect, the present invention provides an electronic device comprising 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 minor defects on the surface of doors and windows provided in the first aspect are executed.

[0055] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, runs the steps of the method for detecting minor defects on door and window surfaces provided in the first aspect above.

[0056] From the above, it can be seen that the method for detecting minor defects on the surface 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 lighting parameters, maximize the defect signal strength, and significantly improve the detection rate of minor scratches and dents on matte paint surfaces, overcoming the problem of decreased detection performance of traditional fixed lighting methods under complex lighting conditions; and by adopting high-speed image sensors and optimized image processing algorithms, the adaptive lighting adjustment process is fast and efficient, which can adapt to the rhythm requirements of high-speed production lines and realize real-time online detection; in addition, the high-quality image after signal-to-noise ratio optimization reduces the false detection rate and missed detection rate of the defect detection algorithm, ensures detection accuracy, and improves the product surface quality of high-end customized wooden doors; finally, the optimization and adjustment of lighting parameters are automatically completed without manual intervention, which reduces the operation difficulty and labor cost, and improves the intelligence level of the detection system.

[0057] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the embodiments of the present invention. The purposes and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 A flow chart of a method for detecting minor defects on door and window surfaces provided by an embodiment of the present invention.

[0059] Figure 2 A schematic structural diagram of a device for detecting minor defects on door and window surfaces provided by an embodiment of the present invention.

[0060] Figure 3 A schematic structural diagram of an electronic device provided by an embodiment of the present invention.

[0061] Description of labels:

[0062] 100. Control module; 200. Calculation module; 300. Comparison module; 400. Adjustment module; 500. Identification module; 600. Generation module; 13. Electronic device; 1301. Processor; 1302. Memory; 1303. Communication bus. DETAILED DESCRIPTION

[0063] The technical solutions in the embodiments of the present invention will be clearly and completely described below 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, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings herein 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 claimed invention, but merely represents 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 making creative work are within the scope of protection of the present invention.

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

[0065] Reference Attachment Figure 1 The present invention provides a method for detecting minor defects on the surface of doors and windows, comprising the steps of:

[0066] S1. Utilize a multi-angle annular dark-field lighting device to illuminate a high-speed, matte-lacquered wooden door component using preset light source parameters, while simultaneously capturing an initial image using a high-speed image sensor. Light source parameters include illumination angle, light intensity, or light source grouping.

[0067] S2. Calculate the SNR value (SNR, or signal-to-noise ratio) under the current lighting conditions based on the initial image;

[0068] S3 compares the SNR value with the 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 the preset optimization strategy;

[0069] 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;

[0070] S5. When the SNR value reaches the optimal level or meets the preset stop iteration condition, the current image is captured and defect recognition and segmentation are performed to obtain the defect detection result;

[0071] S6. Generate a test report based on the defect detection results.

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

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

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

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

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

[0077] Specifically, the present application provides a method for detecting minor defects on the surface of doors and windows. The method first uses a multi-angle annular dark field lighting device and a high-speed image sensor to illuminate and capture images of matte lacquer wooden door components that are circulating 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 SNR value calculation and light source parameter adjustment is repeated until the SNR value reaches the optimal level or the preset stop iteration condition is met. When the SNR value meets the requirements, the current image is collected and defect identification and segmentation are performed to obtain defect detection results, and a test report is generated for quality monitoring and production traceability. This solution realizes adaptive optimization of lighting conditions through SNR value feedback and iterative adjustment of light source parameters, improves the stability and effectiveness of detection of minor defects on door and window surfaces under different lighting conditions, and solves the technical problem that the detection effect is easily affected by lighting conditions.

[0078] In some specific embodiments, the multi-angle annular dark field lighting device can be composed of multiple LED light sources, which are divided into several groups, and the illumination angle and illumination intensity of each group of LED light sources can be adjusted independently. The preset light source parameters can be a set of empirical parameters, for example, the initial illumination angle is set to 45 degrees, the illumination intensity is set to medium, and the light source grouping is set to light up the entire group. The signal-to-noise ratio SNR threshold can be set according to actual detection requirements, for example, it is set to 20dB. The preset optimization strategy can be a lookup table, which stores light source parameter adjustment schemes corresponding to different SNR value ranges. The stopping condition can be the maximum number of iterations, for example, set to 5 times. When the SNR value has not reached 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 deep learning algorithms, such as convolutional neural networks.

[0079] In some embodiments, the specific steps in step S3 include:

[0080] S31. When the SNR value is lower than the SNR threshold, the defect classification model is used to identify the defect type in the current image; the defect type includes a scratch defect and a dent defect;

[0081] S32 selects 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 recess defects;

[0082] 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 illumination angle and light intensity of the multi-angle annular dark field lighting device are adjusted according to the set of light source parameters;

[0083] 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.

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

[0085] In step S32, the preset optimization strategy library can be a lookup table that stores optimization strategies corresponding to different defect types. When the defect type is identified, the system can search and select the corresponding optimization strategy in the optimization strategy library based on the defect type.

[0086] Steps S33 and S34 describe light source parameter adjustment schemes for different defect types. Specifically, for scratch defects, the first light source parameter adjustment scheme may include adjusting the specific parameter values ​​or adjustment ranges of the light source illumination angle and illumination intensity of the multi-angle annular dark field lighting device. For example, the illumination angle can be increased to more effectively highlight the scratch defect, while adjusting the illumination intensity to optimize the image quality. Similarly, for concave defects, the second light source parameter adjustment scheme may include adjusting the specific parameter values ​​or adjustment ranges of the light source grouping and illumination intensity. For example, the light source grouping can be adjusted to change the illumination direction to better visualize the concave defect, and the illumination 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 lighting device according to the different defect types, thereby providing more favorable lighting conditions for subsequent defect detection.

[0087] Specifically, when the SNR value of the initial image falls below a preset SNR threshold, it indicates that the current lighting conditions may not be conducive to effective defect detection. To improve image quality and defect detection accuracy, light source parameters need to be optimized. Different defect types, such as scratches and dents, exhibit distinct visual characteristics in images and require different lighting conditions. Scratches typically manifest as linear brightness or color differences and are more sensitive to lighting angle and intensity. Depressions, on the other hand, may appear as shadows or deformations and are more sensitive to lighting direction and grouping. Therefore, a universal light source parameter adjustment strategy may not achieve optimal signal-to-noise ratio improvement for all defect types. This solution introduces a defect classification model to first identify the defect type in the current image and distinguish between scratches and dents. Then, based on the identified defect type, a corresponding optimization strategy is selected from a pre-set optimization strategy library, which contains differentiated light source parameter adjustment solutions for scratches and dents. For scratches, the illumination angle and intensity are adjusted, while for dents, the light source grouping and intensity are adjusted. As a result, refined light source parameter adjustment for different types of defects is achieved, which can more effectively improve the image signal-to-noise ratio, provide more favorable lighting conditions for subsequent defect detection, and ultimately improve defect detection accuracy.

[0088] In some specific embodiments, it is assumed that the calculated SNR value in step S3 is lower than the preset SNR threshold. The system first executes step S31 and uses a pre-trained defect classification model to identify the defect type of the current image. For example, the defect classification model identifies that the defect type in the current image is a scratch defect. Then, in step S32, the system selects a first light source parameter adjustment scheme corresponding to the scratch defect from a preset optimization strategy library based on the type of the scratch defect. The first light source parameter adjustment scheme can be preset as: increasing the illumination angle of the multi-angle annular dark field lighting device by 5 degrees and increasing the illumination intensity by 10%. Then, in step S33, the system controls the multi-angle annular dark field lighting device according to the selected first light source parameter adjustment scheme, adjusting its illumination angle to the angle value after the increase of 5 degrees and adjusting its illumination intensity to the intensity value after the increase of 10%. Conversely, if the defect classification model identifies that the defect type is a concave defect in step S31, then in step S32, the system will select a second light source parameter adjustment scheme corresponding to the concave defect. The second light source parameter adjustment scheme can be preset as follows: the light source grouping of the multi-angle annular darkfield lighting device is adjusted so that Group A and Group B are turned on simultaneously, and the light intensity is reduced by 5%. In step S34, the system adjusts the light source grouping and light intensity according to the second light source parameter adjustment scheme. Through the above embodiment, differentiated light source parameter adjustments can be achieved according to different defect types, thereby more effectively improving the image signal-to-noise ratio and enhancing the accuracy of defect detection. Therefore, by targeted adjustment of light source parameters, defect characteristics can be more effectively highlighted, the image signal-to-noise ratio can be improved, and the accuracy and reliability of defect detection can be improved.

[0089] In some embodiments, the specific steps in step S31 include:

[0090] S311. Preprocess the initial image by using Gaussian filtering to reduce noise and histogram equalization to enhance contrast to obtain a first preprocessed image;

[0091] S312. Input the first preprocessed image into a defect classification model, and calculate the probability value of the first preprocessed image belonging to a scratch defect and a dent defect using 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 containing scratch defects and dent defects, and the deep convolutional neural network is trained using a cross entropy loss function and an Adam optimizer;

[0092] S313. Compare the probability value with the preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, the defect type is determined to be a scratch defect; if the probability value of the dent defect is greater than the probability threshold, the defect type is determined to be a dent defect; if the probability values ​​of both the scratch defect and the dent defect are less than the probability threshold, then it is determined to be other types of defects.

[0093] During preprocessing of the initial image, Gaussian filtering is used to reduce image noise, mitigate the interference of texture and particle noise on defect detection, and improve image quality. Histogram equalization is used to enhance image contrast, making defect features more distinct and facilitating subsequent defect identification. The defect classification model is a deep convolutional neural network, a network architecture that automatically extracts deep features from images and accurately classifies defect types. The network contains multiple convolutional layers to extract local features of the image, while pooling layers reduce the dimensionality of the feature map, reducing computational effort and improving model robustness. A Softmax classifier is implemented at the network's output layer to convert the network output into probabilities of the image belonging to different defect types, facilitating classification decisions. The deep convolutional neural network's training dataset includes scratch and dent defect samples. Through learning from a large number of samples, the network is able to effectively identify both types of defects. The cross-entropy loss function measures the difference between the model's predictions and the true labels, and the Adam optimizer is used to optimize network parameters, accelerating model convergence and improving training efficiency and performance. A pre-set probability threshold is used to determine 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 to be the corresponding defect type. If the probability value is below the threshold, it is determined to be another type of defect. This takes into account the unknown defect types that may exist in actual applications, improving the adaptability and reliability of the detection system.

[0094] Specifically, to address the potential interference that surface texture in matte-painted wooden door components may pose for defect identification, the initial image is first preprocessed. This preprocessing step uses Gaussian filtering to reduce image noise, smoothing out noise and subtle texture to reduce texture interference with defect feature extraction. Furthermore, histogram equalization is used to enhance image contrast, increasing the grayscale difference between the defect and the background, making the defect features more prominent. The resulting first preprocessed image exhibits reduced noise and enhanced contrast, making it more conducive to subsequent defect classification. This preprocessed image is then fed into a pretrained defect classification model. This model is a deep convolutional neural network trained on a large number of scratch and dent defect samples to learn the characteristic representations of these defects. Using a softmax classifier, the model outputs the probability of an image being a scratch or dent defect. Defect type is determined by comparing the probability values ​​of scratches and dents with preset probability thresholds. If the probability value of a scratch defect is greater than the probability threshold, the defect in the image is considered a scratch defect; if the probability value of a dent defect is greater than the probability threshold, the defect in the image is considered a dent defect; if both probability values ​​are less than the probability threshold, the defect is determined to be another type. This allows accurate identification of defect types, overcomes the problem of misjudgment caused by interference from matte surface texture, and provides accurate defect type information for subsequent adjustment of light source parameters based on defect type.

[0095] 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 image as much as possible. The histogram equalization adopts a global histogram equalization algorithm to enhance the overall contrast of the image. The deep convolutional neural network contains 3 convolution layers and 2 pooling layers, the convolution kernel size is 3x3, and the activation function is the ReLU function. 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 judged as the corresponding defect type. The training data set contains 1,000 scratch defect sample images and 1,000 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 training round is set to 50 rounds. Through the above parameter settings and training process, the defect classification model can accurately identify scratch defects and dent defects on the surface of matte painted wooden door components, providing reliable defect type information for subsequent light source parameter adjustments.

[0096] In some embodiments, the specific steps in step S311 include:

[0097] S3111 analyzes the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, a histogram equalization algorithm with brightness compensation is used to enhance the contrast to obtain a brightness-balanced image.

[0098] 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. Use the adaptively adjusted filtering parameters to perform Gaussian filtering and noise reduction on the brightness equalized image to obtain a first preprocessed image.

[0099] In step S3111, the brightness distribution analysis specifically involves calculating the brightness mean and brightness standard deviation of the initial image. The brightness mean reflects the overall brightness level of the image, while the brightness standard deviation reflects the degree of dispersion in the image's brightness distribution. A threshold for the brightness standard deviation can be set to determine if the brightness distribution is uneven. When the brightness standard deviation exceeds the threshold, the brightness distribution is considered uneven. The histogram equalization algorithm with brightness compensation considers the local brightness information of the image during histogram equalization, compensating for areas that are too dark or too bright to avoid excessive contrast enhancement in areas with uneven brightness.

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

[0101] Specifically, in the case of uneven brightness distribution and varying noise levels in the initial image, 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 image contrast while reducing the impact of brightness unevenness, thereby obtaining a brightness-equalized image. The gradient amplitude of the brightness-equalized image is then calculated. The gradient amplitude can reflect the image's detail information and noise level. The Gaussian filter parameters are adaptively adjusted based on the gradient amplitude. When the gradient amplitude is high, smaller Gaussian filter parameters are used to retain more image detail; when the gradient amplitude is low, larger Gaussian filter parameters are used to enhance the image's noise reduction capabilities. Using the adaptively adjusted filter parameters, the brightness-equalized image is subjected to Gaussian filtering for noise reduction, resulting in a first preprocessed image. Through these steps, the uneven brightness and noise interference issues of the initial image can be effectively addressed, providing a higher-quality preprocessed image for accurate recognition by the subsequent defect classification model.

[0102] In some specific embodiments, the judgment threshold for uneven brightness distribution can be set to a brightness standard deviation of 30. The histogram equalization algorithm with brightness compensation can adopt a limited contrast adaptive histogram equalization algorithm. The gradient amplitude is calculated by the Sobel operator. The specific method of adaptively adjusting the parameters of the Gaussian filter can be that when the mean value of the gradient amplitude 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 value of the gradient amplitude 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. By setting the above specific parameters, effective contrast enhancement and adaptive noise reduction of images with uneven brightness can be achieved, thereby improving the accuracy of subsequent defect classification. The use of a histogram equalization algorithm with brightness compensation can avoid the problem of excessive noise enhancement in traditional histogram equalization on images with uneven brightness, so that the image maintains relative uniformity of brightness distribution while enhancing contrast. Adaptively adjusting the Gaussian filter parameters according to the gradient amplitude can strike a balance between noise reduction and detail retention, so that the preprocessed image can not only effectively remove noise but also retain the detailed features of the defects as much as possible, providing a strong guarantee for the accurate identification of the subsequent defect classification model.

[0103] In some embodiments, the defect classification model is trained by the following steps:

[0104] A1. Build a deep convolutional neural network consisting of multiple convolutional and pooling layers.

[0105] A2. Construct a dataset containing scratch defect sample sets, dent defect sample sets, wood texture sample sets, and paint particle noise sample sets.

[0106] A3. Extract defect images from the scratch defect sample set and the dent defect sample set, respectively, and generate 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.

[0107] A4. Use the enhanced training samples to train the deep convolutional neural network to obtain a defect classification model.

[0108] In step A1, a deep convolutional neural network is constructed. The network structure includes multiple convolutional layers and pooling layers. The convolutional layers are configured to extract spatial features from the image, while the pooling layers are configured to reduce the resolution of the feature map, reduce computational complexity, and enhance the feature's translation invariance. The stacking of multiple convolutional and pooling layers enables the network to gradually extract increasingly abstract features from the image, thereby improving the model's accuracy in classifying defect types.

[0109] In step A2, a dataset is constructed. The dataset includes a scratch defect sample set, a dent defect sample set, a wood texture sample set, and a paint particle noise sample set. The scratch defect sample set and the dent defect sample set contain images of various types of scratch defects and dent defects, respectively, and are used to train the model to identify different types of defects. The wood texture sample set and the paint particle noise sample set contain images of defect-free wood textures and paint particle noise, respectively, and are used to simulate interference factors that may exist in actual industrial scenarios and improve the robustness of the model.

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

[0111] In step A4, the defect classification model is trained, and the augmented training samples are fed into the constructed deep convolutional neural network for training. The training process uses a cross-entropy loss function to measure the difference between the model's predictions and the true labels. The Adam optimizer is then used to optimize the network parameters and minimize the loss function, ultimately yielding a trained defect classification model. Thus, by constructing a deep convolutional neural network, building a dataset containing a variety of samples, generating augmented training samples, and using the augmented training samples to train the deep convolutional neural network, the defect classification model is effectively trained.

[0112] 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 in the existing technology to train defect classification models, this solution proposes a defect classification model training method 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 data set containing multiple types of samples is constructed. The sample types cover the defect types that need to be identified and possible interference factors, ensuring the comprehensiveness and representativeness of the training data. In order to further improve the robustness and generalization ability of the model, a method for generating enhanced training samples is also proposed. By superimposing the defect image with the background noise image, the situation in which defects and noise may appear at the same time in real scenes is simulated. Finally, the generated enhanced training samples are used to train the deep convolutional neural network, and the final defect classification model is obtained by optimizing the network parameters. The trained defect classification model can accurately identify the defect type in the image and provide reliable classification results for subsequent light source parameter optimization and defect detection.

[0113] In some specific embodiments, the deep convolutional neural network can adopt the ResNet-50 network structure, which has a deeper network layer and residual connection, can effectively extract the deep features of the image, and alleviate the gradient disappearance problem. The data set can contain 1,000 scratch defect images, 1,000 dent defect images, 500 wood texture images, and 500 paint particle noise images. When generating enhanced training samples, wood texture images or paint particle noise images can be randomly selected to superimpose with the defect images, and the transparency of the superposition can be set to between 0.3 and 0.7. During training, the Adam optimizer can be used, the learning rate is set to 0.001, the batch size is set to 32, and the training epoch is set to 100. Through the above specific implementation methods, 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.

[0114] In some embodiments, the specific steps in step S5 include:

[0115] S51. Preprocess the current image by using median filtering to remove noise and adaptive histogram equalization to enhance local contrast to obtain a second preprocessed image;

[0116] S52. Use the trained Mask R-CNN model (i.e., a masked 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 pixel-level defect segmentation.

[0117] S53. Calculate the area, perimeter, and shape factor of the defect region according to the defect mask image, and use the area, perimeter, and shape factor as defect features;

[0118] S54. Based on the defect characteristics, use a support vector machine classifier to finely classify the defect type to obtain a defect detection result. The defect detection result includes the defect location, defect type and defect characteristics.

[0119] In step S51, the current image is preprocessed, specifically using median filtering to remove image noise and adaptive histogram equalization to enhance local contrast. This produces a higher-quality second preprocessed image, paving the way for subsequent defect identification and segmentation.

[0120] In step S52, the second preprocessed image is subjected to defect identification and segmentation using the Mask R-CNN model. The Mask R-CNN model is pre-trained and can perform both object detection and instance segmentation. The model comprises a classification branch for preliminary defect type identification; a bounding box regression branch for precisely locating defects in the image; and a mask branch for pixel-level segmentation of defects, thereby generating an accurate defect mask image.

[0121] In step S53, defect characteristics such as the area, perimeter, and shape factor of the defect region are calculated based on the defect mask image obtained in step S52. The area characteristic reflects the size of the defect, the perimeter characteristic describes the length of the defect contour, and the shape factor characterizes the regularity of the defect shape. These defect characteristics provide a quantitative basis for fine-grained defect classification and quality monitoring.

[0122] In step S54, a support vector machine classifier is used to finely classify the defect type based on the defect features extracted in step S53. The support vector machine classifier is an effective classification algorithm that can accurately classify defect types based on defect features. The final defect detection results contain detailed information such as defect location, defect type, and defect features, which can meet the needs of quality monitoring and production traceability.

[0123] Specifically, after signal-to-noise ratio optimization is completed, the captured current image first enters step S51 for preprocessing. The use of a median filter effectively reduces noise in the image, such as salt-and-pepper noise, by replacing the pixel value with the median of its neighborhood grayscale values, eliminating isolated noise points and smoothing the image. Adaptive histogram equalization adaptively adjusts the histogram based on the local characteristics of different image regions, enhancing local contrast and making previously difficult defects more distinct. The resulting preprocessed image improves image quality, providing clearer input for subsequent defect identification and segmentation. Subsequently, in step S52, the second preprocessed image is fed into the pretrained Mask R-CNN model. Leveraging its powerful feature extraction and multi-tasking capabilities, the Mask R-CNN model accurately identifies defects in the image and simultaneously provides defect category, location, and pixel-level segmentation results. The classification branch initially determines whether the defect is a scratch, dent, or other type. The bounding box regression branch determines the location of the defect's bounding rectangle. The mask branch generates a mask that precisely aligns with the defect area, achieving accurate segmentation. In step S53, based on the defect mask image, characteristic parameters such as the defect area, perimeter, and shape factor are calculated. The area directly reflects the size of the defect, the perimeter describes the complexity of the defect outline, and the shape factor quantifies the regularity of the defect shape. For example, the shape factor of a circular defect is close to 1, while the shape factor of a narrow defect is smaller. These characteristic parameters provide a quantitative basis for subsequent fine-grained defect classification. 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-grained classification of defect types by constructing an optimal classification hyperplane. For example, different types of scratches or dents can be distinguished, or defects can be further subdivided into different levels. The final defect detection results not only include the location 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.

[0124] In some specific implementation methods, in order to more clearly demonstrate the technical solution, a specific embodiment is provided. In step S51, the median filter specifically adopts a 3x3 filter window, and the adaptive histogram equalization adopts an image block of size 8x8 for local histogram equalization, and sets the contrast limit parameter to 0.03 to avoid excessive enhancement of noise. In step S52, the Mask R-CNN model uses ResNet50 as the backbone network to extract image features. During the training process, a data set containing scratch defects, dent defects and normal wooden door surface images is used for training. The optimizer uses Adam and the learning rate is set to 0.001. In step S53, the area of ​​the defective area is obtained by counting the number of defective pixels in the defect mask image, the perimeter is obtained by extracting the defect contour pixels and calculating the contour length through the chain code tracking algorithm, and the shape factor is calculated by 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, such as further subdividing scratch defects into slight scratches, moderate scratches and severe scratches.

[0125] In some embodiments, the specific steps in step S51 include:

[0126] S511. Convert the current image to the HSV color space and extract the brightness component V;

[0127] S512. The luminance component V is smoothed using a guided filter to obtain a luminance background image; the guided image of the guided filter is the luminance component V itself, and the filter radius of the guided filter is adaptively adjusted according to the resolution of the current image;

[0128] S513. According to the brightness of the background image, calculate the brightness correction coefficient, and use the brightness correction coefficient to perform brightness correction on the three RGB color channels of the current image to obtain a brightness-corrected image;

[0129] S514. Using median filtering to remove noise from the brightness corrected image to obtain a third preprocessed image;

[0130] S515. Dividing the third preprocessed image into a plurality of non-overlapping image blocks, and calculating the local contrast of each image block;

[0131] S516. Adaptively adjust the parameters of the 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.

[0132] 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 image brightness information and color information, so that subsequent brightness processing is concentrated on the brightness component and color information interference is avoided.

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

[0134] In step S513, a brightness correction coefficient is calculated based on the brightness background image. This 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 reduced or eliminated, and the image brightness distribution is more uniform, creating more favorable lighting conditions for subsequent defect detection.

[0135] 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 effects of noise on the brightness correction effect.

[0136] 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 based on the contrast of different areas of the image, avoiding the problems of over-enhancement or under-enhancement that may be caused by global histogram equalization, more effectively improving the local contrast of the image, making defect features more obvious, and more conducive to subsequent defect identification and segmentation.

[0137] Specifically, to address the problem of uneven image brightness and low contrast caused by uneven LED lighting and the reflective properties of matte surfaces in surface defect detection of matte-painted wooden door components, this embodiment first converts the image from RGB color space to HSV color space and extracts the V component 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. A brightness correction coefficient is calculated based on the brightness background image and applied to the RGB channels to achieve image brightness correction and reduce the impact of uneven lighting. Next, a median filter is used to remove image noise and further improve image quality. Finally, the image is divided into small blocks, and the local contrast is calculated. Local histogram equalization is then adaptively performed to enhance the local contrast and highlight the defect features. Through the above steps, the problem of uneven image brightness is effectively solved, and the image contrast and quality are improved, providing high-quality image input for the subsequent Mask R-CNN model for defect recognition and segmentation, thereby improving the accuracy and robustness of the entire defect detection system.

[0138] 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 the adaptive histogram equalization, the image is divided into image blocks of 64x64 pixels in size, and the local contrast is obtained by calculating the standard deviation of the pixel grayscale values ​​in each image block. The clipping threshold clipLimit parameter of the adaptive histogram equalization is adaptively adjusted according to the local contrast. The specific adjustment strategy is: when the local contrast is lower than the preset threshold, the clipLimit parameter is set to 2, and when the local contrast is higher than the preset threshold, the clipLimit parameter is set to 1. By setting the above parameters, the effect and efficiency of image preprocessing can achieve an optimal balance.

[0139] In some embodiments, the specific steps in step S53 include:

[0140] S531. Extracting a set of pixel coordinates of a defective area according to the defect mask image;

[0141] S532. Calculate the minimum bounding rectangle of the pixel coordinate set, and use the area of ​​the minimum bounding rectangle as the area of ​​the defect area;

[0142] S533. According to the defect mask image, the chain code tracking algorithm is used to extract the edge pixel coordinates of the defect area from the pixel coordinate set, and the length of the edge pixel coordinates is calculated to obtain the perimeter of the defect area;

[0143] S534. Calculate the shape factor of the defect area based on the area and perimeter of the defect area.

[0144] To extract pixel coordinate sets, contour extraction algorithms, such as the findContours function in the OpenCV library, can be used to identify the pixel set representing the defect area from the defect mask image. To calculate the minimum bounding rectangle, the minimum area bounding rectangle algorithm can be used to find the smallest rectangle enclosing the defect pixel set. One implementation method is to use the rotating caliper algorithm to efficiently calculate the minimum bounding rectangle. The chain code tracking algorithm can be implemented by first determining the starting edge pixel of the defect area, then searching for adjacent edge pixels in a specific direction, and recording the directional 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.

[0145] Specifically, after acquiring the defect mask image, the defect mask image is first input into the contour extraction module to extract the set of pixel coordinates that constitute the defect area. Then, these pixel coordinate sets are sent to the minimum bounding rectangle calculation module to calculate the minimum rectangle enclosing the defect area. 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 track along the edge of the defect area, extract the coordinates of the edge pixels, and calculate the length of these coordinates to obtain the perimeter of the defect area. Finally, the two values ​​of area and perimeter are input into the shape factor calculation module, and the shape factor is calculated according to a preset formula. As a result, the defect characteristic 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.

[0146] In some specific embodiments, assuming a defect region exists in a defect mask image, a contour extraction algorithm first extracts a set of pixel coordinates for the defect region, for example, pixel coordinates {(10, 20), (11, 21), (12, 22), ..., (30, 40)}. Next, a minimum bounding rectangle algorithm calculates the smallest rectangle enclosing these pixels. Assuming the calculated minimum bounding rectangle has an area of ​​200 pixels, the defect area is determined to be 200. A chain code tracking algorithm tracks the edge pixels of the defect region. Assuming the calculated length of the edge pixel coordinates is 60 pixels, the defect perimeter is determined to be 60. Finally, a shape factor calculation module calculates a shape factor of approximately 0.698 according to a preset formula. Through these steps, characteristic parameters such as the defect area, perimeter, and shape factor are quantified for subsequent support vector machine classifiers to refine defect type classification. Using the area of ​​the minimum bounding rectangle as the defect area effectively reduces area calculation errors caused by irregular defect shapes or edge noise, thereby improving the robustness of the area feature. The application of the chain code tracking algorithm makes the perimeter calculation more accurate, overcomes the shortcomings of the simple pixel counting method, and provides a guarantee for the accurate calculation of the shape factor.

[0147] In some embodiments, the specific steps in step S534 include:

[0148] S5341. Calculate the shape factor of the defect area according to the following formula:

[0149] ;

[0150] in, is the shape factor of the defect area, is the area of ​​the defect region, is the perimeter of the defect area.

[0151] The shape factor is calculated using the above formula. Here, area S represents the area of ​​the minimum circumscribed rectangle of the defect region's pixel coordinates. Perimeter C is obtained by extracting the edge pixel coordinates of the defect region using a chain code tracking algorithm and calculating their length. The constant 4π is used to ensure the normalization of the shape factor calculation. This allows the shape factor to be quantified and used to characterize the shape characteristics of the defect region, providing a quantitative basis for subsequent fine-grained defect classification.

[0152] Specifically, the shape factor calculation first determines the area S of the defect region. Generally, because the physical area of ​​a single pixel is very small, the area of ​​the minimum bounding rectangle of the defect region's pixel coordinates is approximately equal to the total area of ​​all pixels within the defect region in the defect mask image. Specifically, the area S can be calculated by counting the number of pixels within 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 is negligible). Next, a 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 calculated by calculating the length of the edge pixel coordinates. Finally, the area S and perimeter C are substituted into the shape factor calculation formula to calculate the shape factor F. The shape factor F quantitatively describes the shape of the defect region, providing shape feature parameters for the subsequent support vector machine classifier to perform fine-grained defect classification. The introduction of the constant 4π makes the shape factor values ​​of defects of different shapes comparable, ensuring the consistency and accuracy of the shape feature quantification results.

[0153] In some specific embodiments, assuming that the defect area in the defect mask image contains 100 pixels, and the actual area represented by each pixel is 0.01 square millimeters, the area S of the defect area is 1 square millimeter. There are 40 edge pixel coordinates of the defect area extracted by the chain code tracking algorithm, and the length represented by each edge pixel coordinate is approximately 0.1 millimeters, so the perimeter C of the defect area 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 support vector machine classifier to perform fine classification of defects. The above formula is used to calculate the shape factor, which ensures the clarity of the shape factor calculation method, improves the accuracy and consistency of the defect shape feature extraction, and lays the foundation for fine classification of defects.

[0154] Please refer to Figure 2 , Figure 2 In some embodiments of the present invention, a device for detecting minor defects on the surface of doors and windows is provided. The device is integrated into a back-end control device in the form of a computer program and includes:

[0155] The control module 100 is configured to illuminate the matte lacquer wooden door components rotating at high speed using a multi-angle annular dark field lighting device with preset light source parameters, and simultaneously capture an initial image using a high-speed image sensor; the light source parameters include illumination angle, light intensity, or light source grouping;

[0156] A calculation module 200 is configured to calculate the SNR value under current lighting conditions based on the initial image;

[0157] A comparison module 300 is configured to 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;

[0158] An adjustment module 400 is configured to repeatedly calculate the SNR value and adjust the light source parameters until the SNR value reaches an optimal level or a preset stop iteration condition is met;

[0159] The recognition module 500 is used to collect the current image and perform defect recognition and segmentation to obtain defect detection results when the SNR value reaches the optimal level or meets the preset stop iteration condition;

[0160] The generation module 600 is used to generate a test report based on the defect detection results for use in quality monitoring and production traceability.

[0161] In some embodiments, the comparison module 300 is configured to compare the SNR value with a preset SNR threshold value. If the SNR value is lower than the SNR threshold value, the following steps are performed when adjusting the light source parameters of the multi-angle annular dark field illumination device according to a preset optimization strategy:

[0162] S31. When the SNR value is lower than the SNR threshold, the defect classification model is used to identify the defect type in the current image; the defect type includes a scratch defect and a dent defect;

[0163] S32 selects 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 recess defects;

[0164] 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 illumination angle and light intensity of the multi-angle annular dark field illumination device are adjusted according to the set of light source parameters;

[0165] 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 lighting device are adjusted according to the set of light source parameters.

[0166] In some embodiments, the comparison module 300 performs the following when used to identify the defect type in the current image using the defect classification model:

[0167] S311. Preprocess the initial image by using Gaussian filtering to reduce noise and histogram equalization to enhance contrast to obtain a first preprocessed image;

[0168] S312. Input the first preprocessed image into a defect classification model, and calculate the probability value of the first preprocessed image belonging to a scratch defect and a dent defect using 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 containing scratch defects and dent defects, and the deep convolutional neural network is trained using a cross entropy loss function and an Adam optimizer;

[0169] S313. Compare the probability value with the preset probability threshold. If the probability value of the scratch defect is greater than the probability threshold, the defect type is determined to be a scratch defect; if the probability value of the dent defect is greater than the probability threshold, the defect type is determined to be a dent defect; if the probability values ​​of both the scratch defect and the dent defect are less than the probability threshold, then it is determined to be other types of defects.

[0170] In some embodiments, the comparison module 300 performs the following when preprocessing the initial image by using Gaussian filtering to reduce noise and using histogram equalization to enhance contrast to obtain the first preprocessed image:

[0171] S3111 analyzes the brightness distribution of the initial image. If it is determined that the brightness distribution of the initial image is uneven, a histogram equalization algorithm with brightness compensation is used to enhance the contrast to obtain a brightness-balanced image.

[0172] 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. Use the adaptively adjusted filtering parameters to perform Gaussian filtering and noise reduction on the brightness equalized image to obtain a first preprocessed image.

[0173] In some embodiments, when the SNR value reaches an optimal level or satisfies a preset stop iteration condition, the recognition module 500 captures the current image and performs defect recognition and segmentation to obtain a defect detection result, and executes:

[0174] S51. Preprocess the current image by using median filtering to remove noise and adaptive histogram equalization to enhance local contrast to obtain a second preprocessed image;

[0175] S52. Using the trained Mask R-CNN model, 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 pixel-level defect segmentation;

[0176] S53. Calculate the area, perimeter, and shape factor of the defect region according to the defect mask image, and use the area, perimeter, and shape factor as defect features;

[0177] S54. Based on the defect characteristics, use a support vector machine classifier to finely classify the defect type to obtain a defect detection result. The defect detection result includes the defect location, defect type and defect characteristics.

[0178] In some embodiments, the recognition module 500 performs the following steps when preprocessing the current image, removing noise using median filtering, and enhancing local contrast using adaptive histogram equalization to obtain the second preprocessed image:

[0179] S511. Convert the current image to the HSV color space and extract the brightness component V;

[0180] S512. The luminance component V is smoothed using a guided filter to obtain a luminance background image; the guided image of the guided filter is the luminance component V itself, and the filter radius of the guided filter is adaptively adjusted according to the resolution of the current image;

[0181] S513. According to the brightness of the background image, calculate the brightness correction coefficient, and use the brightness correction coefficient to perform brightness correction on the three RGB color channels of the current image to obtain a brightness-corrected image;

[0182] S514. Using median filtering to remove noise from the brightness corrected image to obtain a third preprocessed image;

[0183] S515. Dividing the third preprocessed image into a plurality of non-overlapping image blocks, and calculating the local contrast of each image block;

[0184] S516. Adaptively adjust the parameters of the 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.

[0185] In some embodiments, the recognition module 500 is configured 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 when performing the following operations:

[0186] S531. Extracting a set of pixel coordinates of a defective area according to the defect mask image;

[0187] S532. Calculate the minimum bounding rectangle of the pixel coordinate set, and use the area of ​​the minimum bounding rectangle as the area of ​​the defect area;

[0188] S533. According to the defect mask image, the chain code tracking algorithm is used to extract the edge pixel coordinates of the defect area from the pixel coordinate set, and the length of the edge pixel coordinates is calculated to obtain the perimeter of the defect area;

[0189] S534. Calculate the shape factor of the defect region according to the area and the perimeter of the defect region.

[0190] In some embodiments, the identification module 500 performs the following when calculating the shape factor of the defect region according to the area and the perimeter of the defect region:

[0191] S5341. Calculate the shape factor of the defect region according to the following formula:

[0192] ;

[0193] wherein, is the shape factor of the defect region, is the area of the defect region, is the perimeter of the defect region.

[0194] Please refer to Figure 3 , Figure 3 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. The present application provides an electronic device 13, which comprises 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 mechanism (not shown). The memory 1302 stores computer readable instructions executable by the processor 1301. When the electronic device is running, the processor 1301 executes the computer readable instructions to execute the door and window surface micro flaw detection method in any optional implementation manner of the above-mentioned embodiments, so as to realize the following functions: using a multi-angle ring-shaped dark field illumination device, illuminating a high-speed flowing matte paint surface wooden door part with preset light source parameters, and synchronously collecting an initial image using a high-speed image sensor; the light source parameters include an illumination angle, an illumination intensity or a light source grouping; calculating an SNR value under a current illumination condition according to the initial image; comparing the SNR value with a preset SNR threshold value, if the SNR value is lower than the SNR threshold value, adjusting the light source parameters of the multi-angle ring-shaped dark field illumination device according to a preset optimization strategy; repeating the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches an optimal level or meets a preset stop iteration condition; when the SNR value reaches the optimal level or meets the preset stop iteration condition, collecting a current image and performing defect identification and segmentation to obtain a defect detection result; generating a detection report according to the defect detection result.

[0195] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for detecting minor defects on the surface of doors and windows in any optional implementation of the above-mentioned embodiment is executed to achieve the following functions: using a multi-angle annular dark-field lighting device to illuminate high-speed matte painted wooden door components with preset light source parameters, and using a high-speed image sensor to synchronously capture an initial image; the light source parameters include illumination angle, light intensity or light source grouping; calculating the SNR value under current lighting conditions based on the initial image; 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; repeating the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches an optimal level or meets a preset stop iteration condition; when the SNR value reaches an optimal level or meets a preset stop iteration condition, capturing the current image and performing defect identification and segmentation to obtain a defect detection result; and generating a detection report based on the defect detection result.

[0196] 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), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0197] 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 merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interface, the indirect coupling or communication connection of the device or unit may be electrical, mechanical or other forms.

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

[0199] Furthermore, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

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

[0201] The foregoing description is merely an embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Those skilled in the art will readily appreciate that the present invention is susceptible to various modifications and variations. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection 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. Utilize a multi-angle annular dark-field illumination device to illuminate a high-speed rotating matte-finished wooden door component using preset light source parameters, and simultaneously capture 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 based on the initial image; S3 compares 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; 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 satisfies the preset stop iteration condition; S5. When the SNR value reaches the optimal level or meets the preset stop iteration condition, the current image is collected and defect recognition and segmentation are performed to obtain a defect detection result; S6. Generate a test report based on the defect detection results; The specific steps in step S3 include: S31. When the SNR value is lower than the SNR threshold, the defect classification model is used to identify the defect type in the current image; 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 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 illumination 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; The specific steps in step S31 include: S311. Preprocessing the initial image by using Gaussian filtering to reduce noise and histogram equalization to enhance contrast to obtain a first preprocessed image; S312. Input the first pre-processed image into the defect classification model, and calculate the probability value of the first pre-processed image being a scratch defect or a dent defect using 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 containing scratch defects and dent defects, and the deep convolutional neural network is trained using 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, the defect type is determined to be a scratch defect; if the probability value of the dent defect is greater than the probability threshold, the defect type is determined to be a dent defect; if the probability values ​​of the scratch defect and the dent defect are both less than the probability threshold, they are determined to be other types of defects.

2. The method for detecting minor defects on door and window surfaces according to claim 1, 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, a histogram equalization algorithm with brightness compensation is used to enhance the contrast to obtain a brightness-balanced 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.

3. The method for detecting minor defects on door and window surfaces according to claim 1, characterized in that: The defect classification model is trained by the following steps: A1. Build a deep convolutional neural network consisting of multiple convolutional and pooling layers. A2. Construct a dataset containing scratch defect sample sets, dent defect sample sets, wood texture sample sets, and paint particle noise sample sets. 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 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.

4. The method for detecting minor defects on door and window surfaces according to claim 1, characterized in that: The specific steps in step S5 include: S51. Preprocessing the current image by using median filtering to remove noise and using adaptive histogram equalization to enhance local contrast 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 localization, and a mask branch for pixel-level defect segmentation; S53. Calculate the area, perimeter, and shape factor of the defect region 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 finely classify the defect type to obtain a defect detection result, which includes the defect location, defect type and defect characteristics.

5. The method for detecting minor defects on the surface of doors and windows according to claim 4, 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 luminance component V using a guided filter to obtain a luminance background image; the guided image of the guided filter is the luminance component V itself, and the filter radius of the guided filter is adaptively adjusted according to the resolution of the current image; S513. Calculate a brightness correction coefficient based on the brightness background image, and use the brightness correction coefficient to perform brightness correction on the three RGB color channels of the current image 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. Dividing the third pre-processed image into a plurality of non-overlapping image blocks, and calculating the local contrast of each image block; S516. Adaptively adjust the parameters of the 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.

6. A device for detecting minor defects on the surface of doors and windows, characterized in that: include: The control module is used to use a multi-angle annular dark field lighting device to illuminate the high-speed matte The lacquered wooden door components are illuminated and an initial image is synchronously captured using a high-speed image sensor; the light source parameters include illumination angle, light intensity or light source grouping; A calculation module, configured to calculate an SNR value under current lighting conditions based on the initial image; A comparison module is used to compare 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 is used to repeatedly perform the calculation of the SNR value and the adjustment of the light source parameters until the SNR value reaches Reach the optimal level or meet the preset stopping conditions; The recognition module is used to collect the current image when the SNR value reaches the optimal level or meets the preset stop iteration condition. Image and perform defect recognition and segmentation to obtain defect detection results; A generation module, configured to generate a test report based on the defect detection results for use in quality monitoring and production traceability; The comparison module is used 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 lighting device are adjusted according to the preset optimization strategy. S31. When the SNR value is lower than the SNR threshold, the defect classification model is used to identify the defect type in the current image; the defect type includes a scratch defect and a dent defect; S32 selects 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 recess 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 illumination 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; The comparison module is executed when it is used to identify the defect type in the current image using the defect classification model: S311. Preprocess the initial image by using Gaussian filtering to reduce noise and histogram equalization to enhance contrast to obtain a first preprocessed image; S312. Input the first preprocessed image into a defect classification model, and calculate the probability value of the first preprocessed image belonging to a scratch defect and a dent defect using 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 containing scratch defects and dent defects, and the deep convolutional neural network is trained using 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, the defect type is determined to be a scratch defect; if the probability value of the dent defect is greater than the probability threshold, the defect type is determined to be a dent defect; if the probability values ​​of both the scratch defect and the dent defect are less than the probability threshold, then it is determined to be other types of defects.

7. 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 minor defects on the surface of doors and windows as described in any one of claims 1 to 5 are executed.

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

Citation Information

Patent Citations

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

    CN118731044A