Knitting needle consistency detection method
Through the machine vision-based knitting needle consistency detection method, the shape and texture characteristics of knitting needles are analyzed using the decision tree model, which solves the problems of low needle detection efficiency and poor consistency, and realizes efficient, accurate sorting and standardization of knitting needle products.
Patent Information
- Application Number
- CN202510507781.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-08-15
AI Technical Summary
The existing knitting needle detection methods are low in efficiency and poor in consistency, making it difficult to accurately and quickly distinguish qualified and unqualified knitting needles, which affects the quality and efficiency of knitting production.
The knitting needle consistency detection method based on machine vision is adopted. By collecting the front-facing image of the knitting needle, superimposing it with the standard template image after image preprocessing, shape and texture features are extracted, and consistency detection is used for decision tree model to achieve rapid sorting of knitting needles.
It improves the consistency and standardization of knitting needle products, has high detection efficiency, reduces human errors, and reduces computing power costs. It is suitable for a variety of knitting needles, with high accuracy and versatility.
Smart Images

Figure CN120495182A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of knitting needle detection, in particular to a knitting needle consistency detection method. Background Art
[0002] Knitting needles are core components of knitting machinery. They come in a wide variety of styles, with delicate and complex structures. Any single needle failing to meet quality standards can result in defects and product losses. Furthermore, needles are consumable, resulting in significant annual consumption. Currently, manual inspection is the primary method for inspecting needles from above. However, manual inspection is inefficient, lacks consistency, and requires high worker skill and endurance.
[0003] Most existing automatic knitting needle sorting methods are not designed to detect product consistency. Public document CN111678450B discloses a method and device for visual inspection of precision parts. This method uses machine vision to detect the offset of knitting needles in the side view direction. However, it suffers from drawbacks such as excessive computational complexity, sensitivity to image stains, and an incomplete overview of the effective features of knitting needles. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a knitting needle consistency detection method, which can accurately and quickly distinguish qualified knitting needles from unqualified knitting needles based on the knitting needle consistency, and effectively improve the consistency and standardization of the final knitting needle product.
[0005] The technical solution adopted by the present invention to solve the technical problem is: to provide a knitting needle consistency detection method, comprising the following steps:
[0006] Collecting a front view image of the knitting needle to be inspected and performing image preprocessing to obtain a contour image of the knitting needle to be inspected;
[0007] Using the edge line of the needle setting area as a reference, the outline image of the needle to be tested is superimposed with the standard template image, and the image of the needle setting area after superposition is obtained as the image to be tested;
[0008] The visual features of the image to be tested are extracted, and the extracted feature data are put into the knitting needle sorting model to obtain the consistency test results of the knitting needles to be tested.
[0009] Furthermore, the visual features include shape features and texture features.
[0010] Furthermore, the texture features include outer contour area and outer contour height.
[0011] Furthermore, the shape features include a gray level co-occurrence matrix, an image gray level second order matrix and a gray level histogram.
[0012] Furthermore, the contour line of the set position includes an intersection contour line of the needle butt and the needle shaft.
[0013] Furthermore, the setting area includes a knitting needle hook.
[0014] Furthermore, the standard template image is obtained by performing corrosion and expansion processing on the outline image of the template knitting needle.
[0015] Furthermore, the image preprocessing includes:
[0016] The image is processed in sequence by grayscale, median filtering and binarization;
[0017] Perform contour extraction on the processed image.
[0018] Furthermore, the knitting needle sorting model is constructed based on a decision tree model.
[0019] Furthermore, the knitting needle sorting model is trained by the following method:
[0020] Acquire front view images of a plurality of knitting needle samples, wherein the knitting needle samples include qualified knitting needles and unqualified knitting needles;
[0021] extracting the contour images of the knitting needles from the front view images of the knitting needle samples;
[0022] Based on the edge line of the knitting needle setting area, the outline image of each knitting needle sample is superimposed with the standard template image to obtain the overlapping image of the knitting needle setting area as a sample image set;
[0023] The visual features of each image sample in the sample image set are extracted, and then divided into a training data set and a test data set to train and evaluate the knitting needle inspection model.
[0024] Beneficial effects
[0025] Due to the adoption of the above technical solution, the present invention has the following advantages and positive effects compared with the prior art: the present invention superimposes the contour image of the knitting needle to be inspected with the standard template image by setting a fixed baseline, obtains the overlapping image of the set area of the knitting needle as the image to be inspected, and constructs a sorting model based on machine learning to evaluate the consistency of the knitting needle to be inspected with the standard template needle based on the image to be inspected, and then sorts the needles. Based on the consistency of the knitting needles, the present invention can accurately and quickly distinguish qualified knitting needles from unqualified knitting needles, effectively improving the standardization of the final knitting needle products; the present invention focuses on the characteristics of shape and texture features in the consistency detection of knitting needles in actual production, only extracts the superimposed image of the set area and extracts its effective features, so that the model focuses on the analysis of specific areas and specific parameters, avoiding the influence of noise, and has high detection efficiency. It can also obtain accurate detection results without incurring high computing power costs, and is convenient for deployment; the selection of image features and the training of the model in the present invention are both outside the detection, and there is no need to collect invalid information, which avoids the waste of computing power. The model training process does not require human intervention, which reduces human errors. As the number of samples increases and accumulates, the model will become more accurate and can be widely applied to various types of knitting needles, with greater versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 This is a flowchart of knitting needle sorting according to an embodiment of the present invention;
[0027] Figure 2 is a flow chart of model construction and consistency detection according to an embodiment of the present invention;
[0028] Figure 3 is a top view image of a certain type of knitting needle according to an embodiment of the present invention;
[0029] Figure 4 Schematic diagram of the outline of a certain type of knitting needle and the positions of its butt, shank, and hook according to an embodiment of the present invention;
[0030] Figure 5 Schematic diagram of a certain type of knitting needle template according to an embodiment of the present invention;
[0031] Figure 6 Schematic diagram of qualified and unqualified samples in the hook area of a certain type of knitting needle according to an embodiment of the present invention;
[0032] Figure 7 Schematic diagram of qualified and unqualified samples of a certain type of knitting needle part of the needle body area according to an embodiment of the present invention;
[0033] Figure 8 4 is a schematic diagram of a decision tree after training according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] Below in conjunction with specific embodiment, further set forth the present invention.Should be understood that these embodiments are only used to illustrate the present invention and are not used in limiting the scope of the present invention.In addition, should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall equally within the scope limited by the appended claims of the application.
[0035] The embodiment of the present invention relates to a method for detecting consistency of knitting needles, such as Figure 1 As shown, the following steps are included:
[0036] Collecting a front view image of the knitting needle to be inspected and performing image preprocessing to obtain a contour image of the knitting needle to be inspected;
[0037] Using the edge line of the needle setting area as a reference, the outline image of the needle to be tested is superimposed with the standard template image, and the image of the needle setting area after superposition is obtained as the image to be tested;
[0038] The visual features of the image to be tested are extracted, and the extracted feature data are put into the knitting needle inspection model to obtain the consistency test results of the knitting needles to be inspected.
[0039] The image preprocessing is to extract the knitting needle outline in the image, which can be obtained by existing methods. This embodiment adopts the following method:
[0040] The image is processed in sequence by grayscale, median filtering and binarization;
[0041] Perform contour extraction on the processed image.
[0042] To more accurately analyze the consistency differences between the needle under test and the standard template, it is necessary to align the contour image of the needle under test with the standard template image based on a unified reference. This embodiment uses the intersection line of the needle's butt and needle bar as a reference to superimpose the top-view edge contour of the needle under test with the template image. The superimposed image of the needle's set area is intercepted to obtain the image under test and extract visual features. Among them, visual features include shape features and texture features, specifically feature parameters such as outer contour area and outer contour height, grayscale co-occurrence matrix, image grayscale second-order matrix, and grayscale histogram. Several of these can be selected according to actual conditions.
[0043] The following further illustrates this implementation with a specific example based on a decision tree.
[0044] This embodiment is divided into two parts: model building and consistency detection. Figure 2 As shown, the specific steps include:
[0045] S1. Taking a certain type of knitting needle as an example, 400 qualified knitting needle samples and 400 unqualified knitting needle samples are obtained from the factory, totaling 800 knitting needle samples. The top view images (i.e., front view images) of many knitting needle samples are collected using a camera, such as Figure 3 As shown;
[0046] S2, such as Figure 4 As shown, based on image processing, the edge contour of the knitting needle sample is extracted, including the needle butt 1, the needle butt line 2, the needle shaft 3, the needle shaft line 4, and the needle hook 5;
[0047] S3, using the template knitting needle, obtain the contour image, and perform image morphological corrosion and expansion processing on the template knitting needle contour image to obtain the image template for detecting the consistency of the knitting needle contour, such as Figure 5 As shown;
[0048] S4, such as Figure 6 and Figure 7 As shown, the intersection line of the needle butt and needle bar of the knitting needle is used as a reference, and the edge contour of the sample is superimposed with the template to obtain the image of the knitting needle hook and part of the needle body area in the superimposed image, thereby completing the collection of the sample image;
[0049] S5. Extract the feature data of the sample images and form a feature vector. The feature data includes the gray-level co-occurrence matrix of the image, the second-order gray-level moment of the image, the outer contour area, the outer contour height, and the gray-level histogram of the image. The feature data of the 800 sample images are divided into a training set and a test set in a ratio of 8:2, that is, the training set accounts for 80% and the test set accounts for 20%;
[0050] S6. Select a decision tree as the training model and put the training set into the decision tree model for training;
[0051] S7, such as Figure 8 As shown in the figure, the test set is put into the model for training, and the quality of the model is evaluated according to various indicators, including precision, recall, F1-score, accuracy, and area under the receiver operating characteristic curve (AUC); in order to obtain the decision tree model with the best performance indicators, the model parameters need to be modified, and the model parameters include the feature selection standard, namely the Gini coefficient or information entropy, the maximum depth of the decision tree, the minimum number of samples of leaf nodes, and the minimum number of samples required for internal node re-division; the grid search method is used to traverse all possible parameter combinations, and the optimal parameter combination is found after cross-validation; after calculation, the optimal parameters in the model training process include: the Gini coefficient is used as the feature selection standard; the maximum depth of the decision tree is not limited; the minimum number of samples of leaf nodes is 1; the minimum number of samples required for internal node re-division is 2. Based on the above parameters, the decision tree model with the best performance indicators is obtained.
[0052] S8, collecting a top view image of the type of knitting needle to be tested, and obtaining a top view edge contour of the knitting needle to be tested through image processing;
[0053] S9, using the intersection line of the needle butt and needle shaft of the knitting needle as a reference, superimposing the top edge contour of the knitting needle to be tested with the template, intercepting the image of the knitting needle hook and part of the needle body area in the superimposed image to obtain the image to be tested;
[0054] S10, extracting feature data of the image to be tested, importing the feature data into the established decision tree model, and the model recognizes and classifies the image to be tested, completing a consistency sorting of the knitting needles to be tested;
[0055] S11. Repeat steps S8-S10 to complete consistency sorting of the batch of knitting needles to be tested.
[0056] The image processing steps in steps S2 and S8 specifically include: performing grayscale processing, median filtering, binarization, and contour extraction on the top view image of the sample or the knitting needle to be tested in sequence to extract the outer contour line of the knitting needle.
[0057] The evaluation indicators of step S7 include:
[0058] Precision refers to the proportion of instances predicted by the model to be positive samples that are actually positive samples; accuracy refers to the proportion of correctly classified samples to the total number of samples;
[0059] Recall rate refers to the ratio of the number of correctly classified positive samples to the actual number of positive samples;
[0060] The F1-score is the harmonic mean of precision and recall, which is used to comprehensively evaluate the performance of the model;
[0061] AUC is the area under the ROC curve, and ROC is the receiver operating characteristic curve, which is a graph of the true positive rate versus the false positive rate for different classification thresholds.
[0062] In order to test the actual effect of the model, 10,000 knitting needles were manually tested, of which 5,053 needles were qualified and 4,947 needles were unqualified. The qualified needles were tested based on the above steps S8-S10. The results showed that the decision tree model judged 5,052 needles as qualified among the 5,053 qualified needles, and the accuracy rate of detecting qualified needles was about 99.98%; the decision tree model judged 4,946 needles as unqualified among the 4,947 unqualified needles, and the accuracy rate of detecting unqualified needles was about 99.98%; when the model was actually applied, the average accuracy of model detection was 99.98%.
[0063] The contents not described in detail in this specification belong to the prior art known to those skilled in the art.
[0064] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
[0065] It should be noted that, in this application, the term "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or apparatus comprising the element.
[0066] The foregoing is merely a list of specific embodiments of the present application, intended to enable those skilled in the art to understand or implement the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the broadest scope consistent with the principles and novel features of the present application.
Claims
1. A method for detecting consistency of knitting needles, characterized in that: The following steps are involved: Collecting a front view image of the knitting needle to be inspected and performing image preprocessing to obtain a contour image of the knitting needle to be inspected; Using the edge line of the needle setting area as a reference, the outline image of the needle to be tested is superimposed with the standard template image, and the image of the needle setting area after superposition is obtained as the image to be tested; The visual features of the image to be tested are extracted, and the extracted feature data are put into the knitting needle sorting model to obtain the consistency test results of the knitting needles to be tested.
2. The method according to claim 1, characterized in that The visual features include shape features and texture features.
3. The method according to claim 2, characterized in that The texture features include outer contour area and outer contour height.
4. The method according to claim 2, characterized in that The shape features include a gray level co-occurrence matrix, an image gray level second order matrix and a gray level histogram.
5. The method according to claim 1, wherein The outline of the set position includes an intersection outline of the needle butt and the needle shaft.
6. The method according to claim 1, characterized in that The setting area includes the knitting needle hooks.
7. The method according to claim 1, characterized in that The standard template image is obtained by performing corrosion and expansion processing on the outline image of the template knitting needle.
8. The method according to claim 1, characterized in that The image preprocessing includes: The image is processed in sequence by grayscale, median filtering and binarization; Perform contour extraction on the processed image.
9. The method according to claim 1, characterized in that The knitting needle sorting model is constructed based on a decision tree model.
10. The method according to claim 1, characterized in that The knitting needle sorting model is trained by the following method: obtaining front view images of a plurality of knitting needle samples, wherein the knitting needle samples include qualified knitting needles and unqualified knitting needles; extracting the contour images of the knitting needles from the front view images of the knitting needle samples; Based on the edge line of the knitting needle setting area, the outline image of each knitting needle sample is superimposed with the standard template image to obtain the overlapping image of the knitting needle setting area as a sample image set; The visual features of each image sample in the sample image set are extracted, and then divided into a training data set and a test data set to train and evaluate the knitting needle inspection model.
Citation Information
Patent Citations
A method and apparatus for visual inspection of precision parts
CN111678450B