A method for linking online cloth quality detection and ERP system of a loom
By linking convolutional neural networks with data from weaving equipment, the system automatically identifies and scores fabric defects, overcoming the shortcomings of traditional detection methods. This enables precise defect location and data traceability, supporting production optimization and management.
Patent Information
- Application Number
- CN202611066957.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-17
- Publication Date
- 2026-11-06
AI Technical Summary
Traditional manual inspection methods are insufficient for comprehensive and detailed defect identification of fabrics on high-speed looms. Offline inspection extends the production cycle and the defect information is not sufficiently linked to production records, making it difficult to establish a quality traceability system.
Convolutional neural networks are used to extract surface defect features of fabric, generate defect mask images, and calculate the centroid coordinates of defect areas. Combined with the tension and rotation speed values of the weaving equipment, the defect type is automatically identified and differentiated scoring is performed. The quality inspection data package is then sent to the ERP system simultaneously.
It enables automatic classification of fabric defects, precise identification of responsibility, and traceability of quality data, providing data support for production process optimization and raw material supplier management.
Smart Images

Figure CN123046083A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of fabric inspection technology, and more specifically, to a method for linking online fabric quality inspection on a loom with an ERP system. Background Technology
[0002] As a crucial component of the manufacturing industry, the quality of textile products directly impacts a company's market competitiveness and economic benefits. In the fabric production process, fabric quality inspection is a key step in ensuring product qualification rates.
[0003] While traditional manual inspection methods can detect some quality issues, the high-speed operation of looms and continuous fabric production make it difficult for inspectors to comprehensively identify every minute defect within a limited time. Furthermore, prolonged repetitive work can lead to fatigue and misjudgment. In recent years, some companies have introduced offline inspection equipment, but this method requires removing the fabric from the production line for inspection, which not only extends the production cycle but can also result in large batches of defective products due to time lag, leading to a double waste of raw materials and production time. Even more challenging is the technical bottleneck of accurately locating defect information and linking it to production records. For example, when a defect is detected in a section of fabric, if the specific location of the defect within the entire roll cannot be accurately marked and correlated with production factors such as loom operating parameters and raw material batches, the company cannot conduct effective quality analysis and process improvement. This disconnect between defect location information and production management data directly hinders the establishment of a quality traceability system. Summary of the Invention
[0004] In order to overcome the shortcomings of the existing technology, the present invention provides a method for linking online fabric quality inspection on a loom with an ERP system, aiming to solve the problems in the above-mentioned existing technology.
[0005] The technical solution adopted by this invention to solve its technical problem is: a method for linking online fabric quality inspection on a loom with an ERP system, comprising the following steps: S1: Obtain the fabric surface image detected online, and use a convolutional neural network to extract features from the fabric surface image to obtain a defect mask image representing the defect area; S2: Obtain the mask coordinates of the defect pixels in the defect mask image, and calculate the centroid pixel coordinates of the defect region based on the mask coordinates; S3: Obtain the tension value, rotation speed value, and batch label of the fabric raw material when the weaving equipment generates a defective area; S4: If the tension value is greater than the preset tension threshold and the rotation speed value is greater than the preset rotation speed threshold, the defect type corresponding to the defect area is determined to be a mechanical damage defect, and the mechanical damage defect is scored according to the tension value and rotation speed value. S5: If the tension value is not greater than the preset tension threshold or the rotation speed value is not greater than the preset rotation speed threshold, the defect type corresponding to the defect area is determined to be a raw material damage defect, and the defect score is determined based on the area of the current defect area. S6: Compile the defect type, defect score, center of gravity pixel coordinates, tension value, rotation speed value, and fabric raw material batch identifier into a quality inspection data package and send it to the ERP system database.
[0006] It is worth noting that, in step S1, the step of obtaining the defect mask image representing the defect region includes: Acquire online detection images of fabric surfaces and preprocess the fabric surface images to obtain arrangement feature maps; A convolutional neural network is used to extract features from the arrangement feature map to obtain a defect probability map, and defect connected components are extracted from the defect probability map; Extract the contour edges of the morphological contour of the connected region of the defect; The Sobel operator is used to calculate the gradient components of the pixels at the contour edge in the horizontal and vertical directions, and the gradient magnitude is synthesized. If the gradient magnitude is greater than a preset threshold, the pixel of the contour edge to which the gradient magnitude belongs is marked as a mutation pixel, and the local segment of the contour edge to which the mutation pixel belongs is located to generate a local damaged sub-region. Calculate the Euclidean distance between any two abruptly changed pixels as the center point spacing, and divide the local damaged sub-regions with center point spacing less than a preset distance threshold into the same defect group; find the smallest bounding rectangle of the local damaged sub-regions in the same group as the final defect region, and generate a defect mask image based on the pixel coordinates of the final defect region.
[0007] Preferably, in step S1, the step of preprocessing the surface image to obtain the arrangement feature map includes: The surface texture of the fabric surface image is extracted using a gray-level co-occurrence matrix, the texture period is determined based on the surface texture, and the texture units are divided based on the texture period. The warp and weft interlacing features are extracted from the texture unit using a grayscale projection function. The yarn arrangement pattern is determined based on the warp and weft interlacing features, and the yarn arrangement pattern is mapped into an arrangement feature map.
[0008] Optionally, in step S1, the step of extracting the defect connected components in the defect probability map includes: Pixels with probability values greater than a preset probability threshold in the defect probability map are identified as defect candidate pixels, and pixels with pixel values not greater than the probability threshold in the defect probability map are identified as normal background pixels, thus generating a first binary image. A morphological opening operation is performed on the first binary image using structuring elements of a preset size to obtain a second binary image; Based on the 8-neighborhood connectivity rule and using the Two-Pass two-scan method, the second binary image is labeled with connected components to obtain multiple initial connected components; For the multiple initial connected components obtained, the area of each initial connected component is obtained, and the pixel coordinates in each initial connected component are mapped to the defect probability map. The corresponding probability values are obtained and the average value is calculated to obtain the average probability value of each initial connected component. Based on the area and average probability value of each initial connected component, a minimum defect area threshold and a preset confidence threshold are set. If the area of an initial connected component is less than the minimum defect area threshold or the average probability value is lower than the preset confidence threshold, the corresponding initial connected component is removed, and the retained initial connected components are determined as defect connected components.
[0009] Specifically, in step S2, the step of calculating the centroid pixel coordinates of the defect region includes: Obtain the mask coordinates of the defect pixels in the defect mask image to obtain a defect coordinate set; input the defect coordinate set into the spatial moment calculation tool; The space moment calculation tool sums up all the horizontal coordinates in the defect coordinate set to obtain the total sum of horizontal coordinates. The space moment calculation tool then divides the total sum of horizontal coordinates by the total number of coordinates in the defect coordinate set to obtain the centroid horizontal coordinate. The spatial moment calculation tool sums up all the ordinates in the defect coordinate set to obtain the total sum of the ordinates; the spatial moment calculation tool then divides the total sum of the ordinates by the total number of coordinates in the defect coordinate set to obtain the centroid ordinate. The centroid pixel coordinates of the defect area are determined based on the horizontal and vertical coordinates of the centroid.
[0010] It is worth noting that, in step S3, the steps of obtaining the tension value, rotation speed value, and batch mark of the fabric raw material when the weaving equipment generates a defective area include: Obtain the latch encoder pulse value corresponding to the acquisition of fabric surface image triggered by preset encoder; Obtain a pre-established affine transformation matrix, perform matrix multiplication between the centroid pixel coordinates and the affine transformation matrix to obtain the physical coordinates of the defect; perform matrix multiplication between the reference coordinates of the fabric surface image and the affine transformation matrix to obtain the reference physical coordinates; calculate the physical offset distance of the defect in the direction of fabric travel based on the physical coordinates of the defect and the reference physical coordinates. Obtain the preset encoder single-pulse fabric movement distance, and divide the physical offset distance of the defect by the encoder single-pulse fabric movement distance to obtain the pulse offset amount; Subtracting the pulse offset from the latch encoder pulse value yields the defect weaving target pulse value. Obtain a pre-established pulse timestamp mapping table, retrieve the fabric weaving time corresponding to the defect weaving target pulse value from the pulse timestamp mapping table, and construct a retrieval interval based on the fabric weaving time and a preset time window radius; Using the retrieval interval as an index, retrieve the tension value of the fabric and the rotational speed value of the equipment traction roller from the weaving equipment time series database; Obtain the batch identifier of the raw materials corresponding to the single weaving time period in which the fabric is woven.
[0011] Specifically, in step S4, the step of scoring mechanical damage defects based on tension and rotational speed values includes: If the tension value is greater than the preset tension threshold and the rotation speed value is greater than the preset rotation speed threshold, then the defect type corresponding to the defect area is determined to be a mechanical damage defect. The tension deviation is obtained by calculating the difference between the tension value and the tension threshold, and the speed deviation is obtained by calculating the difference between the speed value and the speed threshold. Obtain the preset tension score weight and speed score weight corresponding to the mechanical damage defect. Multiply the tension deviation by the tension score weight to obtain the first product, and multiply the speed deviation by the speed score weight to obtain the second product. Calculate the sum of the first product and the second product to obtain the defect score corresponding to the mechanical damage defect.
[0012] Preferably, in step S5, the step of determining the defect score based on the area of the current defect region includes: If the tension value is not greater than the preset tension threshold or the rotation speed value is not greater than the preset rotation speed threshold, then the defect type corresponding to the defect area is determined to be a raw material damage defect. Obtain the set of defect coordinates of the defect mask image, and extract the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum y-coordinate from the defect coordinate set; multiply the difference between the maximum x-coordinate and the minimum x-coordinate by the difference between the maximum y-coordinate and the minimum y-coordinate to obtain the defect area of the defect mask image. Obtain the preset conversion coefficient corresponding to the raw material damage defect, and multiply the defect area by the preset conversion coefficient to obtain the defect score corresponding to the raw material damage defect.
[0013] The beneficial effects of this invention are as follows: In the method of linking online fabric quality inspection and ERP system on the loom, the surface defect features of the fabric are extracted by a convolutional neural network to generate a defect mask image and calculate the centroid coordinates of the defect area. The tension value, rotation speed value and raw material batch identifier of the loom are collected simultaneously. Based on whether the tension value and rotation speed value exceed a preset threshold at the same time, the defect type is automatically determined to be mechanical damage or raw material damage. Differentiated scoring strategies are adopted for different types. Mechanical damage defects are scored according to the tension value and rotation speed value to reflect the equipment operating status, while raw material damage defects are scored according to the defect area to reflect the raw material quality problem. Finally, the defect type, score, coordinates and equipment parameters are packaged into a quality inspection data package and sent to the enterprise ERP system database. This realizes automatic defect classification, accurate responsibility positioning and traceability of quality data, and provides data support for production process optimization and raw material supplier management. Attached Figure Description
[0014] Figure 1 A flowchart illustrating the method for linking online fabric quality inspection on a loom with an ERP system.
[0015] Figure 2 Network topology diagram for the method of linking online fabric quality inspection on looms with ERP system.
[0016] Figure 3 A flowchart illustrating the steps to obtain a mask image representing a defect region. Detailed Implementation
[0017] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings. It should be noted that these descriptions are for the purpose of aiding understanding the present invention, but do not constitute a limitation thereof. Furthermore, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0018] Combination Figures 1 to 3 The method for linking online fabric quality inspection on a loom with an ERP system, as shown, includes the following steps: S1: Obtain the fabric surface image detected online, and use a convolutional neural network to extract features from the fabric surface image to obtain a defect mask image representing the defect area; S2: Obtain the mask coordinates of the defect pixels in the defect mask image, and calculate the centroid pixel coordinates of the defect region based on the mask coordinates; S3: Obtain the tension value, rotation speed value, and batch label of the fabric raw material when the weaving equipment generates a defective area; S4: If the tension value is greater than the preset tension threshold and the rotation speed value is greater than the preset rotation speed threshold, the defect type corresponding to the defect area is determined to be a mechanical damage defect, and the mechanical damage defect is scored according to the tension value and rotation speed value. S5: If the tension value is not greater than the preset tension threshold or the rotation speed value is not greater than the preset rotation speed threshold, the defect type corresponding to the defect area is determined to be a raw material damage defect, and the defect score is determined based on the area of the current defect area. S6: Compile the defect type, defect score, center of gravity pixel coordinates, tension value, rotation speed value, and fabric raw material batch identifier into a quality inspection data package and send it to the ERP system database.
[0019] In the method of linking online fabric quality inspection and ERP system on the loom, a convolutional neural network is used to extract surface defect features of the fabric to generate a defect mask image and calculate the centroid coordinates of the defect area. The tension value, rotation speed value and raw material batch identifier of the loom are collected simultaneously. Based on whether the tension value and rotation speed value exceed a preset threshold, the defect type is automatically determined to be mechanical damage or raw material damage. Differentiated scoring strategies are adopted for different types. Mechanical damage defects are scored based on tension value and rotation speed value to reflect the equipment operating status, while raw material damage defects are scored based on defect area to reflect raw material quality problems. Finally, the defect type, score, coordinates and equipment parameters are packaged into a quality inspection data package and sent to the enterprise ERP system database. This realizes automatic defect classification, accurate responsibility positioning and traceability of quality data, and provides data support for production process optimization and raw material supplier management.
[0020] Before being sent to the ERP system's database, the acquired defect type, defect score, centroid pixel coordinates, tension value, rotation speed value, and fabric batch identifier are concatenated into a Lightweight Data Exchange (LTE) text file. This LEE text is then transmitted to the ERP system's receiving port. The receiving port retrieves the LEE text and extracts the fabric batch identifier for field integrity comparison. If the field integrity comparison result is true, the LEE text is written to the quality inspection data table in the ERP system's built-in relational database.
[0021] It is worth noting that, in step S1, the step of obtaining the defect mask image representing the defect region includes: Acquire online detection images of fabric surfaces and preprocess the fabric surface images to obtain arrangement feature maps; A convolutional neural network is used to extract features from the arrangement feature map to obtain a defect probability map, and defect connected components are extracted from the defect probability map; Extract the contour edges of the morphological contour of the connected region of the defect; The Sobel operator is used to calculate the gradient components of the pixels at the contour edge in the horizontal and vertical directions, and the gradient magnitude is synthesized. If the gradient magnitude is greater than a preset threshold, the pixel of the contour edge to which the gradient magnitude belongs is marked as a mutation pixel, and the local segment of the contour edge to which the mutation pixel belongs is located to generate a local damaged sub-region. Calculate the Euclidean distance between any two abruptly changed pixels as the center point spacing, and divide the local damaged sub-regions with center point spacing less than a preset distance threshold into the same defect group; find the smallest bounding rectangle of the local damaged sub-regions in the same group as the final defect region, and generate a defect mask image based on the pixel coordinates of the final defect region.
[0022] It should be noted that the permutation feature map is input into a convolutional neural network to extract features, and the output is a defect probability map. The network captures abnormal textures through convolutional kernels and outputs the probability value of a pixel belonging to a defect. Then, the defect connected components are extracted based on the defect probability. This method utilizes the fitting ability of deep learning to significantly improve the robustness of defect recognition in complex backgrounds.
[0023] For example, the contour edge of the morphological contour of the defective connected region is extracted. Specifically, based on the binary image contour search algorithm OpenCV-findContours, the pixels inside the defective connected region are regarded as the foreground and the remaining pixels are the background. The pixels are traversed from the background to the foreground. When the pixel switches from the background pixel to the foreground pixel of the defect, the pixel is the contour point. The traversal continues to the outer perimeter of the foreground region, and the set of boundary pixel coordinates is collected in turn, which is the contour edge of the morphological contour of the defective connected region. The contour edge obtained here is the set of outer contour points that surround the entire defective connected region.
[0024] Subsequently, the Sobel operator is used to calculate the horizontal and vertical gradient components of the contour edge pixels, and the gradient magnitudes are synthesized. Specifically, the Sobel-x convolution kernel in the horizontal direction of the Sobel operator is set. And the Sobel-y convolution kernel in the vertical direction The convolution kernel iterates through each pixel of the contour edge, calculating the horizontal gradient component SX and the vertical gradient component SY, and then calculating the gradient magnitude. Then, values with gradient magnitudes greater than a gradient threshold are identified as gradient abrupt changes. For example, if a gradient magnitude reaches 150, exceeding a preset threshold of 100, the pixels at the contour edge to which this gradient magnitude belongs are marked as abrupt pixels, and a 5×5 pixel neighborhood centered on the abrupt pixel is designated as a local defect sub-region. The Euclidean distance between any two abrupt pixels is calculated as the center-point spacing; local defect sub-regions with center-point spacing less than a preset distance threshold are grouped into the same defect group; the smallest bounding rectangle is calculated for each local defect sub-region within the same group, and this bounding rectangle is constrained within the contour edge of the shape contour to obtain the final defect region. The region pixels of the local defect sub-regions are extracted, and a defect mask image is generated based on the pixel coordinates of each final defect region. This can accurately locate the blurred areas at the defect edges and avoid misjudgment. In one possible implementation, the region pixels within the final defect region are extracted, and a defect mask image is generated based on their pixel coordinates in the original image. In the mask image, the defect pixel value is 1, and the background value is 0. This provides precise pixel-level positioning guidance for fabric cutting, enabling accurate location of defects.
[0025] Preferably, in step S1, the step of preprocessing the surface image to obtain the arrangement feature map includes: The surface texture of the fabric surface image is extracted using a gray-level co-occurrence matrix, the texture period is determined based on the surface texture, and the texture units are divided based on the texture period. The warp and weft interlacing features are extracted from the texture unit using a grayscale projection function. The yarn arrangement pattern is determined based on the warp and weft interlacing features, and the yarn arrangement pattern is mapped into an arrangement feature map.
[0026] Specifically, the process involves acquiring online images of the fabric surface and preprocessing these images to obtain grayscale images. Grayscale co-occurrence matrices are then constructed at different pixel offset distances in the grayscale images at 0 degrees (horizontally to the right, corresponding to the weft direction of the fabric, i.e., the horizontal yarn texture) and 90 degrees (vertically downwards, corresponding to the warp direction of the fabric, i.e., the longitudinal yarn texture). The contrast features of the two grayscale co-occurrence matrices are then calculated. , The base pixel gray level in a grayscale image , Based on the grayscale of the reference pixel Another pixel grayscale value is paired according to a specified direction and offset distance. and Composition of grayscale pairs And used as a coordinate in the gray-level co-occurrence matrix. , The total number of gray levels in the grayscale image. Coordinates in the normalized gray-level co-occurrence matrix The corresponding joint probability, , To iterate through all reference pixel grayscale values within the current input grayscale image for a specified direction and offset distance. The grayscale values obtained from the statistics The total number of occurrences is calculated. The weft texture period pixel value is determined based on the minimum value of the contrast feature change with pixel offset distance in the 0-degree direction, and the warp texture period pixel value is determined based on the minimum value of the contrast feature change with pixel offset distance in the 90-degree direction. The grayscale image is then segmented into texture units with a size equal to the warp texture period pixel value multiplied by the weft texture period pixel value. For example, assuming a detected warp texture period of 20 pixels and a weft texture period of 15 pixels, the image can be divided into 20 x 15 pixel texture units. This eliminates interference from uneven lighting, transforms complex images into regular units, and improves feature extraction accuracy.
[0027] A one-dimensional vertical projection curve is obtained by performing a vertical grayscale integral projection on the texture unit along the horizontal direction. , Texture unit coordinates The pixel grayscale value is given by H, where H is the warp texture period; a one-dimensional horizontal projection curve is obtained by performing horizontal grayscale integral projection on the texture unit along the vertical direction. , Texture unit coordinates The pixel grayscale is defined as follows: W represents the weft texture period; the one-dimensional vertical projection curve and the one-dimensional horizontal projection curve are used as warp and weft interlacing features; extreme value analysis is performed on the one-dimensional vertical projection curve and the one-dimensional horizontal projection curve respectively, and the coordinates of the peaks and troughs are extracted as the yarn arrangement rules; where the peak is the local maximum value of the curve, with a high cumulative grayscale value, and corresponds to the dense yarn and solid yarn area; the trough is the local minimum value of the curve, with a low cumulative grayscale value, and corresponds to the yarn gap and interlacing hole area; a two-dimensional arrangement feature map with the same size as the texture unit is generated based on the coordinate mapping of the peaks and troughs. Specifically, the pixels corresponding to the coordinates of the peaks in the one-dimensional vertical projection curve or the one-dimensional horizontal projection curve are assigned a grayscale value of 255, the pixels corresponding to the coordinates of the troughs in the one-dimensional vertical projection curve or the one-dimensional horizontal projection curve are assigned a grayscale value of 0, and the remaining intermediate transition positions are set to an intermediate grayscale value of 127. This process highlights the physical interlacing structure of the yarn, significantly amplifies minor yarn breakage anomalies, and enhances the ability to express defect features.
[0028] Optionally, in step S1, the step of extracting the defect connected components in the defect probability map includes: Pixels with probability values greater than a preset probability threshold in the defect probability map are identified as defect candidate pixels, and pixels with pixel values not greater than the probability threshold in the defect probability map are identified as normal background pixels, thus generating a first binary image. A morphological opening operation is performed on the first binary image using structuring elements of a preset size to obtain a second binary image; Based on the 8-neighborhood connectivity rule and using the Two-Pass two-scan method, the second binary image is labeled with connected components to obtain multiple initial connected components; For the multiple initial connected components obtained, the area of each initial connected component is obtained, and the pixel coordinates in each initial connected component are mapped to the defect probability map. The corresponding probability values are obtained and the average value is calculated to obtain the average probability value of each initial connected component. Based on the area and average probability value of each initial connected component, a minimum defect area threshold and a preset confidence threshold are set. If the area of an initial connected component is less than the minimum defect area threshold or the average probability value is lower than the preset confidence threshold, the corresponding initial connected component is removed, and the retained initial connected components are determined as defect connected components.
[0029] For example, a morphological opening operation is performed on the first binary image using a structuring element of a preset size to obtain a second binary image. It should be noted that the morphological opening operation consists of two basic operations, erosion and dilation, connected in series. Specifically, firstly, the set structuring element is slid across the image to perform an erosion operation. If background pixels exist within the area covered by the structuring element, the central pixel is set as background. This process can eliminate small, isolated noise points in the image and break the weak connections between defects. Subsequently, the same structuring element is used to perform a dilation operation on the eroded image. If defect pixels exist within the area covered by the structuring element, the central pixel is set as a defect, thereby restoring the original size and shape of the main defect area.
[0030] In one possible implementation, the second binary image is labeled with connected components based on the 8-neighborhood connectivity rule and using a Two-Pass scanning method to obtain multiple initial connected components. The Two-Pass scanning method is a classic image connected component labeling algorithm. During the first line-by-line scan of the image, the labels of adjacent pixels of the current non-zero pixel (i.e., defect) are checked. If an adjacent pixel has no label, a new label is assigned to the current pixel; if an adjacent pixel already has a label, the smallest label is assigned to the current pixel, and the equivalence relationships between different labels are recorded simultaneously. After completing the first scan, the algorithm constructs a disjoint-set data structure based on the recorded equivalence relationships, resolving all mutually connected label sets. Then, the second scan is performed, replacing the temporary label of each pixel in the image with the smallest root label in its corresponding equivalence set, thus completing the unified labeling of all connected regions.
[0031] Specifically, the process involves: acquiring a second binary image; performing a first pass through the second binary image in a top-to-bottom and left-to-right order; if the current pixel is a foreground defect pixel, acquiring the neighboring pixels in the upper left, upper, upper right, and left directions; determining the label status of the neighboring pixels; if the neighboring pixels have no labeled labels (indicating that the traversed area around the current pixel is entirely background pixels), assigning a new, incrementally unique label to the current pixel; if the neighboring pixels have only one label (indicating that there is only one labeled connected component label in the neighborhood of the current pixel, determining that the current pixel is connected to the labeled region, directly assigning the label to the current pixel, belonging to the same defect area), then assigning the label to the current pixel; if the neighboring pixels have multiple different labels (indicating that the current pixel is simultaneously connected to two...),... The different old labels above indicate that the multiple labels that were originally segmented and marked actually belong to the same defect connected region. The minimum label is then assigned to the current pixel, and the equivalent correspondence of the multiple labels is input into a pre-established disjoint-set data structure tool. The first traversal scan is completed to obtain the initial label image containing the equivalent correspondence. The disjoint-set tool traverses the equivalent correspondence of all labels in the initial label image, clusters and merges all associated labels, and maps all labels belonging to the same connected region to a single minimum reference label, generating a globally unique label mapping dictionary to eliminate label redundancy and conflict. Then, a second traversal scan is performed on the initial label image. Based on the label mapping dictionary, the initial labels of all foreground pixels in the initial label image are replaced to obtain the initial connected region after marking.
[0032] Specifically, in step S2, the step of calculating the centroid pixel coordinates of the defect region includes: Obtain the mask coordinates of the defect pixels in the defect mask image to obtain a defect coordinate set; input the defect coordinate set into the spatial moment calculation tool; The space moment calculation tool sums up all the horizontal coordinates in the defect coordinate set to obtain the total sum of horizontal coordinates. The space moment calculation tool then divides the total sum of horizontal coordinates by the total number of coordinates in the defect coordinate set to obtain the centroid horizontal coordinate. The spatial moment calculation tool sums up all the ordinates in the defect coordinate set to obtain the total sum of the ordinates; the spatial moment calculation tool then divides the total sum of the ordinates by the total number of coordinates in the defect coordinate set to obtain the centroid ordinate. The centroid pixel coordinates of the defect area are determined based on the horizontal and vertical coordinates of the centroid.
[0033] Obtain the mask coordinates of the defect pixels in the defect mask image, and summarize the extracted discrete pixel position information to obtain the defect coordinate set.
[0034] It's important to note that the spatial moment calculation tool is an analysis engine based on image geometric features. It characterizes the spatial distribution of a target by calculating the zeroth and first moments of an image region. Specifically, in fabric defect analysis, the zeroth moment represents the total number of pixels in the defect coordinate set, i.e., the area of the defect region, while the first moment reflects the quality distribution tendency of these pixels along a specific coordinate axis. The spatial moment calculation tool first iterates through and sums all the horizontal coordinates in the defect coordinate set, accumulating the position value of each defect pixel in the horizontal direction to obtain the sum of the horizontal coordinates. This sum corresponds to the first spatial moment of the image in the horizontal direction. Subsequently, the spatial moment calculation tool divides the obtained sum of horizontal coordinates by the total number of coordinates in the defect coordinate set, which is equivalent to dividing the horizontal first moment by the zeroth moment. Through this averaging of the spatial distribution, the centroid horizontal coordinate is obtained.
[0035] The calculation process for the centroid's vertical coordinate is the same. Finally, the centroid's horizontal coordinate and vertical coordinate are combined to form the centroid pixel coordinates of the defect area.
[0036] It is worth noting that, in step S3, the steps of obtaining the tension value, rotation speed value, and batch mark of the fabric raw material when the weaving equipment generates a defective area include: Obtain the latch encoder pulse value corresponding to the acquisition of fabric surface image triggered by preset encoder; A pre-established affine transformation matrix is obtained. The centroid pixel coordinates are multiplied by the affine transformation matrix to obtain the physical coordinates of the defect. The reference coordinates of the fabric surface image are multiplied by the affine transformation matrix to obtain the reference physical coordinates. The physical offset distance of the defect in the direction of fabric travel is calculated based on the physical coordinates of the defect and the reference physical coordinates. The physical offset distance of the defect represents the difference in the actual physical length of the fabric along the direction of fabric travel in the fabric surface image. The pre-established affine transformation matrix is used to convert the image pixel coordinate system containing the centroid pixel coordinates and the reference coordinates into the actual physical coordinate system of the fabric. Obtain the preset encoder single-pulse fabric movement distance, divide the physical offset distance of the defect by the encoder single-pulse fabric movement distance to obtain the pulse offset, which represents the difference in fabric movement pulses between the defect and the current fabric surface image shooting reference position. Subtracting the pulse offset from the latch encoder pulse value yields the defect weaving target pulse value. Obtain a pre-established pulse timestamp mapping table, retrieve the fabric weaving time corresponding to the defect weaving target pulse value from the pulse timestamp mapping table, and construct a retrieval interval based on the fabric weaving time and a preset time window radius; Using the retrieval interval as an index, retrieve the tension value of the fabric and the rotational speed value of the equipment traction roller from the weaving equipment time series database; Obtain the batch identifier of the raw materials corresponding to the single weaving time period in which the fabric is woven.
[0037] An affine transformation matrix is a mathematical tool used to describe the geometric mapping relationship between a two-dimensional image space and the actual physical space. In fabric visual inspection, the image captured by an industrial camera is a two-dimensional matrix in pixels, while the actual movement of the fabric is in physical lengths such as millimeters. By constructing this matrix through pre-calibrating camera parameters, the centroid pixel coordinates and reference coordinates on the fabric surface image can be translated and scaled to accurately map them to the actual physical coordinate system of the fabric. In this embodiment, the reference coordinates are the coordinates (0, 0) of the lower left corner of the fabric surface image, and the fabric's movement direction is set to the positive Y-axis direction of the actual physical coordinate system. Therefore, when calculating the physical offset distance of a defect, it is only necessary to calculate the difference between the Y-axis component of the defect's physical coordinates and the Y-axis component of the reference physical coordinates to obtain the physical offset distance of the defect.
[0038] Specifically, a preset encoder single-pulse fabric movement distance is obtained, representing the fixed physical length the fabric moves forward when the loom spindle encoder emits an electrical pulse signal. Dividing the physical offset distance of the defect by this single-pulse movement distance converts the physical length in the spatial dimension into a pulse offset in the device control dimension. Subsequently, the latched encoder pulse value corresponding to the camera triggering image acquisition is obtained, and the pulse offset is subtracted from it to deduce the defect weaving target pulse value when the defect occurs.
[0039] It should be noted that the pulse timestamp mapping table is the core data structure in the weaving equipment control system for recording the equipment's operating status. Internally, it records the correspondence between the encoder's accumulated pulse values and the system's absolute timestamps in key-value pairs at high frequency. The system retrieves records from the pulse timestamp mapping table that match the target pulse value for the defect, thereby accurately pinpointing the actual fabric weaving time when the defect occurred on the loom.
[0040] In order to comprehensively analyze the equipment operating conditions before and after the defects occur, the system constructs a retrieval interval based on the fabric weaving time and a preset time window radius. This time window radius defines the time span extending forward and backward from the weaving time, ensuring that complete time-series data is covered in the defect formation process.
[0041] Finally, using the retrieval interval as an index, the tension value of the fabric and the rotation speed value of the equipment traction roller within that time period are retrieved from the weaving equipment time sequence database, and the corresponding fabric raw material batch identifier is obtained.
[0042] Preferably, in step S4, the step of scoring mechanical damage defects based on tension and rotational speed values includes: If the tension value is greater than the preset tension threshold and the rotation speed value is greater than the preset rotation speed threshold, then the defect type corresponding to the defect area is determined to be a mechanical damage defect. The tension deviation is obtained by calculating the difference between the tension value and the tension threshold, and the speed deviation is obtained by calculating the difference between the speed value and the speed threshold. Obtain the preset tension score weight and speed score weight corresponding to the mechanical damage defect. Multiply the tension deviation by the tension score weight to obtain the first product, and multiply the speed deviation by the speed score weight to obtain the second product. Calculate the sum of the first product and the second product to obtain the defect score corresponding to the mechanical damage defect.
[0043] It should be noted that the preset tension threshold refers to the maximum yarn tension that the loom can withstand during normal fabric drafting, while the preset speed threshold refers to the maximum rotational speed set for the traction roller to smoothly wind the fabric. If the current tension value is greater than the tension threshold, and the synchronously collected speed value is greater than the speed threshold, it indicates that the equipment is in an extreme operating condition of both overspeed and high tension. This dual over-limit physical state is highly likely to cause yarn breakage; therefore, the system classifies the defect type corresponding to this defect area as a mechanical damage defect.
[0044] The system then calculates the tension deviation by measuring the difference between the actual tension value and the tension threshold, and the speed deviation by measuring the difference between the actual rotational speed value and the rotational speed threshold. Specifically, to comprehensively assess the severity of the mechanical damage defect, the system obtains preset tension scoring weights and rotational speed scoring weights. These scoring weights are coefficients derived from historical weaving data statistics and are used to measure the contribution of different physical quantities to the degree of fabric damage. Then, a defect score corresponding to the mechanical damage defect is obtained based on a weighted summation.
[0045] Optionally, in step S5, the step of determining the defect score based on the area of the current defect region includes: If the tension value is not greater than the preset tension threshold or the rotation speed value is not greater than the preset rotation speed threshold, then the defect type corresponding to the defect area is determined to be a raw material damage defect. Obtain the set of defect coordinates of the defect mask image, and extract the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum y-coordinate from the defect coordinate set; multiply the difference between the maximum x-coordinate and the minimum x-coordinate by the difference between the maximum y-coordinate and the minimum y-coordinate to obtain the defect area of the defect mask image. Obtain the preset conversion coefficient corresponding to the raw material damage defect, and multiply the defect area by the preset conversion coefficient to obtain the defect score corresponding to the raw material damage defect.
[0046] It should be noted that the system acquires a set of defect coordinates from the defect mask image. This set contains the two-dimensional spatial position information of all pixels constituting the defect area in the image coordinate system. To quantify the physical size of the raw material damage defect, the system iterates through the defect coordinate set to extract the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum y-coordinate. Specifically, the maximum and minimum x-coordinates define the maximum span of the defect in the weft direction of the fabric, while the maximum and minimum y-coordinates define the maximum extension range of the defect in the warp direction.
[0047] The system then multiplies the difference between the maximum and minimum x-coordinates by the difference between the maximum and minimum y-coordinates to calculate the area of the smallest bounding rectangle enclosing the defect region. This area is used as the defect area in the defect mask image. This area estimation method based on extreme coordinates can quickly pinpoint the distribution range of inherent defects in the raw materials, such as yarn thick spots or neps. The system further obtains a preset conversion coefficient corresponding to the raw material damage defect. This coefficient is a mapping ratio from area to severity set according to the quality standards of the raw yarn in different batches of fabric raw materials. Multiplying the defect area by the preset conversion coefficient yields the defect score corresponding to the raw material damage defect.
[0048] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention, and these variations still fall within the protection scope of the present invention.
Claims
1. A method for linking online fabric quality inspection on a loom with an ERP system, characterized in that, Includes the following steps: S1: Obtain the fabric surface image detected online, and use a convolutional neural network to extract features from the fabric surface image to obtain a defect mask image representing the defect area; S2: Obtain the mask coordinates of the defect pixels in the defect mask image, and calculate the centroid pixel coordinates of the defect region based on the mask coordinates; S3: Obtain the tension value, rotation speed value, and batch label of the fabric raw material when the weaving equipment generates a defective area; S4: If the tension value is greater than the preset tension threshold and the rotation speed value is greater than the preset rotation speed threshold, the defect type corresponding to the defect area is determined to be a mechanical damage defect, and the mechanical damage defect is scored according to the tension value and rotation speed value. S5: If the tension value is not greater than the preset tension threshold or the rotation speed value is not greater than the preset rotation speed threshold, the defect type corresponding to the defect area is determined to be a raw material damage defect, and the defect score is determined based on the area of the current defect area. S6: Compile the defect type, defect score, center of gravity pixel coordinates, tension value, rotation speed value, and fabric raw material batch identifier into a quality inspection data package and send it to the ERP system database.
2. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 1, characterized in that: In step S1, the step of obtaining a defect mask image representing the defect region includes: Acquire online detection images of fabric surfaces and preprocess the fabric surface images to obtain arrangement feature maps; A convolutional neural network is used to extract features from the arrangement feature map to obtain a defect probability map, and defect connected components are extracted from the defect probability map; Extract the contour edges of the morphological contour of the connected region of the defect; The Sobel operator is used to calculate the gradient components of the pixels at the contour edge in the horizontal and vertical directions, and the gradient magnitude is synthesized. If the gradient magnitude is greater than a preset threshold, the pixel of the contour edge to which the gradient magnitude belongs is marked as a mutation pixel, and the local segment of the contour edge to which the mutation pixel belongs is located to generate a local damaged sub-region. Calculate the Euclidean distance between any two abruptly changed pixels as the center point spacing, and divide the local damaged sub-regions with center point spacing less than a preset distance threshold into the same defect group; find the smallest bounding rectangle of the local damaged sub-regions in the same group as the final defect region, and generate a defect mask image based on the pixel coordinates of the final defect region.
3. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 2, characterized in that: In step S1, the step of preprocessing the surface image to obtain the arrangement feature map includes: The surface texture of the fabric surface image is extracted using a gray-level co-occurrence matrix, the texture period is determined based on the surface texture, and the texture units are divided based on the texture period. The warp and weft interlacing features are extracted from the texture unit using a grayscale projection function. The yarn arrangement pattern is determined based on the warp and weft interlacing features, and the yarn arrangement pattern is mapped into an arrangement feature map.
4. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 2, characterized in that: In step S1, the step of extracting the defect connected components in the defect probability map includes: Pixels with probability values greater than a preset probability threshold in the defect probability map are identified as defect candidate pixels, and pixels with pixel values not greater than the probability threshold in the defect probability map are identified as normal background pixels, thus generating a first binary image. A morphological opening operation is performed on the first binary image using structuring elements of a preset size to obtain a second binary image; Based on the 8-neighborhood connectivity rule and using the Two-Pass two-scan method, the second binary image is labeled with connected components to obtain multiple initial connected components; For the multiple initial connected components obtained, the area of each initial connected component is obtained, and the pixel coordinates in each initial connected component are mapped to the defect probability map. The corresponding probability values are obtained and the average value is calculated to obtain the average probability value of each initial connected component. Based on the area and average probability value of each initial connected component, a minimum defect area threshold and a preset confidence threshold are set. If the area of an initial connected component is less than the minimum defect area threshold or the average probability value is lower than the preset confidence threshold, the corresponding initial connected component is removed, and the retained initial connected components are determined as defect connected components.
5. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 1, characterized in that: In step S2, the step of calculating the centroid pixel coordinates of the defect region includes: Obtain the mask coordinates of the defect pixels in the defect mask image to obtain a defect coordinate set; input the defect coordinate set into the spatial moment calculation tool; The space moment calculation tool sums up all the horizontal coordinates in the defect coordinate set to obtain the total sum of horizontal coordinates. The space moment calculation tool then divides the total sum of horizontal coordinates by the total number of coordinates in the defect coordinate set to obtain the centroid horizontal coordinate. The spatial moment calculation tool sums up all the ordinates in the defect coordinate set to obtain the total sum of the ordinates; the spatial moment calculation tool then divides the total sum of the ordinates by the total number of coordinates in the defect coordinate set to obtain the centroid ordinate. The centroid pixel coordinates of the defect area are determined based on the horizontal and vertical coordinates of the centroid.
6. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 1, characterized in that: In step S3, the steps of obtaining the tension value, rotation speed value, and batch mark of the fabric raw material when the weaving equipment generates a defective area include: Obtain the latch encoder pulse value corresponding to the acquisition of fabric surface image triggered by preset encoder; Obtain a pre-established affine transformation matrix, perform matrix multiplication between the centroid pixel coordinates and the affine transformation matrix to obtain the physical coordinates of the defect; perform matrix multiplication between the reference coordinates of the fabric surface image and the affine transformation matrix to obtain the reference physical coordinates; calculate the physical offset distance of the defect in the direction of fabric travel based on the physical coordinates of the defect and the reference physical coordinates. Obtain the preset encoder single-pulse fabric movement distance, and divide the physical offset distance of the defect by the encoder single-pulse fabric movement distance to obtain the pulse offset amount; Subtracting the pulse offset from the latch encoder pulse value yields the defect weaving target pulse value. Obtain a pre-established pulse timestamp mapping table, retrieve the fabric weaving time corresponding to the defect weaving target pulse value from the pulse timestamp mapping table, and construct a retrieval interval based on the fabric weaving time and a preset time window radius; Using the retrieval interval as an index, retrieve the tension value of the fabric and the rotational speed value of the equipment traction roller from the weaving equipment time sequence database; Obtain the batch identifier of the raw materials corresponding to the single weaving time period in which the fabric is woven.
7. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 1, characterized in that: In step S4, the step of scoring mechanical damage defects based on tension and rotational speed values includes: If the tension value is greater than the preset tension threshold and the rotation speed value is greater than the preset rotation speed threshold, then the defect type corresponding to the defect area is determined to be a mechanical damage defect. The tension deviation is obtained by calculating the difference between the tension value and the tension threshold, and the speed deviation is obtained by calculating the difference between the speed value and the speed threshold. Obtain the preset tension score weight and speed score weight corresponding to the mechanical damage defect. Multiply the tension deviation by the tension score weight to obtain the first product, and multiply the speed deviation by the speed score weight to obtain the second product. Calculate the sum of the first product and the second product to obtain the defect score corresponding to the mechanical damage defect.
8. The method for online fabric quality inspection on a loom and linkage with an ERP system according to claim 1, characterized in that: In step S5, the step of determining the defect score based on the area of the current defect region includes: If the tension value is not greater than the preset tension threshold or the rotation speed value is not greater than the preset rotation speed threshold, then the defect type corresponding to the defect area is determined to be a raw material damage defect. Obtain the set of defect coordinates of the defect mask image, and extract the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum y-coordinate from the defect coordinate set; multiply the difference between the maximum x-coordinate and the minimum x-coordinate by the difference between the maximum y-coordinate and the minimum y-coordinate to obtain the defect area of the defect mask image. Obtain the preset conversion coefficient corresponding to the raw material damage defect, and multiply the defect area by the preset conversion coefficient to obtain the defect score corresponding to the raw material damage defect.
