Machine Vision-Based Yarn Defect Detection Method and Device

Through the machine vision-based yarn defect detection method, image processing and deep learning neural networks are used to identify yarn defects, which solves the problems of low detection accuracy and insufficient automation level in the prior art, and achieves efficient and accurate yarn defect detection.

CN116894836BActive Publication Date: 2025-08-01ZHEJIANG SCI-TECH UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310950857.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2025-08-01
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

The detection accuracy of existing yarn defect detection methods is easily affected, the automation level is low, and it is prone to false detection.

Method used

Using a yarn defect detection method based on machine vision, yarn images are acquired for binary processing, dimensionality reduction and average pooling, the optimal feature vector is constructed, and input into a deep learning neural network for defect type recognition.

Benefits of technology

It realizes automated defect detection in the yarn production process, improves detection accuracy and speed, and reduces the computing resource occupancy rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116894836B_ABST
    Figure CN116894836B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for detecting yarn defects based on machine vision. The method includes obtaining an image of the yarn; performing binarization processing on the image of the yarn to obtain a binarized image of the yarn; performing dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of the yarn width values; performing average pooling on the one-dimensional sequence to obtain a feature sequence; constructing an optimal feature vector based on the feature sequence; and inputting the optimal feature vector into a deep learning neural network to output the feature attributes of the yarn. The present application can achieve automated defect detection in the yarn production process, solves the problems that the detection accuracy of traditional yarn defect detection methods is easily affected, the automation level is low, and false detection is prone to occur, and has the advantages of low computational resource occupancy rate, fast detection speed, and high recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of textile computer detection technology, and specifically relates to a yarn defect detection method and device based on machine vision. Background Art

[0002] During the yarn production process, yarn defects such as neps and fine lines are inevitable due to the influence of mechanical transmission equipment and spinning raw materials. Therefore, yarn defect detection during the production process is of great research significance for controlling yarn production quality and improving yarn production efficiency.

[0003] At present, the commonly used yarn defect detection methods are: photoelectric detection method, capacitive detection method and manual visual inspection method.

[0004] Photoelectric detection generally consists of a light emitter, an optical system, and a photoreceptor. Infrared light generated by the light emitter passes through the optical system, creating a uniform detection zone. The photoreceptor then converts the light energy into an analog output. When the yarn passes through the detection zone, it partially blocks the light, reducing the amount of light received by the photoreceptor. This change in light energy reflects the yarn diameter within the detection zone. The photoreceptor then converts the light energy into an electrical signal, the amplitude of which corresponds to the yarn diameter. The accuracy of photoelectric detection is susceptible to factors such as aging of the photoelectric device and light transmission through yarn hairiness.

[0005] The capacitive detection method consists of two perpendicular capacitor plates. When the yarn passes through the detection area formed by the two plates in a non-contact manner, the addition of the fiber medium causes the dielectric constant between the two plates to change, resulting in a change in the capacitance value of the two plates, indirectly reflecting changes in the yarn quality. This method can detect common yarns, but the detection accuracy is easily affected by the ambient air humidity, yarn moisture content, and spatial electric field unevenness.

[0006] Manual visual inspection involves inspectors randomly checking yarns from the same batch, relying on their experience and visual observation to determine the type and quantity of yarn defects. This method has a low level of automation, and the results rely on the operator's subjectivity, making it prone to false positives. Summary of the Invention

[0007] The purpose of this application is to provide a yarn defect detection method and device based on machine vision to solve the technical problems of yarn defect detection methods in the prior art, such as easily affected detection accuracy, low automation level, and easy misdetection.

[0008] To achieve the above purpose, a technical solution adopted in this application is:

[0009] A yarn defect detection method based on machine vision is provided, comprising:

[0010] Obtain an image of the yarn;

[0011] Perform binarization on the image of the yarn to obtain a binarized image of the yarn;

[0012] Perform dimensionality reduction on the binarized image to obtain a one-dimensional sequence of the yarn width values;

[0013] Perform average pooling on the one-dimensional sequence to obtain a feature sequence, where the pooling size P of the average pooling i = f(a i ), a i = 1, 2, 3...N;

[0014] Construct an optimal feature vector based on the feature sequence;

[0015] Input the optimal feature vector into a deep learning neural network and output the characteristic attributes of the yarn, where the characteristic attributes include normal or the type of yarn defect.

[0016] In one or more embodiments, the step of performing binarization on the image of the yarn to obtain a binarized image of the yarn includes:

[0017] Calculate the OSTU threshold T of the image of the yarn based on the OSTU threshold method OSTU ;

[0018] Correct the OSTU threshold based on the following formula to obtain a corrected threshold T g-global-OSTU :

[0019] where V q is the gray value of the pixel point with the largest number of pixels having the same gray value among all pixel points of the image of the yarn, and Z x is the gray value of the pixel point with the smallest gray value among all pixel points of the image of the yarn;

[0020] Perform binarization on the image based on the corrected threshold to obtain a binarized image of the yarn.

[0021] In one or more embodiments, the step of performing dimensionality reduction on the binarized image to obtain a one-dimensional sequence of the yarn width values includes:

[0022] Take the background pixels of the binarized image as value 1 and the foreground pixels as value 0 to obtain the matrix X n*m of the binarized image, where n is the number of pixels of the binarized image in the yarn width direction and m is the number of pixels of the binarized image in the yarn length direction;

[0023] Based on the following formula, a one-dimensional sequence D of the yarn width value is calculated:

[0024] D = [n n…n] 1*m - [1 1…1] 1*n * X n*m .

[0025] In one or more embodiments, the yarn defects include detail defects and long missing section defects. The step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes:

[0026] Performing average pooling on the one-dimensional sequence, with the pooling size to obtain a feature sequence S1(a1), where a1 = 1, 2, 3...N1, and m is the length of the one-dimensional sequence.

[0027] In one or more embodiments, the yarn defects include thick section defects. The step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes:

[0028] Performing average pooling on the one-dimensional sequence, with the pooling size to obtain a feature sequence S2(a2), where a2 = 1, 2, 3...N2, and m is the length of the one-dimensional sequence.

[0029] In one or more embodiments, the yarn defects include short missing section defects and false twist defects. The step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes:

[0030] Performing average pooling on the one-dimensional sequence twice, with the pooling sizes of the two average poolings being P 3-1 = 4a3 + 2, P 3-2 = 2a3 + 1, to obtain sequences M short and M long , where a3 = 1, 2, 3...N3, and m is the length of the one-dimensional sequence.

[0031] Performing backward search for difference and forward search for difference on the sequences M short and M long respectively to obtain a backward difference sequence and a forward difference sequence;

[0032] Comparing the backward difference sequence and the forward difference sequence, and taking the larger value at each corresponding position of the backward difference sequence and the forward difference sequence to construct a feature sequence S3(a3).

[0033] In one or more embodiments, the performing the above operations on the sequences Mshort and M long The steps of performing backward search for difference and forward search for difference to obtain a backward difference sequence and a forward difference sequence include:

[0034] Remove the first a3 values at the head end of the sequence M short and sequentially compare the sequence M short and M long from the head end until the tail end to obtain a backward difference sequence S 3-1 = |M short [a3 + 1:m + 1 - 4a3] - M long [1:m - 1 - 5a3]|, where m is the length of the one-dimensional sequence;

[0035] Remove the last a3 values at the tail end of the sequence M short and sequentially compare the sequence M short and M long from the tail end until the head end to obtain a forward difference sequence S 3-2 = |M short [1:m - 1 - 5a3] - M long [3a3 + 2:m - 2a3]|, where m is the length of the one-dimensional sequence.

[0036] In one or more embodiments, the steps of constructing an optimal feature vector based on the feature sequence include:

[0037] Calculating the optimal solution of a i using the random frog leaping algorithm based on partial least squares;

[0038] Based on the optimal solution, calculate the maximum value, minimum value, and average value of the feature sequence, and collect to obtain the optimal feature vector.

[0039] In one or more embodiments, in the step of inputting the optimal feature vector into a deep learning neural network to output the characteristic attributes of the yarn, the neural network is a two-layer ANN classifier, and the training method of the deep learning neural network includes:

[0040] Obtain a sample training set, where the sample training set includes a number of optimal feature vectors of yarn images labeled with label values;

[0041] Input the sample training set, and update the weights of the deep learning neural network in the direction of gradient descent based on the cross-entropy loss function and the label values until the cross-entropy loss function converges to obtain the deep learning neural network.

[0042] To achieve the above object, another technical solution adopted by this application is:

[0043] A yarn defect detection device based on machine vision is provided, including:

[0044] An acquisition module for acquiring an image of the yarn;

[0045] A binarization processing module for binarizing the image of the yarn to obtain a binarized image of the yarn;

[0046] A dimensionality reduction processing module for performing dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of the yarn width value;

[0047] An average pooling module for performing average pooling on the one-dimensional sequence to obtain a feature sequence, wherein the pooling size P of the average pooling i = f(a i ), a i = 1, 2, 3... N;

[0048] A construction module for constructing an optimal feature vector based on the feature sequence;

[0049] A classification and output module for inputting the optimal feature sequence into a deep learning neural network and outputting the feature attributes of the yarn, wherein the feature attributes include normal or the types of yarn defects.

[0050] Different from the prior art, the beneficial effects of this application are:

[0051] The yarn defect detection method of this application is based on machine vision. After collecting the image of the yarn and performing binarization processing, dimensionality reduction is carried out to obtain a one-dimensional sequence of the yarn width value. By performing average pooling with different pooling sizes on the one-dimensional sequence, a feature sequence that can highlight different defects is obtained. Based on the feature sequence, an optimal feature vector can be generated and input into a deep learning neural network to automatically output the types of yarn defects. It can realize automatic defect detection in the yarn production process, solve the problems that the detection accuracy of traditional yarn defect detection methods is easily affected, the automation level is low, and false detection is likely to occur, and has the advantages of low computational resource occupancy rate, fast detection speed, and high recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 is a schematic flowchart of an embodiment of the yarn defect detection method based on machine vision of this application;

[0053] Figure 2 is a defect type diagram of chenille yarn;

[0054] Figure 3 is a schematic diagram of an embodiment of the backward search of this application;

[0055] Figure 4It is a schematic diagram of an embodiment of backward search in this application;

[0056] Figure 5 It is a characteristic sequence diagram of yarns of different defect types in this application;

[0057] Figure 6 It is a schematic structural diagram of an embodiment of a deep learning neural network in this application;

[0058] Figure 7 It is a schematic structural diagram of an embodiment of a yarn defect detection device based on machine vision in this application;

[0059] Figure 8 It is a hardware structure diagram of an embodiment of an electronic device in this application. Specific Embodiments

[0060] The following will describe this application in detail in conjunction with the various embodiments shown in the drawings. However, these embodiments do not limit this application, and structural, method, or functional transformations made by those of ordinary skill in the art based on these embodiments are all included within the protection scope of this application.

[0061] As described in the background art, there are significant limitations in current methods for detecting yarn defects, making it difficult to effectively control the quality and efficiency of yarn production.

[0062] Therefore, the applicant has developed a method for detecting yarn defects based on machine vision. By collecting images of yarns, this method can process the images, automatically identify various defects of the yarns, has a fast detection speed, high recognition accuracy, and low computational resource occupancy rate, and can be widely applied to the defect detection of various yarns.

[0063] Specifically, please refer to Figure 1 , Figure 1 It is a schematic flow diagram of an embodiment of a method for detecting yarn defects based on machine vision in this application.

[0064] The detection method includes:

[0065] S100. Obtain an image of the yarn.

[0066] First, an image of the yarn can be obtained during the production process. Among them, the yarn can be in a moving state or a stationary state.

[0067] In one embodiment, in order to ensure the acquisition effect of the yarn image, the acquisition can be performed under backlight illumination conditions.

[0068] S200. Perform binarization processing on the image of the yarn to obtain a binarized image of the yarn.

[0069] To accurately segment the range of yarn in the image, the image can be binarized. In one embodiment, the threshold method can be used to segment the range of yarn. In other embodiments, other methods can also be used for yarn segmentation, such as segmenting the range of yarn through a deep learning neural network.

[0070] Specifically, in one embodiment, the OSTU threshold T of the yarn image can be calculated first based on the OSTU threshold method. OSTU After that, the OSTU threshold is corrected to improve the segmentation accuracy.

[0071] Among them, the OSTU threshold method is a conventional threshold segmentation method in the art, and the calculation process of the OSTU threshold will not be elaborated here.

[0072] The formula for correcting the OSTU threshold can be as follows:

[0073]

[0074] In the formula, V q is the gray value of the pixel point with the largest number of pixels having the same gray value among all pixel points of the yarn image, and Z x is the gray value of the pixel point with the smallest gray value among all pixel points of the yarn image.

[0075] After that, the collected yarn image can be binarized based on the corrected threshold T g-global-OSTU , that is, the gray value of the pixel points with gray values less than the corrected threshold is set to 0, and the gray value of the pixel points with gray values greater than the corrected threshold is set to 255, thereby obtaining a binarized image.

[0076] S300. Perform dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of yarn width values.

[0077] It can be understood that the binarized image includes the images of the yarn and the background. Based on this binarized image, the width at any point in the length direction of the yarn can be calculated.

[0078] The specific calculation method can be to use the background pixels of the binarized image as value 1 and the foreground pixels as value 0, thereby obtaining the matrix X of the binarized image n*m , where n is the number of pixels of the binarized image in the yarn width direction, and m is the number of pixels of the binarized image in the yarn length direction.

[0079] Based on the formula D1 = [1 1 … 1] 1*n *X n*m, the number of background pixels in the yarn width direction of the yarn image can be calculated. After that, the total number of pixels n in the yarn width direction of the yarn image can be used to calculate the width value of the yarn. Specifically, the one-dimensional sequence D of the yarn width value can be calculated according to the following formula:

[0080] D = [n n … n] 1*m - [1 1 … 1] 1*n * X n*m .

[0081] S400. Perform average pooling on the one-dimensional sequence to obtain a feature sequence.

[0082] Among them, the pooling size P of average pooling i = f(a i ), a i = 1, 2, 3... N.

[0083] After obtaining the one-dimensional sequence D of the yarn width, average pooling can be performed on this one-dimensional sequence to reflect the change trend of the yarn width in the length direction. Based on this change trend, possible defect problems of the yarn can be reflected.

[0084] In an application scenario, taking chenille yarn as an example, there may be five major types of defects in the production process of chenille yarn, namely detail defects, long missing knot defects, thick knot defects, short missing knot defects, and decorative yarn interlacing defects. Specifically, refer to Figure 2 , Figure 2 which is the defect type diagram of chenille yarn.

[0085] As Figure 2 shown, the change trends of the width values of chenille yarn with different defect types in the length direction are different. Among them, detail defects and long missing knot defects are long-segment defects, thick knot defects are short-segment defects, while short missing knot defects and decorative yarn interlacing defects are mutation defects. Therefore, for different types of defects, the pooling size of average pooling should be different. For example, for long-segment defects, the amount of data for taking the average each time should be larger to highlight the change in the width values of long and short yarns; while for short-segment defects, the corresponding amount of data for taking the average each time should be smaller to highlight the characteristics of the defects.

[0086] In an implementation manner, when the yarn defects include detail defects and long missing knot defects, the pooling size of average pooling can be where a1 = 1, 2, 3... N1, m is the length of the one-dimensional sequence,

[0087] Based on this pooling size, a feature sequence S1(a1) can be obtained, and its length is Exemplarily, when m = 100 and a1 = 1, the pooling size is 50, that is, the average value operation is performed on 50 values each time, and they are shifted sequentially. Finally, a feature sequence S1(a1) composed of 51 values can be obtained.

[0088] In one embodiment, the yarn defect includes a slub defect, and the pooling size of the average pooling can be where a2 = 1, 2, 3... N2, and m is the length of the one-dimensional sequence.

[0089] Based on this pooling size, a feature sequence S2(a2) can be obtained, and its length is Exemplarily, when m = 100 and a2 = 1, the pooling size is 2, that is, the average value operation is performed on 2 values each time, and they are shifted sequentially. Finally, a feature sequence S2(a2) composed of 99 values can be obtained.

[0090] In one embodiment, the yarn defects include short slub defects and garniture interlacing defects. Due to the mutation characteristics of these two defects, when performing average pooling, different pooling sizes can be used to perform average pooling twice, and then the difference between the two is taken to construct the feature sequence.

[0091] Specifically, the one-dimensional sequence can be subjected to average pooling twice, and the pooling sizes of the two average poolings are P 3-1 = 4a3 + 2, P 3-2 = 2a3 + 1 respectively, to obtain sequences M short and M long , where a3 = 1, 2, 3... N3, and m is the length of the one-dimensional sequence.

[0092] Among them, the length of sequence M short is m - 1 - a3×4, and the length of sequence M long is m - a3×2. Then, the backward search for difference and the forward search for difference can be performed on sequences M short and M long respectively to obtain the backward difference sequence and the forward difference sequence.

[0093] Specifically, since the lengths of the two sequences are different, the method for backward search for difference is as follows: remove the first a3 values at the head end of sequence M short , and sequentially compare sequence M short and M long from the head end until the tail end to obtain the backward difference sequence S 3-1 = |M short [a3 + 1:m + 1]|. Please refer to Figure 3 . Figure 3 is a schematic diagram of one embodiment of the backward search of this application.

[0094] The method for forward search and difference calculation is as follows: Remove the last a3 values from the end of sequence M short and compare sequence M short and M long in sequence from the end until the head to obtain the forward difference sequence S 3-2 = |M short [1:m - 1 - 5a3] - M long [3a3 + 2:m - 2a3]|. Please refer to Figure 4 , Figure 4 which is a schematic diagram of an embodiment of the backward search of this application.

[0095] After obtaining the backward difference sequence and the forward difference sequence, the maximum value of each corresponding position of the backward difference sequence and the forward difference sequence can be taken to construct the feature sequence S3(a3).

[0096] It can be understood that through the above average pooling method, the characteristics of mutation defects can be effectively highlighted, which helps subsequent classification.

[0097] Please refer to Figure 5 , Figure 5 which is a feature sequence diagram of yarns with different defect types in this application. As Figure 5 shown, for yarns with different defect types, different feature sequences can well characterize their features, thus laying a reliable foundation for subsequent defect detection.

[0098] S500. Based on the feature sequence, construct the optimal feature vector.

[0099] Specifically, since the feature sequence is a sequence related to the variable a i , when the value of a i is different, the feature sequence is also different. Therefore, it is necessary to calculate the optimal solution of the variable a i .

[0100] In one embodiment, the optimal solution of a i can be calculated based on the random frog leaping algorithm of partial least squares. The specific method is introduced in detail below.

[0101] First, when a i takes any value, the maximum value, minimum value and average value statistics of the feature sequence can be calculated.

[0102] Exemplarily, the maximum value, minimum value and average value of the three feature sequences S1(a1), S2(a2), S3(a3) calculated in the above step S400 when the variable takes values from 1 to N can be calculated to construct the feature sequence combination V(L). Taking N = 5 as an example, the specific formula can be seen as follows.

[0103] V(L) = [L1(S1) L2(S2) L3(S3)]

[0104]

[0105]

[0106] As shown in the above formula, it can be seen that the size of the sequence V(L) is: 1×45. Then, based on the random frog leaping algorithm of partial least squares (PLS), the optimal values of a1, a2, and a3 in the sequence V(L) can be found to reconstruct the feature vector L = {l[S1(a1)] l[S2(a2)] l[S3(a3)]}

[0107] Among them, the implementation steps of the random frog leaping algorithm of partial least squares are as follows:

[0108] Step1: Initialization, including a subset V0 containing Q variables. The number of iterations is 1000, the number of variables Q = 5, η = 0.1, ω = 3.

[0109] Step2: Randomly generate Q* from the normal distribution Norm(Q, θQ), including the candidate subset V*.

[0110] Step3: If Q* = Q, then V* = V0. If Q* < Q, then use V0 to establish a PLS model, calculate the regression coefficients of each variable, delete Q - Q* variables related to the minimum absolute regression coefficient, and the remaining Q* variables form V*. If Q* > Q, then randomly select ω(Q* - Q) variables from V - V0 to form a variable subset S, use V0 and S to construct a PLS model, calculate the regression coefficients of each variable, and retain the Q* variables with the largest absolute regression coefficient in this PLS model to form V*.

[0111] Step4: Calculate the root mean square error of cross-validation RMSECV and RMSECV* of V0 and V*. If RMSECV* <= RMSECV, then take V* as V1. Otherwise, accept V* as V1 with a probability of ηRMSECV / RMSECV*. Update V0 with V1 and return to Step2 until the iteration ends.

[0112] Step5: Calculate the selection probability of each variable after the iteration is completed. The frequency of the jth variable selected in the variable subset is denoted as Nj. The selection probability of each variable is as follows:

[0113]

[0114] According to the selection probabilities of each variable, calculate the sum of probabilities of [S1(a1)] (a1 = 1, 2, 3, 4, 5), [S2(a2)] (a2 = 1, 2, 3, 4, 5), and [S3(a3)] (a3 = 1, 2, 3, 4, 5) respectively, and select the [S1(a i )], [S2(a i )], [S3(a i )] with the highest probability for a1, a2, a3, and finally reconstruct the feature vector L, that is, the optimal feature vector.

[0115] It should be noted that the above implementation manner only exemplarily expounds the method for calculating the optimal solution for three feature sequences simultaneously, and the finally obtained optimal feature vector is a 1×9 vector. In other implementation manners, the optimal feature vector of one feature sequence can also be calculated separately based on the random frog leaping algorithm of partial least squares, or the optimal feature vectors of two feature sequences can be calculated, and the effects of this implementation manner can be achieved.

[0116] S600. Input the optimal feature vector into the deep learning neural network and output the characteristic attributes of the yarn.

[0117] Among them, the characteristic attributes include normal or the types of yarn defects.

[0118] In one implementation manner, the deep learning neural network can be a two-layer ANN classifier. This two-layer ANN classifier can include an input layer and an output layer at both ends, and two hidden layers in the middle.

[0119] Specifically, please refer to Figure 6 , Figure 6 which is a schematic structural diagram of one implementation manner of the deep learning neural network of this application. As Figure 6 shown, in one implementation manner, for the 1×9 optimal feature vector obtained in the above step S500, the input layer can include 9 neurons, the output layer can include 6 neurons, and the 6 neurons respectively correspond to the normal state and five kinds of defects. The hidden layer can be a fully connected layer, and each fully connected layer can include 10 hidden neurons. By inputting the optimal feature vector into the input layer, passing through two fully connected layers, and then classifying and outputting through a neuron in the output layer, the defect type of the yarn can be obtained.

[0120] Specifically, the training method of the above deep learning neural network includes:

[0121] Obtain a sample training set, and the sample training set includes several groups of optimal feature vectors of yarn images labeled with label values;

[0122] The sample training set is input, and based on the cross entropy loss function and label value, the weights of the deep learning neural network are updated along the direction of gradient descent until the cross entropy loss function converges to obtain a deep learning neural network.

[0123] Specifically, in order to achieve classification, the above-mentioned deep learning neural network needs to perform forward propagation and back propagation calculations during the training process.

[0124] The forward propagation of a two-hidden-layer neural network refers to the process of transferring data from the input layer to the output layer through each hidden layer. Input x as a neuron into the first hidden layer and calculate it using the following formula:

[0125] h1=σ(w1x+b1)

[0126] Among them, w1 and b1 are the weight and bias of the first hidden layer respectively, and σ is the ReLU (Rectified Linear Unit) activation function, which is σ = max(0,x).

[0127] The result h1 is passed to the second hidden layer to be calculated using the following formula,

[0128] h2=σ(w2h1+b2)

[0129] Among them, w2 and b2 are the weight and bias of the second hidden layer respectively.

[0130] The result h2 is passed to the output layer for calculation,

[0131] y=softmax(w3h2+b3)

[0132] Among them, w3 and b3 are the weight and bias of the output layer respectively, and softmax is the activation function.

[0133]

[0134] The output of the neural network can be converted into a probability distribution between 0 and 1. The output y is a vector with a dimension of 6, including normal yarn, thick sections, thin sections, long and missing sections, short sections, and decorative yarn interlacing, which ultimately realizes the yarn classification based on the feature vector L.

[0135] The back propagation of a two-layer neural network calculates the error between the label value and the result value, transmits the error in the reverse direction of the network according to the error, and updates the weight w and bias value b in each layer.

[0136] ①Calculate the error of the output layer

[0137] The deviation E between the classification result and the expected value is calculated based on the cross entropy loss function between the classification result and the actual label:

[0138]

[0139] where m is the number of training samples, C is the number of classes, and t ij and y ij are the true label of the j-th class of the i-th training sample and the probability that the model predicts the j-th class, respectively. The goal of the cross-entropy loss function is to minimize the gap between the predicted value and the true value. When the predicted probability is closer to the true label, the value of the loss function is closer to 0, and vice versa. Therefore, the cross-entropy loss function can help the model better fit the training data and improve the accuracy of the classification task.

[0140] ② Calculate the error of the second hidden layer

[0141] The error can be propagated along the network to the second hidden layer. Through the chain rule, the error can be expressed as:

[0142]

[0143] where δ2 is the error of the second hidden layer.

[0144] ③ Calculate the error of the first hidden layer

[0145] The error δ2 of the second hidden layer can also be propagated along the network to the first hidden layer to calculate the error of the first hidden layer:

[0146]

[0147] where δ1 represents the error of the second hidden layer, and (δ2 > 0) is the indicator function, which has a value of 1 when δ2 > 0 and a value of 0 when δ2 < 0.

[0148] ④ Update the weights and biases

[0149] Use the error to update the weights and biases. The update of the weights and biases can be implemented using the gradient descent algorithm, that is, by adjusting the weight and bias values in the direction of reducing the error. The update of the weights and biases is as follows:

[0150]

[0151] where lr is the learning rate, and the amplitude can be adjusted according to the error each time an update is made.

[0152] After updating the weights and biases using the backpropagation algorithm, calculate the forward propagation again and repeat the above process iteratively until the bias values of each round converge. Record all the weights and biases for forward propagation, and a chenille yarn defect classification model can be established. Use this model to detect chenille yarn.

[0153] The present application also provides a yarn defect detection device based on machine vision. Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of an embodiment of the yarn defect detection device based on machine vision of the present application.

[0154] The device includes an acquisition module 21, a binarization processing module 22, a dimensionality reduction processing module 23, an average pooling module 24, a construction module 25, and a classification output module 26.

[0155] Among them, the acquisition module 21 is used to acquire an image of the yarn;

[0156] The binarization processing module 22 is used to perform binarization processing on the image of the yarn to obtain a binarized image of the yarn;

[0157] The dimensionality reduction processing module 23 is used to perform dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of yarn width values;

[0158] The average pooling module 24 is used to perform average pooling on the one-dimensional sequence to obtain a feature sequence. Among them, the pooling size P of the average pooling i = f(a i ), a i = 1, 2, 3... N;

[0159] The construction module 25 is used to construct an optimal feature vector based on the feature sequence;

[0160] The classification output module 26 is used to input the optimal feature sequence into a deep learning neural network and output the feature attributes of the yarn. Among them, the feature attributes include normal or the type of yarn defects.

[0161] As described above with reference to Figures 1 to 6 , the yarn defect detection method based on machine vision according to the embodiments of the present specification has been described. The details mentioned in the above description of the method embodiments also apply to the yarn defect detection device based on machine vision of the embodiments of the present specification. The above-mentioned yarn defect detection device based on machine vision can be implemented by hardware, or by software, or by a combination of hardware and software.

[0162] Figure 8 is a hardware structure diagram of an embodiment of the electronic device of the present application. As Figure 8 shown, the electronic device 30 may include at least one processor 31, a memory 32 (such as a non-volatile memory), a memory 33, and a communication interface 34, and at least one processor 31, the memory 32, the memory 33, and the communication interface 34 are connected together via a bus 35. At least one processor 31 executes at least one computer-readable instruction stored or encoded in the memory 32.

[0163] It should be understood that the computer-executable instructions stored in the memory 32, when executed, cause at least one processor 31 to perform the various operations and functions described above in connection with the various embodiments of this specification. Figures 1 - 4 described above.

[0164] In an embodiment of this specification, the electronic device 30 may include, but is not limited to: a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile electronic device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable electronic device, a consumer electronic device, and so on.

[0165] According to one embodiment, there is provided a program product such as a machine-readable medium. The machine-readable medium may have instructions (i.e., the elements implemented in software as described above), which, when executed by the machine, cause the machine to perform the various operations and functions described above in connection with the various embodiments of this specification. Figures 1 - 4 Specifically, a system or device equipped with a readable storage medium may be provided, on which software program code for implementing the functions of any one of the above embodiments is stored, and the computer or processor of the system or device is caused to read and execute the instructions stored in the readable storage medium.

[0166] In this case, the program code read from the readable medium itself can implement the functions of any one of the above embodiments, so the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of this specification.

[0167] Examples of the readable storage medium include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as a CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.

[0168] Those skilled in the art should understand that the various embodiments disclosed above can be variously deformed and modified without departing from the essence of the invention. Therefore, the protection scope of this specification should be defined by the appended claims.

[0169] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined as required. The device structures described in the above embodiments can be physical structures or logical structures. That is, some units may be implemented by the same physical entity, or some units may be implemented separately by multiple physical entities, or some components in multiple independent devices may be jointly implemented.

[0170] In the above embodiments, the hardware units or modules can be implemented mechanically or electrically. For example, a hardware unit, module, or processor can include permanent dedicated circuits or logic (such as a dedicated processor, FPGA, or ASIC) to perform corresponding operations. The hardware unit or processor can also include programmable logic or circuits (such as a general-purpose processor or other programmable processors), which can be temporarily set by software to perform corresponding operations. The specific implementation method (mechanical method, or dedicated permanent circuit, or temporarily set circuit) can be determined based on cost and time considerations.

[0171] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the scope of the claims. The term "exemplary" used throughout this specification means "serving as an example, instance, or illustration" and does not mean "preferred" or "advantageous" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, these technologies can be implemented without these specific details. In some instances, well-known structures and devices are shown in block diagram form to avoid obscuring the concepts of the described embodiments.

[0172] The above description of the present disclosure is provided to enable any ordinary person skilled in the art to implement or use the present disclosure. Various modifications to the present disclosure are obvious to those of ordinary skill in the art, and the general principles corresponding herein can also be applied to other variations without departing from the scope of protection of the present disclosure. Therefore, the present disclosure is not limited to the examples and designs described herein, but is consistent with the broadest scope that conforms to the principles and novel features disclosed herein.

Claims

1. A method for detecting yarn defects based on machine vision, characterized in that, Including: Obtaining an image of the yarn; Performing binarization processing on the image of the yarn to obtain a binarized image of the yarn; Performing dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of the yarn width value; Perform average pooling on the one-dimensional sequence to obtain a feature sequence, where the pooling size P of the average pooling i = f(a i ), a i = 1, 2, 3... N; Constructing an optimal feature vector based on the feature sequence; Inputting the optimal feature vector into a deep learning neural network to output the characteristic attributes of the yarn, where the characteristic attributes include normal or the type of yarn defect; Wherein, the step of performing dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of the yarn width value includes: Using the background pixels of the binary image as value 1 and the foreground pixels as value 0, the matrix X of the binary image is obtained n*m , where n is the number of pixels of the binary image in the yarn width direction, and m is the number of pixels of the binary image in the yarn length direction; Calculating to obtain a one-dimensional sequence D of the yarn width value based on the following formula: D = [n n…n] 1*m - [1 1…1] 1*n * X n*m ; When the yarn defects include detail defects and long missing section defects, the step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes: Perform average pooling on the one-dimensional sequence, with the pooling size to obtain the feature sequence S1(a1), where a1 = 1, 2, 3... N1, and m is the length of the one-dimensional sequence When the yarn defects include thick section defects, the step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes: Perform average pooling on the one-dimensional sequence, with the pooling size to obtain the feature sequence S2(a2), where a2 = 1, 2, 3... N2, and m is the length of the one-dimensional sequence When the yarn defects include short missing section defects and decorative yarn interlacing defects, the step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes: Perform two average poolings on the one-dimensional sequence respectively. The pooling sizes of the two average poolings are P 3-1 = 4a3 + 2 and P 3-2 = 2a3 + 1 to obtain sequences M short and M long , where a3 = 1, 2, 3... N3, m is the length of the one-dimensional sequence; Perform backward search for difference and forward search for difference on the sequence M short and M long respectively, to obtain a backward difference sequence and a forward difference sequence; Comparing the backward difference sequence and the forward difference sequence, and taking the larger value of each corresponding position of the backward difference sequence and the forward difference sequence to construct a feature sequence S3(a3); The step of constructing an optimal feature vector based on the feature sequence includes: Calculating the optimal solution of a using the random frog leaping algorithm based on partial least squares i ; Calculating the maximum value, minimum value and average value of the feature sequence based on the optimal solution, and collecting to obtain the optimal feature vector.

2. The yarn defect detection method according to claim 1, wherein, The step of performing binarization processing on the image of the yarn to obtain a binarized image of the yarn includes: Calculate the OSTU threshold T of the image of the yarn based on the OSTU threshold method OSTU ; The OSTU threshold is corrected based on the following formula to obtain a corrected threshold T g-global-OSTU : In the formula, V q is the gray value of the pixel points with the largest same number of gray values among all pixel points of the image of the yarn, and Z x is the gray value of the pixel point with the smallest gray value among all pixel points of the image of the yarn; Performing binarization processing on the image based on the corrected threshold to obtain a binarized image of the yarn.

3. The yarn defect detection method according to claim 1, characterized in that, Said separately for said sequence M short and M long Performing backward search for difference and forward search for difference to obtain a backward difference sequence and a forward difference sequence includes the steps of: Remove the first a3 values at the head end of the sequence M short and sequentially compare the sequence M short and M long from the head end until the tail end to obtain the backward difference sequence S 3-1 = |M short [a3 + 1:m + 1 - 4a3] - M long [1:m - 1 - 5a3]|, where m is the length of the one-dimensional sequence; Remove the last a3 values at the end of the sequence M short and compare the sequence M short and M long sequentially from the end to the head to obtain the forward difference sequence S 3-2 = |M short [1:m - 1 - 5a3] - M long [3a3 + 2:m - 2a3]|, where m is the length of the one-dimensional sequence.

4. The yarn defect detection method according to claim 1, wherein In the step of inputting the optimal feature vector into a deep learning neural network to output the characteristic attributes of the yarn, the neural network is a two-layer ANN classifier, and the training method of the deep learning neural network includes: Obtaining a sample training set, where the sample training set includes a plurality of groups of optimal feature vectors of yarn images labeled with label values; Inputting the sample training set, and updating the weights of the deep learning neural network along the gradient descent direction based on the cross-entropy loss function and the label value until the cross-entropy loss function converges to obtain the deep learning neural network.

5. A yarn defect detection device based on machine vision, characterized in that, Including: An acquisition module for obtaining an image of the yarn; A binarization processing module for performing binarization processing on the image of the yarn to obtain a binarized image of the yarn; A dimensionality reduction processing module for performing dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of the yarn width value; The mean pooling module is used to perform mean pooling on the one-dimensional sequence to obtain a feature sequence, where the pooling size P of the mean pooling i = f(a i ), a i = 1, 2, 3... N; A construction module for constructing an optimal feature vector based on the feature sequence; A classification output module for inputting the optimal feature vector into a deep learning neural network to output the characteristic attributes of the yarn, where the characteristic attributes include normal or the type of yarn defect; Wherein, the step of performing dimensionality reduction processing on the binarized image to obtain a one-dimensional sequence of the yarn width value includes: Taking the background pixels of the binary image as value 1 and the foreground pixels as value 0, the matrix X of the binary image is obtained n*m , where n is the number of pixels of the binary image in the yarn width direction, and m is the number of pixels of the binary image in the yarn length direction; Calculating to obtain a one-dimensional sequence D of the yarn width value based on the following formula: D = [n n…n] 1*m - [1 1…1] 1*n * X n*m ; When the yarn defects include detail defects and long missing knot defects, the step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes: Perform average pooling on the one-dimensional sequence, with the pooling size to obtain a feature sequence S1(a1), where a1 = 1, 2, 3... N1, and m is the length of the one-dimensional sequence When the yarn defects include thick knot defects, the step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes: Perform average pooling on the one-dimensional sequence, with the pooling size to obtain the feature sequence S2(a2), where a2 = 1, 2, 3... N2, and m is the length of the one-dimensional sequence When the yarn defects include short missing knot defects and decorative yarn interleaving defects, the step of performing average pooling on the one-dimensional sequence to obtain a feature sequence includes: Perform two average poolings on the one-dimensional sequence respectively. The pooling sizes of the two average poolings are P 3-1 = 4a3 + 2 and P 3-2 = 2a3 + 1, obtaining sequences M short and M long , where a3 = 1, 2, 3... N3, m is the length of the one-dimensional sequence; Perform backward search for difference and forward search for difference on the sequence M respectively short and M long to obtain a backward difference sequence and a forward difference sequence Compare the backward difference sequence and the forward difference sequence, and take the larger value at each corresponding position of the backward difference sequence and the forward difference sequence to construct the feature sequence S3(a3); The step of constructing an optimal feature vector based on the feature sequence includes: Calculating the optimal solution of a by the random frog leaping algorithm based on partial least squares i ; Based on the optimal solution, calculate the maximum value, minimum value and average value of the feature sequence, and collect to obtain the optimal feature vector.

Citation Information

Patent Citations

  • Yarn identification method and apparatus

    CN108288272A

  • Yarn defect classifying device and method and yarn winding machine

    EP2644553A2