Visual model-based knitted fabric defect detection method and system

By combining adaptive light source intensity adjustment and multi-scale convolutional neural networks with attention mechanisms and autoencoders, the problems of low efficiency and misjudgment in traditional methods for detecting defects in knitted fabrics are solved, achieving efficient and accurate defect detection and localization.

CN120932013APending Publication Date: 2025-11-11SICHUAN JUNQIAO KNITTING GARMENT CO LTD
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202511102747.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-07
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In the current technology, the detection of defects in knitted fabrics relies on manual visual inspection or traditional machine vision methods, which are inefficient, have a high rate of missed detection, and lack standardized methods. They are difficult to adapt to the needs of large-scale industrial production. In addition, traditional methods have low sensitivity to recognize complex textures and structures, and are prone to misjudgment or missed detection.

Method used

A vision-based detection method is adopted, which learns the normal texture distribution through adaptive light source intensity adjustment, multi-scale convolutional neural network, attention mechanism and autoencoder, and combines fractal dimension difference measurement to form a composite error value, so as to accurately judge and locate defects.

Benefits of technology

It improves the accuracy and efficiency of defect detection in knitted fabrics, reduces false positives, lowers labor costs, and is suitable for various knitted fabric inspection scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120932013A_ABST
    Figure CN120932013A_ABST
Patent Text Reader

Abstract

The invention discloses a knitted fabric defect detection method and system based on a visual model, and relates to the technical field of defect detection, and the detection steps are as follows: S1, based on the surface color intensity of a to-be-detected knitted fabric, adaptively adjusting the light source intensity, and reducing fabric reflection; s2, acquiring image data of the knitted fabric to be detected based on a camera, preprocessing the image data and then integrating the image data into a data set; s3, extracting shallow-layer, middle-layer and deep-layer features of the preprocessed image based on a multi-scale convolutional neural network; and S4, performing weighted fusion on the multi-scale features by using an attention mechanism, and learning feature distribution of normal textures through an auto-encoder. By enhancing sensitivity to fine defects, judging defects based on composite errors, accurately classifying and positioning, and reducing misjudgment, the method provides a basis for quality evaluation and automatic repair, reduces labor cost, improves quality inspection efficiency, and is suitable for efficient quality inspection scenes of various knitted fabrics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, specifically to a method and system for detecting defects in knitted fabrics based on a visual model. Background Technology

[0002] Knitted fabrics, with their softness, breathability, and elasticity, are widely used in clothing, home textiles, and industrial textiles. During their production, factors such as raw material quality, equipment precision, and process parameters can easily lead to texture defects like holes, stains, snags, and twisted loops, directly impacting product quality and market competitiveness. Therefore, efficient and accurate defect detection in knitted fabrics is a crucial step in ensuring production quality. Currently, defect detection in knitted fabrics mainly relies on manual visual inspection or traditional machine vision methods. Manual inspection is affected by subjective experience and fatigue, resulting in low efficiency, high false negative rates, and inconsistent standards, making it difficult to meet the needs of large-scale industrial production. Traditional machine vision methods are mostly based on pixel-level errors or single texture features for defect judgment, but their limitations are significant: on the one hand, knitted fabric textures have both periodic and random characteristics, and the surface is prone to highlight areas due to material reflection, leading to the loss of texture details during image acquisition. The image quality stability under traditional fixed light sources is poor, directly affecting the accuracy of subsequent feature extraction. On the other hand, traditional methods are insufficient in depicting the complex structure of textures (such as the density and twisting of loops), and it is difficult to distinguish between real defects and normal texture fluctuations based on pixel-level differences alone. In particular, the sensitivity for identifying structural defects such as minor fraying and loop deformation is low, easily leading to misjudgment or false negatives. To address these issues, we propose a knitted fabric defect detection method and system based on a vision model. Summary of the Invention

[0003] To address the aforementioned technical problems, a visual model-based method and system for detecting defects in knitted fabrics is provided. This technical solution resolves the problems described above.

[0004] To achieve the above objectives, the technical solution adopted by this invention is: a method for detecting defects in knitted fabrics based on a visual model, wherein the detection steps are as follows: S1. Based on the color intensity of the knitted fabric surface to be detected, the light source intensity is adaptively adjusted to reduce fabric reflection; S2. Collect image data of the knitted fabric to be detected based on the camera, and integrate the image data into a dataset after preprocessing. S3. Extract shallow, middle and deep features of the preprocessed image based on a multi-scale convolutional neural network; S4. Use attention mechanism to weighted fuse multi-scale features and learn the feature distribution of normal texture through autoencoder; S5. Introduce a fractal dimension difference measure. For the feature distribution of knitted fabric texture, calculate the fractal dimension of the local window for the reconstructed image and the original image respectively. Combine the traditional pixel-level error with the fractal dimension deviation to form a composite error value of texture defect characteristics. S6. Based on the comparison results between the error value and the preset threshold, determine whether there is a defect, and classify and locate the areas with defects.

[0005] Preferably, in step S1, the hardware system is built in advance, and based on the requirements for detecting defects in knitted fabrics, the effective gray value range of non-reflective materials in the image is defined. Based on the common colors of knitted fabrics, color intensity levels are divided, and different levels correspond to different initial light source intensity ranges. Acquire and preprocess fabric images, crop the effective area, and perform grayscale conversion and noise reduction; Calculate the average gray value of the area to determine the color intensity level; To avoid glare and ensure clear texture, the required light source intensity adjustment is calculated based on the brightness range deviation. The calculated adjustment amount is converted into a control signal, and the brightness is adjusted by controlling the output light source.

[0006] Preferably, the data preprocessing in step S2 includes image correction, noise reduction, size normalization, and image enhancement. Image correction eliminates camera distortion and adjusts pixel positions through calibration parameters to ensure geometric accuracy of the image. Noise reduction uses Gaussian filtering to remove noise caused by light and sensor noise during image acquisition, while preserving fabric texture details. Size normalization scales the image to a fixed resolution. Image enhancement adjusts contrast and brightness using histogram equalization to improve the distinction between the knitted fabric texture and the background.

[0007] Preferably, the specific steps of the multi-scale convolutional neural network in step S3 are as follows: Construct a multi-scale network containing multiple convolutional blocks, each of which consists of convolutional kernels of different sizes, and capture features at different scales through parallel convolutional operations; The input preprocessed image is processed through the first few convolutional layers to extract low-level visual features of edges, textures and colors, while preserving image detail information. The non-linear expression is enhanced by the ReLU activation function. The shallow features are aggregated by the middle convolutional blocks, and multi-scale local features are fused to generate the middle semantic features of the contour and regional structure. The dimensionality is reduced and the robustness is enhanced by the pooling layer. Deep convolutional layers further abstract mid-level features and combine them with skip connections to fuse shallow details, outputting high-level features that contain global semantics.

[0008] Preferably, the attention mechanism in step S4 performs weighted fusion of multi-scale features as follows: The shallow, medium and deep feature maps extracted by the multi-scale convolutional network are used as input, and global average pooling and global max pooling are performed on the feature maps at each scale to compress the spatial dimension. Spatial attention weight maps are generated using convolutional layers and activation functions to characterize the importance of different locations. The feature maps at each scale are compressed along the channel dimension, and channel attention weights are generated through fully connected layers and activation functions to characterize the importance of different feature channels. The original feature map is multiplied element-wise with the corresponding spatial and channel attention weights to enhance the feature response of important regions and channels; The number of channels for features at each scale is unified by 1×1 convolution, and the sum is obtained by weighting according to the learnable weight coefficients to obtain the fused multi-scale features.

[0009] Preferably, the step in S4, which involves learning the feature distribution of a normal texture using an autoencoder, is as follows: Collect images of defect-free normal knitted fabrics to construct a training set, providing a foundation for the model to learn normal texture features; By using convolutional and pooling layers to extract features and reduce the dimensionality of the input image, the image is compressed into a low-dimensional feature vector, the essential features of the texture are extracted, noise and redundant information are removed, and a latent space vector containing the core features of normal texture is generated. By using deconvolutional layers and upsampling layers to increase the dimensionality of latent spatial features, the image size is gradually restored. The low-dimensional feature vectors are reconstructed into an output image with the same size as the original input image, thus learning the mapping relationship from features to image; By optimizing the algorithm to minimize the pixel-level difference between the input image and the reconstructed image, the autoencoder focuses on capturing the common feature distribution of normal textures, ignoring individual differences and random noise. The test image is used to generate a reconstructed image through a trained autoencoder, and the pixel difference between the original image and the reconstructed image is calculated. An error threshold is set, and areas exceeding the threshold are judged as texture abnormalities.

[0010] Preferably, the texture defect detection process in step S5, which involves fractal dimension difference measurement fusion, includes fractal dimension calculation preparation, local window fractal dimension solution, fractal dimension deviation calculation, pixel-level error calculation, composite error fusion, and defect judgment. Specifically, fractal dimension calculation preparation involves dividing the original image and the reconstructed image output by the autoencoder into overlapping local windows of fixed size, covering all areas of the image, and capturing texture details at different locations. Local window fractal dimension solution involves covering the window with grids of different scales, counting the number of grids containing texture pixels, establishing a double logarithmic relationship between scale and grid number, and the absolute value of the slope is the fractal dimension of the window, reflecting the complexity of the texture.

[0011] Preferably, the fractal dimension deviation calculation is performed by calculating the absolute difference in fractal dimension between the corresponding local windows of the original image and the reconstructed image to obtain the fractal dimension deviation matrix, which quantifies the difference in texture complexity between the two. Traditional pixel-level error calculation uses mean square error to calculate the pixel-level difference between the original image and the reconstructed image, resulting in a pixel error matrix that reflects the direct deviation of grayscale values. The composite error value fusion is based on the texture characteristics of knitted fabrics. The weighting coefficients of pixel-level error and fractal dimension deviation are determined by cross-validation. The two error matrices are then summed point by point to obtain the composite error value. A composite error threshold is set for defect determination. Areas exceeding the threshold are determined to be texture defects. Post-processing is performed based on the spatial continuity of the local window to output the final defect detection result.

[0012] Preferably, in step S6, the defect area is located by using an edge detection algorithm to determine the contour boundary, record the coordinate information of the boundary pixels, calculate the minimum bounding rectangle of the defect area, output the coordinates of the upper left and lower right corners of the rectangle, locate the position in the image, and combine the actual size ratio of the knitted fabric to convert the image coordinates into physical position parameters to determine the position of the defect on the knitted fabric.

[0013] A visual model-based defect detection system for knitted fabrics, the defect detection system comprising: The adaptive light source adjustment module adjusts the light source intensity based on the color intensity of the knitted fabric surface to reduce fabric reflection. The acquisition module acquires image data of the surface of the knitted fabric to be inspected based on the camera; The calculation and analysis module calculates and analyzes the image data to determine whether there are defects on the surface of the knitted fabric to be inspected; The defect location module classifies and locates areas with defects.

[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention adaptively adjusts the light source intensity to reduce reflection based on the color intensity of the knitted fabric surface, ensuring clear images and providing high-quality data for subsequent processing. A multi-scale convolutional neural network combined with an attention mechanism comprehensively extracts shallow, medium, and deep features and enhances key information, improving the accuracy of feature representation. An autoencoder learns normal texture distribution and integrates fractal dimension differences with pixel-level errors to form a composite error, which better matches the texture characteristics of the knitted fabric and enhances sensitivity to subtle defects. Based on the composite error, defects are accurately classified and located, reducing misjudgments and providing a basis for quality assessment and automated repair. This reduces labor costs, improves quality inspection efficiency, and is suitable for various high-efficiency quality inspection scenarios for knitted fabrics. Attached Figure Description

[0015] Figure 1 This is a flowchart of the detection steps of the present invention; Figure 2 This is a block diagram of the defect detection system of the present invention. Detailed Implementation

[0016] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.

[0017] Reference Figure 1 As shown, a method for detecting defects in knitted fabrics based on a visual model includes the following detection steps: S1. Based on the color intensity of the knitted fabric surface to be detected, the light source intensity is adaptively adjusted to reduce fabric reflection; S2. Collect image data of the knitted fabric to be detected based on the camera, and integrate the image data into a dataset after preprocessing. S3. Extract shallow, middle and deep features of the preprocessed image based on a multi-scale convolutional neural network; S4. Use attention mechanism to weighted fuse multi-scale features and learn the feature distribution of normal texture through autoencoder; S5. Introduce a fractal dimension difference measure. For the feature distribution of knitted fabric texture, calculate the fractal dimension of the local window for the reconstructed image and the original image respectively. Combine the traditional pixel-level error with the fractal dimension deviation to form a composite error value of texture defect characteristics. S6. Based on the comparison results between the error value and the preset threshold, determine whether there is a defect, and classify and locate the areas with defects.

[0018] This application adaptively adjusts the light source intensity to reduce reflection based on the color intensity of the knitted fabric surface, ensuring clear images and providing high-quality data for subsequent processing. A multi-scale convolutional neural network combined with an attention mechanism comprehensively extracts shallow, medium, and deep features and enhances key information, improving the accuracy of feature representation. An autoencoder learns the normal texture distribution and integrates fractal dimension differences and pixel-level errors to form a composite error, which better matches the texture characteristics of knitted fabrics and enhances sensitivity to subtle defects. Based on the composite error, defects are judged, accurately classified and located, reducing misjudgments and providing a basis for quality assessment and automated repair. This reduces labor costs, improves quality inspection efficiency, and is suitable for various high-efficiency quality inspection scenarios for knitted fabrics.

[0019] In step S1, the hardware system is built in advance. Based on the requirements for detecting defects in knitted fabrics, the effective gray value range of non-reflective elements in the image is defined. Based on the common colors of knitted fabrics, color intensity levels are divided, and different levels correspond to different initial light source intensity ranges. Acquire and preprocess fabric images, crop the effective area, and perform grayscale conversion and noise reduction; Calculate the average gray value of the area to determine the color intensity level; To avoid glare and ensure clear texture, the required light source intensity adjustment is calculated based on the brightness range deviation. The calculated adjustment amount is converted into a control signal, and the brightness is adjusted by controlling the output light source.

[0020] This application provides a precise benchmark for light source adjustment by pre-building a hardware system, defining effective grayscale ranges, and dividing color intensity levels. This avoids adjustment deviations caused by fuzzy initial parameters. The preprocessing of acquired images, cropping effective areas, and grayscale denoising focuses on key areas, reduces interference from irrelevant information, and ensures accurate color intensity judgment. The level is determined based on the average grayscale value, and the adjustment amount is calculated in combination with the brightness deviation. This makes the light source adjustment more closely match the actual color and reflectivity of the fabric, achieving "on-demand dimming." Finally, the adjustment amount is converted into a control signal to precisely adjust the brightness. This avoids excessive reflection from obscuring the texture while ensuring that the texture is clearly discernible. This lays a high-quality data foundation for subsequent image acquisition and defect detection, and improves the stability and reliability of the entire detection system.

[0021] The data preprocessing in step S2 includes image correction, noise reduction, size normalization, and image enhancement. Image correction eliminates camera distortion and adjusts pixel positions through calibration parameters to ensure geometric accuracy of the image. Noise reduction uses Gaussian filtering to remove noise caused by light and sensor noise during image acquisition, while preserving fabric texture details. Size normalization scales the image to a fixed resolution. Image enhancement adjusts contrast and brightness using histogram equalization to improve the distinction between the knitted fabric texture and the background.

[0022] This application's Gaussian filtering noise reduction removes light and sensor noise while preserving the texture details of knitted fabrics to the greatest extent and reducing the interference of noise on defect identification; size standardization scales the image to a fixed resolution, eliminating feature scale differences caused by different sizes, which facilitates stable model learning; histogram equalization adjusts contrast and brightness, enhances the distinction between texture and background, and makes key features of coils and textures clearer.

[0023] The specific steps of the multi-scale convolutional neural network in step S3 are as follows: Construct a multi-scale network containing multiple convolutional blocks, each of which consists of convolutional kernels of different sizes, and capture features at different scales through parallel convolutional operations; The input preprocessed image is processed through the first few convolutional layers to extract low-level visual features of edges, textures and colors, while preserving image detail information. The non-linear expression is enhanced by the ReLU activation function. The shallow features are aggregated by the middle convolutional blocks, and multi-scale local features are fused to generate the middle semantic features of the contour and regional structure. The dimensionality is reduced and the robustness is enhanced by the pooling layer. Deep convolutional layers further abstract mid-level features and combine them with skip connections to fuse shallow details, outputting high-level features that contain global semantics.

[0024] The nonlinear expression of the ReLU activation function is as follows: F(x) = max(0, x) The function introduces a non-linear transformation into the multi-scale convolutional neural network by retaining positive values ​​in the input (i.e., outputting x when input x≥0 and discarding negative values, and outputting 0 when input x<0). This characteristic enables the network to learn the complex non-linear features in knitted fabric textures, avoiding the model's limitation of linear mapping. At the same time, sparse activation reduces redundant computation, improves feature extraction efficiency, and ensures that the non-linear correlation between texture details and semantic information is effectively captured in the feature transfer from shallow to deep layers.

[0025] The attention mechanism in step S4 performs a weighted fusion of multi-scale features as follows: The shallow, medium and deep feature maps extracted by the multi-scale convolutional network are used as input, and global average pooling and global max pooling are performed on the feature maps at each scale to compress the spatial dimension. Spatial attention weight maps are generated using convolutional layers and activation functions to characterize the importance of different locations. The feature maps at each scale are compressed along the channel dimension, and channel attention weights are generated through fully connected layers and activation functions to characterize the importance of different feature channels. The original feature map is multiplied element-wise with the corresponding spatial and channel attention weights to enhance the feature response of important regions and channels; The number of channels for features at each scale is unified by 1×1 convolution, and the sum is obtained by weighting according to the learnable weight coefficients to obtain the fused multi-scale features.

[0026] The formula for weighted summation is: in Indicates the first Original feature maps at different scales (shallow, intermediate, and deep); This is a spatial attention weighting map for the corresponding scale; Channel attention weights; This indicates element-wise multiplication, achieving weighted enhancement of the feature map and attention weights; This is a 1×1 convolution operation used to unify the number of channels for features at different scales; Learnable cross-scale weight coefficients (satisfying) ), representing the fusion ratio of features at different scales; This is the final fused multi-scale feature map; This formula enhances key features through an attention mechanism, unifies dimensions through 1×1 convolution, and dynamically balances scale contributions through learnable weights, thereby achieving effective fusion of multi-scale features.

[0027] The step in step S4, which involves learning the feature distribution of normal textures using an autoencoder, is as follows: A large number of defect-free normal knitted fabric images were collected to construct a dedicated training set. These images cover the texture morphology of various normal knitted fabrics, providing sufficient and comprehensive basic data for the model to learn the core features of normal textures, ensuring that the model can fully understand the general rules of normal textures. By using convolutional and pooling layers to process the input normal image, the convolutional layer is responsible for extracting the key features of the texture in the image, while the pooling layer simplifies the data through dimensionality reduction, gradually compressing the original image into a low-dimensional feature vector. This process can accurately extract the essential features of the texture, while filtering out noise and redundant information in the image. The resulting low-dimensional vector is like the "fingerprint" of the texture, condensing the core characteristics of the normal texture and forming a feature representation in the latent space. The model utilizes deconvolutional and upsampling layers to upsize the low-dimensional feature vectors in the latent space. The deconvolutional layer gradually restores the spatial dimension of the features, while the upsampling layer continuously expands the size of the feature map, so that the low-dimensional feature vectors are gradually restored to an output image with the same size as the original input image. In this process, the model continuously learns the mapping relationship from low-dimensional features to the complete image and learns how to reconstruct an image that conforms to normal texture rules based on the core features. The model is trained by optimizing the algorithm, with the goal of minimizing the pixel-level difference between the original input image and the reconstructed output image. By continuously adjusting the model parameters, the reconstructed image is made as close as possible to the original image, so that the autoencoder focuses on capturing the common feature distribution of normal textures and automatically ignores the subtle individual differences between different normal samples and irrelevant random noise in the image, thereby forming a stable representation of normal textures. For the test image to be detected, it is input into the trained autoencoder to generate a corresponding reconstructed image. The pixel difference between the original test image and the reconstructed image is calculated to measure the degree of deviation between the two. A reasonable error threshold is set. When the pixel difference in a certain region exceeds the threshold, it is determined that the region has texture abnormalities, i.e., it may contain defects. This method achieves effective defect identification by comparing the reconstruction capability of normal textures.

[0028] The texture defect detection process in step S5, which uses fractal dimension difference measurement fusion, includes fractal dimension calculation preparation, local window fractal dimension solution, fractal dimension deviation calculation, pixel-level error calculation, composite error fusion, and defect judgment. Specifically, fractal dimension calculation preparation involves dividing the original image and the reconstructed image from the autoencoder output into overlapping local windows of fixed sizes, covering all areas of the image and capturing texture details at different locations. Local window fractal dimension solution involves covering the window with grids of different scales, counting the number of grids containing texture pixels, establishing a double logarithmic relationship between scale and grid number, and the absolute value of the slope is the fractal dimension of the window, reflecting the complexity of the texture.

[0029] This application divides overlapping local windows into fixed sizes, which can comprehensively cover all areas of the image and avoid misjudgment of defects caused by missing local texture details. It is especially suitable for the characteristics of knitted fabric textures that may vary in different locations, ensuring the capture of subtle texture changes. It uses grids of different scales to calculate the fractal dimension and solves the slope by establishing a double logarithmic relationship between scale and grid number, which can accurately quantify the complexity of the texture (such as the density of coils and the self-similarity of twists). Compared with single-scale analysis, this method can better fit the fractal characteristics of knitted fabric textures and effectively distinguish the natural complexity of normal textures from structural anomalies caused by defects (such as the sudden change in fractal dimension caused by the break in texture continuity at holes).

[0030] Fractal dimension deviation calculation calculates the absolute difference in fractal dimension between the original image and the reconstructed image by taking corresponding local windows, and obtains the fractal dimension deviation matrix, which quantifies the difference in texture complexity between the two. Traditional pixel-level error calculation uses mean square error to calculate the pixel-level difference between the original image and the reconstructed image, resulting in a pixel error matrix that reflects the direct deviation of grayscale values. The composite error value fusion is based on the texture characteristics of knitted fabrics. The weighting coefficients of pixel-level error and fractal dimension deviation are determined by cross-validation. The two error matrices are then summed point by point to obtain the composite error value. A composite error threshold is set for defect determination. Areas exceeding the threshold are determined to be texture defects. Post-processing is performed based on the spatial continuity of the local window to output the final defect detection result.

[0031] This application's fractal dimension deviation calculation quantifies the difference in texture complexity between the original and reconstructed images, capturing structural anomalies (such as texture continuity disruption caused by coil breakage) that are difficult to reflect by traditional pixel-level errors, providing a structural basis for defect detection. Traditional pixel-level errors reflect direct deviations in grayscale values ​​through mean square error, effectively identifying grayscale abrupt changes caused by stains, thus complementing fractal dimension deviation. Composite error fusion determines weights through cross-validation, weightedly integrating structural differences and grayscale deviations. This retains the sensitivity of pixel-level errors to surface defects while enhancing the ability of fractal dimension deviation to identify internal texture anomalies, avoiding the limitations of a single error standard (such as relying solely on grayscale differences may miss structural defects, and relying solely on fractal deviations may misjudge normal grayscale fluctuations).

[0032] In step S6, the defect area is located by using an edge detection algorithm to determine the contour boundary, record the coordinate information of the boundary pixels, calculate the minimum bounding rectangle of the defect area, output the coordinates of the upper left and lower right corners of the rectangle, locate its position in the image, and combine the actual size ratio of the knitted fabric to convert the image coordinates into physical position parameters to determine the position of the defect on the knitted fabric.

[0033] By accurately extracting the defect contour boundary and recording the coordinates through edge detection algorithms, the defect morphology is accurately captured, providing basic morphological data for subsequent analysis. The minimum bounding rectangle is calculated and its coordinates are output, enabling rapid positioning of the defect in the image with simple geometric parameters, facilitating intuitive identification of the defect's location range. By combining the actual size ratio, the image coordinates are converted into physical position parameters, establishing a connection between image information and the fabric entity, allowing the defect location to correspond to the actual physical space of the knitted fabric.

[0034] Reference Figure 2 As shown, a visual model-based defect detection system for knitted fabrics includes: The adaptive light source adjustment module adjusts the light source intensity based on the color intensity of the knitted fabric surface to reduce fabric reflection. The acquisition module acquires image data of the surface of the knitted fabric to be inspected based on the camera; The calculation and analysis module calculates and analyzes the image data to determine whether there are defects on the surface of the knitted fabric to be inspected; The defect location module classifies and locates areas with defects.

[0035] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.

Claims

1. A method for detecting defects in knitted fabrics based on a visual model, characterized in that, The testing steps are as follows: S1. Based on the color intensity of the knitted fabric surface to be detected, the light source intensity is adaptively adjusted to reduce fabric reflection; S2. Collect image data of the knitted fabric to be detected based on the camera, and integrate the image data into a dataset after preprocessing. S3. Extract shallow, middle and deep features of the preprocessed image based on a multi-scale convolutional neural network; S4. Use attention mechanism to weighted fuse multi-scale features and learn the feature distribution of normal texture through autoencoder; S5. Introduce a fractal dimension difference measure. For the feature distribution of knitted fabric texture, calculate the fractal dimension of the local window for the reconstructed image and the original image respectively. Weightedly fuse the traditional pixel-level error and the fractal dimension deviation to form a composite error value of texture defect characteristics. S6. Based on the comparison results between the error value and the preset threshold, determine whether there is a defect, and classify and locate the areas with defects.

2. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: In step S1, the hardware system is built in advance. Based on the requirements for detecting defects in knitted fabrics, the effective gray value range of non-reflective elements in the image is defined. Based on the common colors of knitted fabrics, color intensity levels are divided, and different levels correspond to different initial light source intensity ranges. Acquire and preprocess fabric images, crop the effective area, and perform grayscale conversion and noise reduction; Calculate the average gray value of the area to determine the color intensity level; To avoid glare and ensure clear texture, the required light source intensity adjustment is calculated based on the brightness range deviation. The calculated adjustment amount is converted into a control signal, and the brightness is adjusted by controlling the output light source.

3. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: The data preprocessing in step S2 includes image correction, noise reduction, size normalization, and image enhancement. Image correction eliminates camera distortion and adjusts pixel positions through calibration parameters to ensure geometric accuracy of the image. Noise reduction uses Gaussian filtering to remove noise caused by light and sensor noise during image acquisition, while preserving fabric texture details. Size normalization scales the image to a fixed resolution. Image enhancement adjusts contrast and brightness using histogram equalization to improve the distinction between the knitted fabric texture and the background.

4. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: The specific steps of the multi-scale convolutional neural network in step S3 are as follows: Construct a multi-scale network containing multiple convolutional blocks, each of which consists of convolutional kernels of different sizes, and capture features at different scales through parallel convolutional operations; The input preprocessed image is processed through the first few convolutional layers to extract low-level visual features of edges, textures and colors, while preserving image detail information. The non-linear expression is enhanced by the ReLU activation function. The shallow features are aggregated by the middle convolutional blocks, and multi-scale local features are fused to generate the middle semantic features of the contour and regional structure. The dimensionality is reduced and the robustness is enhanced by the pooling layer. Deep convolutional layers further abstract the mid-level features and combine them with skip connections to fuse shallow details, outputting high-level features that contain global semantics.

5. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: The attention mechanism in step S4 performs a weighted fusion of multi-scale features as follows: The shallow, medium and deep feature maps extracted by the multi-scale convolutional network are used as input, and global average pooling and global max pooling are performed on the feature maps at each scale to compress the spatial dimension. Spatial attention weight maps are generated using convolutional layers and activation functions to characterize the importance of different locations. The feature maps at each scale are compressed along the channel dimension, and channel attention weights are generated through fully connected layers and activation functions to characterize the importance of different feature channels. The original feature map is multiplied element-wise with the corresponding spatial and channel attention weights to enhance the feature response of important regions and channels; The number of channels for features at each scale is unified by 1×1 convolution, and the sum is obtained by weighting according to the learnable weight coefficients to obtain the fused multi-scale features.

6. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: The step in step S4, which involves learning the feature distribution of normal textures using an autoencoder, is as follows: Collect images of defect-free normal knitted fabrics to construct a training set, providing a foundation for the model to learn normal texture features; By using convolutional and pooling layers to extract features and reduce the dimensionality of the input image, the image is compressed into a low-dimensional feature vector, the essential features of the texture are extracted, noise and redundant information are removed, and a latent space vector containing the core features of normal texture is generated. By using deconvolutional layers and upsampling layers to increase the dimensionality of latent spatial features, the image size is gradually restored. The low-dimensional feature vectors are reconstructed into an output image with the same size as the original input image, thus learning the mapping relationship from features to image; By optimizing the algorithm to minimize the pixel-level difference between the input image and the reconstructed image, the autoencoder focuses on capturing the common feature distribution of normal textures, ignoring individual differences and random noise. The test image is used to generate a reconstructed image through a trained autoencoder, and the pixel difference between the original image and the reconstructed image is calculated. An error threshold is set, and areas exceeding the threshold are judged as texture abnormalities.

7. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: The texture defect detection process in step S5, which uses fractal dimension difference measurement fusion, includes fractal dimension calculation preparation, local window fractal dimension solution, fractal dimension deviation calculation, pixel-level error calculation, composite error fusion, and defect judgment. Specifically, fractal dimension calculation preparation involves dividing the original image and the reconstructed image from the autoencoder output into overlapping local windows of fixed sizes, covering all areas of the image and capturing texture details at different locations. Local window fractal dimension solution involves covering the window with grids of different scales, counting the number of grids containing texture pixels, establishing a double logarithmic relationship between scale and grid number, and the absolute value of the slope is the fractal dimension of the window, reflecting the complexity of the texture.

8. The method for detecting defects in knitted fabrics based on a visual model according to claim 7, characterized in that: Fractal dimension deviation calculation calculates the absolute difference in fractal dimension between the original image and the reconstructed image by taking corresponding local windows, and obtains the fractal dimension deviation matrix, which quantifies the difference in texture complexity between the two. Traditional pixel-level error calculation uses mean square error to calculate the pixel-level difference between the original image and the reconstructed image, resulting in a pixel error matrix that reflects the direct deviation of grayscale values. The composite error value fusion is based on the texture characteristics of knitted fabrics. The weighting coefficients of pixel-level error and fractal dimension deviation are determined by cross-validation. The two error matrices are then summed point by point to obtain the composite error value. A composite error threshold is set for defect determination. Areas exceeding the threshold are determined to be texture defects. Post-processing is performed based on the spatial continuity of the local window to output the final defect detection result.

9. The method for detecting defects in knitted fabrics based on a visual model according to claim 1, characterized in that: In step S6, the defect area is located by using an edge detection algorithm to determine the contour boundary, record the coordinate information of the boundary pixels, calculate the minimum bounding rectangle of the defect area, output the coordinates of the upper left and lower right corners of the rectangle, locate its position in the image, and combine the actual size ratio of the knitted fabric to convert the image coordinates into physical position parameters to determine the position of the defect on the knitted fabric.

10. A visual model-based knitted fabric defect detection system, applied to the visual model-based knitted fabric defect detection method described in claims 1 to 9, characterized in that: The defect detection system includes: The adaptive light source adjustment module adjusts the light source intensity based on the color intensity of the knitted fabric surface to reduce fabric reflection. The acquisition module acquires image data of the surface of the knitted fabric to be inspected based on the camera; The calculation and analysis module calculates and analyzes the image data to determine whether there are defects on the surface of the knitted fabric to be inspected; The defect location module classifies and locates areas with defects.

Citation Information

Cited By

  • Deep learning-based air suction powder image quality evaluation method and system

    CN121391887A

  • Meat grading system and method based on machine vision

    CN121837168A

  • A machine vision-based meat grading system and method

    CN121837168B

  • Molding form control method in cellulose acetate production process based on machine vision

    CN122134672A

  • Ceramic product surface defect image detection method and system

    CN122199406A