A machine vision-based method and system for detecting defects in socks

Through the sock defect detection method based on machine vision, the multi-stage area segmentation algorithm and shape difference calculation are used to solve the problem of defect detection accuracy and reliability of the existing technology in the context of different fabric structures, and achieve efficient and accurate defect detection. .

CN119067975BActive Publication Date: 2025-01-24ZHUJI ZHISHEN SOCKS IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411561812.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-01-24
Estimated Expiration
2044-11-05

AI Technical Summary

Technical Problem

The prior art has limited generalization ability in detecting various defect types in different fabric structures of socks, making it difficult to ensure the accuracy and reliability of the detection.

Method used

Adopt a sock defect detection method based on machine vision, collect images through high-resolution cameras and perform preprocessing, build a multi-stage area segmentation algorithm to segment the image into different areas, extract the fabric structure shape, calculate the shape difference, and mark defects according to the difference threshold point.

Benefits of technology

It improves the accuracy and reliability of defect detection under different fabric structure backgrounds, can accurately identify and segment different areas of fabric structure in sock images, perform targeted defect detection, and reduce detection errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119067975B_ABST
    Figure CN119067975B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of textile defect detection, specifically a sock defect detection method and system based on machine vision, firstly, by constructing a multi-stage region segmentation algorithm, the sock image to be detected and the corresponding flawless sock image are respectively segmented into multiple regions to obtain a set of regions to be detected and a set of flawless regions; then, the fabric structure shape of each region in the set of regions to be detected and the set of flawless regions is extracted respectively to obtain a set of fabric structure shapes to be detected and a standard fabric structure shape model for each region; then, by calculating the shape difference between each fabric structure shape to be detected in the region and the corresponding standard fabric structure shape model, the defect point is detected; finally, the defect point detection results of all regions are integrated to obtain the sock defect detection result. The present invention can effectively improve the accuracy and reliability of defect detection under the background of diverse sock fabric structures.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of textile defect detection, and in particular to a socks defect detection method and system based on machine vision. Background Art

[0002] In the process of sock production and manufacturing, defect detection is a key link to ensure product quality. It can not only detect and eliminate unqualified products in time and reduce the defective rate, but also help enterprises adjust production process parameters in time to avoid batch quality problems. Sock production usually adopts circular knitting technology, which can form a variety of fabric structures, including plain, ribbed and jacquard. Different fabric structures have different shape characteristics, and different parts of the same sock will also use different fabric structures. For example, the sock opening usually uses ribbed tissue to provide appropriate tightness, and the sock leg may use plain tissue to ensure fit. The diversity and complexity of this structure poses a challenge to the defect detection of socks. The detection method needs to be able to adapt to the characteristics of different fabric structures to accurately detect various possible defects.

[0003] At present, machine vision technology has been applied to the field of sock defect detection, improving the accuracy and efficiency of defect detection. For example, by capturing sock images with high-speed cameras and combining them with deep learning algorithms, common defects can be quickly identified, avoiding the problem of missed detection due to manual inspection fatigue. However, for the various types of defects in the context of different fabric structures of socks, the generalization ability of existing technologies is limited, and it is difficult to ensure detection accuracy and reliability.

[0004] Therefore, a socks defect detection method and system based on machine vision are proposed. Summary of the invention

[0005] The object of the present invention is to provide a sock defect detection method and system based on machine vision. First, a high-resolution camera is used to collect a sock image to be detected and a corresponding flawless sock image and perform preprocessing. The sock image to be detected and the flawless sock image are respectively segmented into multiple regions by constructing a multi-stage region segmentation algorithm to obtain a set of regions to be detected and a set of flawless regions. Then, the fabric structure shape of each region in the set of regions to be detected is extracted to obtain a set of fabric structure shapes to be detected in each region. The fabric structure shape of each region in the set of flawless regions is extracted, and the average value of all the fabric structure shapes in each region is calculated to obtain a standard fabric structure shape model of each region. Then, for each region in the set of regions to be detected, the shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model is calculated. If the shape difference exceeds a difference threshold, the position where the fabric structure shape to be detected is located is marked as a defect point. Finally, the defect detection results of all regions are integrated to obtain a sock defect detection result.

[0006] To achieve the above object, the present invention provides the following technical solutions:

[0007] A socks defect detection method based on machine vision, comprising:

[0008] Collect the images of the socks to be inspected and the corresponding images of the flawless socks and perform preprocessing;

[0009] A multi-stage region segmentation algorithm is constructed to process the sock image to be detected and the flawless sock image respectively to obtain a set of regions to be detected and a set of regions without flaws; the multi-stage region segmentation algorithm comprises: constructing an energy function to obtain an initial region set; constructing a region adaptive growth algorithm based on fabric structure similarity according to the initial region set to obtain a set of regions with fabric structure consistency; and obtaining a region segmentation result according to the set of regions with fabric structure consistency;

[0010] Extracting the fabric structure shape of each area in the set of areas to be detected, and obtaining a set of fabric structure shapes to be detected in each area; the fabric structure shape is a shape formed by interweaving yarns in the socks;

[0011] Extracting the fabric structure shape of each area in the set of flawless areas, and calculating the average value of all the fabric structure shapes in each area to obtain a standard fabric structure shape model of each area;

[0012] For each area in the set of areas to be detected, calculating the shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model, and if the shape difference exceeds a difference threshold, marking the position where the fabric structure shape to be detected is located as a defect point;

[0013] The detection results of all regions are integrated to determine whether there are defect points in the sock image to be detected, and obtain a sock defect detection result.

[0014] Preferably, the specific steps of the multi-stage region segmentation algorithm include:

[0015] Constructing an energy function, and obtaining an initial region set by minimizing the energy function;

[0016] Calculating the contour curvature for each initial region in the initial region set;

[0017] Extracting a set of contour feature points of each of the initial regions according to the contour curvature;

[0018] Constructing a spatial constraint function for each of the initial regions according to the set of contour feature points, and defining a valid range of the initial region according to the spatial constraint function;

[0019] Extracting intensity features and direction features within the effective range of each of the initial regions;

[0020] Constructing a fabric structure similarity function according to the intensity feature and the direction feature, and calculating the fabric structure similarity;

[0021] According to the fabric structure similarity, a set of fabric structure consistency regions is obtained by a region adaptive growth method;

[0022] The fabric structure consistency regions with the same fabric structure but belonging to different regions are merged, and the region segmentation result is obtained after boundary optimization.

[0023] Preferably, the specific steps of extracting a set of contour feature points include: constructing a contour curvature sequence based on the contour curvature of the initial area, and processing the contour curvature sequence using a Gaussian filter; detecting local maximum and local minimum values ​​in the contour curvature sequence after filtering; setting a curvature threshold and a minimum spacing threshold, and screening the local maximum and the local minimum values ​​according to the curvature threshold and the minimum spacing threshold to obtain the set of contour feature points.

[0024] Preferably, generating the spatial constraint function and defining the effective range specifically includes: calculating the region centroid based on the contour feature point set of each initial region; constructing the spatial constraint function based on the region centroid and the contour feature point set; setting a constraint threshold to define the effective range of the initial region; adjusting the effective range of adjacent initial regions to update the effective range of each initial region.

[0025] Preferably, the specific steps of the fabric structure similarity region adaptive growth algorithm include:

[0026] For each initial region, the contour feature point set is used as the initial seed point set;

[0027] Select pixel points that meet the first constraint condition in the neighborhood of each initial seed point and add them to the initial seed point set to obtain a seed point set; the first constraint condition includes: the fabric structure consistency of the pixel point is greater than the consistency threshold, the fabric structure consistency and the consistency threshold are calculated according to the fabric structure similarity; the pixel point is within the effective range of the initial area; the distance between the pixel point and the existing seed point is greater than the seed point spacing threshold, and the seed point spacing threshold is determined by the average distance of adjacent contour feature points;

[0028] Add all seed points in the seed point set to the queue of points to be processed and the set of segmented points ; When the queue of pending points When it is not empty, the loop executes: Take a point ;for Every point in the neighborhood of If you click Satisfying the second constraint, Add to the segmented point set and the queue of pending points ; The second constraint condition includes: point Not in the segmented point set midpoint within the effective range of the initial area; The growth probability is greater than the adaptive threshold, and the growth probability and the adaptive threshold are calculated according to the fabric structure similarity; when the queue of points to be processed When empty, region adaptive growth ends.

[0029] Preferably, the specific steps of extracting the fabric structure shape include: generating a binary edge image through an edge detection operator; performing a connected domain analysis on the binary edge image to mark each independent sub-region; extracting a contour point sequence of the independent sub-region using a neighborhood tracking algorithm; performing a closure check on the contour point sequence, and when the contour is not closed, interpolating through curve fitting to obtain a set of closed contour curves; optimizing each closed contour curve in the set of closed contour curves to obtain the fabric structure shape.

[0030] Preferably, a square root velocity function is used to represent the fabric structure shape, specifically comprising: normalizing the optimized closed contour curve into a parametric equation; calculating the velocity vector and velocity vector modulus of the closed contour curve according to the parametric equation to obtain the square root velocity function of the fabric structure shape.

[0031] Preferably, the step of calculating the shape difference is: calculating the shape distance and the phase distance between the fabric structure shape to be detected and the standard fabric structure shape model, and calculating the total distance according to the shape distance and the phase distance to obtain the shape difference.

[0032] Preferably, the difference threshold is calculated based on the flawless sock image, and the specific steps are: acquiring all the fabric structure shapes in each area; calculating the shape distance and phase distance between each fabric structure shape and the standard fabric structure shape model; calculating the total distance based on the shape distance and the phase distance to obtain a total distance set; performing statistical analysis on the total distance set, and determining the difference threshold based on the upper limit of the total distance set.

[0033] A socks defect detection system based on machine vision, comprising:

[0034] An image acquisition module, which acquires the image of the socks to be inspected and the corresponding image of the flawless socks and performs preprocessing;

[0035] A region segmentation module constructs a multi-stage region segmentation algorithm to process the to-be-detected sock image and the flawless sock image respectively to obtain a to-be-detected region set and a flawless region set;

[0036] A shape extraction module is used to extract the fabric structure shape of each area in the set of areas to be detected, and obtain the set of fabric structure shapes to be detected in each area; extract the fabric structure shape of each area in the set of flawless areas, and calculate the average value of all the fabric structure shapes in each area to obtain a standard fabric structure shape model of each area;

[0037] a defect detection module, for each area in the set of areas to be detected, calculating a shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model, and marking a position where the fabric structure shape to be detected is located as a defect point if the shape difference exceeds a difference threshold;

[0038] The result integration module integrates the defect detection results of all regions, determines whether there are defect points in the sock image to be detected, and obtains the sock defect detection result.

[0039] Compared with the prior art, the present invention has the following beneficial effects:

[0040] 1. Multi-stage region segmentation algorithm, firstly obtains the initial region by minimizing the energy function, then calculates the region contour curvature and extracts contour feature points, builds a spatial constraint function based on the contour feature points to define the effective range, extracts the strength and direction characteristics of the fabric structure within the effective range, and establishes a fabric structure similarity function, and implements the region adaptive growth method based on the fabric structure similarity function, which can obtain a set of regions divided by fabric structure characteristics, and then obtains the final segmentation result after region merging and boundary optimization, which can accurately identify and segment different regions of the fabric structure in the sock image, perform targeted defect detection, and improve the accuracy and reliability of detection under different fabric structure backgrounds.

[0041] 2. Extract the fabric structure shape of different areas of the socks. First, use the edge detection operator to generate a binary edge image, mark the independent sub-areas through connected domain analysis, and then use the neighborhood tracking algorithm to extract the contour point sequence; for non-closed contours, use curve fitting for interpolation to ensure that a complete set of closed contour curves is obtained, and use the square root velocity function to represent the fabric structure shape; the extraction and representation method of the fabric structure shape can accurately extract the fabric structure characteristics of different areas of the socks, provide a standardized shape expression method, effectively improve the accuracy and reliability of defect detection under different fabric structure backgrounds, and provide an objective basis for defect judgment.

[0042] 3. By considering both shape distance and phase distance as two dimensions, the difference between the shape of the fabric structure to be detected and the standard fabric structure shape model is comprehensively evaluated, which can accurately capture tiny defects. The difference threshold is determined by statistically analyzing the difference between all fabric structure shapes in the defect-free area and the standard fabric structure shape model. It can be adjusted according to the material and weaving characteristics of different socks to avoid detection errors caused by fixed thresholds. It has universality and adaptability, and can maintain high defect detection accuracy and reliability when processing socks with different fabric structures. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 A schematic flow chart of a socks defect detection method based on machine vision provided by an embodiment of the present invention;

[0044] Figure 2 A schematic diagram of the structure of a sock defect detection system based on machine vision provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] With the rapid development of the textile industry, socks are becoming increasingly diverse in weaving technology and style design. However, since different functional areas of socks are woven in different ways to form different fabric structures, the types of defects also show diverse characteristics. Common defects include kinks, flower skipping, star jumps and broken warps, and the specific manifestations of these defects in different fabric structure backgrounds are different. Traditional manual detection methods have problems such as low efficiency, poor accuracy and difficulty in unifying detection standards. The current mainstream defect detection methods are mainly based on artificial intelligence technologies such as deep learning, which require a large amount of labeled sample data to train and optimize the model. At the same time, when facing new fabric structures or defect types, the trained model often needs to collect samples again for training. The generalization ability of the model is limited, which not only increases the detection cost, but also affects the accuracy and reliability of the detection.

[0047] The present invention proposes a sock defect detection method and system based on machine vision, which can automatically divide socks into different areas for targeted analysis according to different fabric structure characteristics, and combine with fabric structure shape extraction to achieve accurate detection of defects under different fabric structure backgrounds. In order to illustrate the role of the present invention, the effectiveness of the present invention will be illustrated from the following two embodiments. Example

[0048] A sock factory applied a sock defect detection method based on machine vision on its production line. Figure 1 ,include:

[0049] Collecting the images of the socks to be inspected and the corresponding images of the socks without defects and performing preprocessing; the preprocessing steps include contrast enhancement, contrast adaptive equalization and noise reduction;

[0050] A multi-stage region segmentation algorithm is constructed to process the sock image to be detected and the flawless sock image respectively to obtain a set of regions to be detected and a set of regions without flaws; the multi-stage region segmentation algorithm comprises: constructing an energy function to obtain an initial region set; constructing a region adaptive growth algorithm based on fabric structure similarity according to the initial region set to obtain a set of regions with fabric structure consistency; and obtaining a region segmentation result according to the set of regions with fabric structure consistency;

[0051] Extracting the fabric structure shape of each area in the set of areas to be detected, and obtaining a set of fabric structure shapes to be detected in each area; the fabric structure shape is a shape formed by interweaving yarns in the socks;

[0052] Extracting the fabric structure shape of each area in the set of flawless areas, and calculating the average value of all the fabric structure shapes in each area to obtain a standard fabric structure shape model of each area;

[0053] For each area in the set of areas to be detected, calculating the shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model, and if the shape difference exceeds a difference threshold, marking the position where the fabric structure shape to be detected is located as a defect point;

[0054] The detection results of all regions are integrated to determine whether there are defect points in the sock image to be detected, and obtain a sock defect detection result.

[0055] The embodiment of the present application carries out a defect detection test on a sock with different fabric structures in different parts, and the test data set includes: 1000 normal samples; 200 defective samples, and the defect types and sample numbers include: 50 kinks; 60 skipped flowers; 45 star skipped flowers; and 45 broken warps. Among them, kinks are caused by the entanglement or knotting of yarns during the weaving process, resulting in the phenomenon of yarn accumulation on the surface of the socks; skipped flowers are the continuous skipping of 2 or more yarns of similar warp or weft yarns at the same part, so that a mesh is formed locally on the surface of the socks; star skipped flowers are caused by the skipping of 2 to 4 yarns by a yarn to form a star-shaped shape; broken warps are the breakage of one or more warp yarns, forming an obvious strip-shaped structural abnormality on the surface of the socks. Table 1 shows the detection effect of the method of the present embodiment on different defect types. On the same sock, the same defect type has certain characteristic differences under different fabric structure backgrounds, which will bring challenges to defect detection. It can be seen from Table 1 that the method of the present embodiment can still achieve a high detection recall rate and precision.

[0056] Firstly, images are captured and preprocessed by a high-resolution camera to ensure the quality of the input images and provide a reliable data basis for subsequent analysis. Secondly, a multi-stage region segmentation algorithm is used to accurately identify and segment different regions of the fabric structure, thereby improving the accuracy of subsequent defect detection. Next, the fabric structure shape is extracted and analyzed to accurately capture the interweaving characteristics of the sock yarns, making defect detection more targeted. A standard fabric structure shape model is constructed and the shape differences are calculated to achieve an adaptive defect judgment standard. This significantly improves the efficiency and accuracy of sock defect detection.

[0057] Furthermore, the specific steps of the multi-stage region segmentation algorithm include: constructing an energy function, obtaining an initial region set by minimizing the energy function ; Calculating the contour curvature for each initial region in the initial region set;

[0058] Extracting a set of contour feature points of each of the initial regions according to the contour curvature;

[0059] Constructing a spatial constraint function for each of the initial regions according to the set of contour feature points, and defining a valid range of the initial region according to the spatial constraint function;

[0060] Extracting intensity features and direction features within the effective range of each of the initial regions;

[0061] Constructing a fabric structure similarity function according to the intensity feature and the direction feature, and calculating the fabric structure similarity;

[0062] According to the fabric structure similarity, a set of fabric structure consistency regions is obtained by a region adaptive growth method;

[0063] The fabric structure consistency regions with the same fabric structure but belonging to different regions are merged, and the region segmentation result is obtained after boundary optimization.

[0064] Furthermore, the formula of the energy function is as follows: in, represents the energy function; Represents the contour curve; and represents the weight coefficient; and Respectively represent the data term, shape term and smoothness term of the energy function; Represents a point on the contour curve The image feature vector at ; Indicates area The average eigenvalue of Indicates area The characteristic standard deviation of Indicates the point on the current curve The location coordinates of Indicates a point on the reference contour curve template The corresponding position coordinates are obtained from the reference contour curve template from the corresponding flawless sock image; Represents the Euclidean distance between two points; Indicates that the curve is at point The second-order derivative at; the fabric structure similarity function in, Represents pixel and The intensity feature difference measure of Represents pixel and The directional feature difference measure, and Represents the weight coefficient.

[0065] Initial segmentation is performed by minimizing the energy function to ensure basic segmentation accuracy; the contour curvature and feature point extraction are used to more accurately identify region boundaries; the spatial constraint function is introduced to limit the effective range to avoid over-segmentation; the fabric structure similarity function is constructed by combining strength and direction characteristics to achieve an accurate description of the fabric structure characteristics; the regional growing method based on fabric structure similarity ensures the consistency of fabric structure characteristics in the segmented area; finally, the final segmentation result is obtained through region merging and boundary optimization to improve the segmentation effect.

[0066] Furthermore, the specific steps of extracting a set of contour feature points include: constructing a contour curvature sequence based on the contour curvature of the initial area, and processing the contour curvature sequence using Gaussian filtering; detecting local maximum and local minimum values ​​in the contour curvature sequence after filtering; setting a curvature threshold and a minimum spacing threshold, and filtering the local maximum and the local minimum values ​​according to the curvature threshold and the minimum spacing threshold to obtain the contour feature point set.

[0067] Gaussian filtering is used to process the curvature sequence to reduce the impact of noise; local maximum and minimum values ​​are detected to accurately capture key feature points; curvature thresholds and minimum spacing thresholds are introduced to ensure the representativeness and reasonable distribution of feature points.

[0068] Furthermore, generating the spatial constraint function and defining the effective range specifically includes: according to the contour feature point set of each initial area Calculate region centroid ;in, represents the number of contour feature points in the contour feature point set, Indicates Contour feature points The coordinates of

[0069] The spatial constraint function is constructed according to the region centroid and the contour feature point set, and the formula is as follows: in, The coordinates are The spatial constraint function of the pixel point; the first term represents the constraint of the pixel point from the centroid of the region; the second term represents the constraint of the pixel point from the contour feature point; represents the regional scale parameter, which is proportional to the size of the initial region; is the parameter of the influence range of the feature point, which is determined by the distribution density of the contour feature points;

[0070] Setting constraint thresholds , defining the effective range of the initial area The effective range of the adjacent initial area is adjusted, specifically including: when the effective range of two adjacent areas and When there is overlap, within the overlapping area, if the spatial constraint value Points belong , if the space constraint value Then the point belongs to ;

[0071] The effective range of each of the initial regions is updated.

[0072] By providing stable reference points through the region centroid and contour feature points, and then designing the spatial constraint function and defining the effective range of the region, excessive expansion of the region is avoided; the adjustment mechanism for the effective range of adjacent regions avoids region overlap and missed detection problems.

[0073] Furthermore, the specific steps of the method for adaptively growing regions based on fabric structure similarity include:

[0074] For each initial region, the contour feature point set is used as the initial seed point set;

[0075] Select pixel points that meet the first constraint condition in the neighborhood of each initial seed point and add them to the initial seed point set to obtain a seed point set; add all seed points in the seed point set to the queue of points to be processed and the set of segmented points ;

[0076] When the queue of pending points When it is not empty, the loop executes: Take a point ;for Each pixel in the neighborhood of If you click Satisfying the second constraint, Add to the segmented point set and the queue of pending points ;

[0077] When the queue of pending points When empty, region adaptive growth ends.

[0078] Furthermore, the first constraint condition includes: pixel points The fabric structure consistency of the pixel point is greater than the consistency threshold, which is the weighted sum of the fabric structure consistency mean and standard deviation of all points in the neighborhood; the pixel point is within the effective range of the initial area; the distance between the pixel point and the existing seed point is greater than the seed point spacing threshold, which is determined by the average distance between adjacent contour feature points; the pixel point is within the effective range of the initial area; the distance between the pixel point and the existing seed point is greater than the seed point spacing threshold, which is determined by the average distance between adjacent contour feature points; The calculation formula for fabric structure consistency is: in, Indicate point The number of points in the neighborhood; Indicate point Neighborhood points; Indicate point With point Similarity of fabric structure;

[0079] The second constraint condition includes: Not in the segmented point set midpoint within the effective range of the initial area; The growth probability is greater than the adaptive threshold; the growth probability and the adaptive threshold calculation formula are as follows: in, Indicate point The growth probability of Indicates the grown area; Indicate point With area The average fabric structure similarity of all points within; represents the tolerance parameter; represents the adaptive threshold; Respectively represent the initial region The mean and standard deviation of fabric structure similarity between all point pairs in , and Represents the adjustment coefficient.

[0080] The contour feature points are used as the initial seed points to ensure the reliability of the starting point of regional adaptive growth; two constraints are introduced to ensure the accuracy and controllability of regional adaptive growth; the application of the pending queue can achieve efficient regional adaptive growth efficiency.

[0081] Furthermore, the specific steps of extracting the fabric structure shape include: generating a binary edge image through an edge detection operator; performing a connected domain analysis on the binary edge image to mark each independent sub-region; extracting a contour point sequence of the independent sub-region using a neighborhood tracking algorithm; performing a closure check on the contour point sequence, and when the contour is not closed, interpolating through curve fitting to obtain a set of closed contour curves; optimizing each closed contour curve in the set of closed contour curves to obtain the fabric structure shape.

[0082] Through edge detection and connected domain analysis, the contour of the fabric structure shape can be accurately extracted; neighborhood tracking and curve fitting are used to ensure the integrity of the shape contour.

[0083] Further, the square root velocity function is used to represent the fabric structure shape, specifically including: normalizing the optimized closed contour curve into a parametric equation; calculating the velocity vector and the velocity vector modulus of the closed contour curve according to the parametric equation, and obtaining the square root velocity function of the fabric structure shape, the formula is as follows: in, Represents the derivative of the closed contour curve parametric equation curve, that is, the curve in The velocity vector at the moment; represents the velocity vector modulus; .

[0084] The square root velocity function is used to represent the shape, which only depends on the derivative information of the closed contour curve and is therefore translation invariant. It provides a standardized shape description method and facilitates subsequent shape difference calculation and comparative analysis.

[0085] Furthermore, the shape difference calculation step is: calculating the shape distance and phase distance between the fabric structure shape to be detected and the standard fabric structure shape model, and calculating the total distance according to the shape distance and the phase distance to obtain the shape difference. , Phase distance and total distance The calculation formula is as follows: in, and Respectively represent the fabric structure shape to be tested and the standard fabric structure shape model; and represent the square root velocity functions of the fabric structure shape to be tested and the standard fabric structure shape model respectively; represents the best parameterized function found by the optimization algorithm, such that and The closed contour curve is aligned with represents its derivative.

[0086] Through the square root velocity function The shape distance can be represented by the norm, which can eliminate the influence of translation, rotation and scaling transformations and ensure that only the differences related to the curve shape itself are captured; the phase distance can measure the parameterized differences between two curves and capture subtle flaws; the comprehensive consideration of shape distance and phase distance can provide a more comprehensive shape difference measurement.

[0087] Furthermore, the difference threshold is calculated based on the flawless sock image, and the specific steps are: obtaining all the fabric structure shapes in each area; calculating the shape distance and phase distance between each fabric structure shape and the standard fabric structure shape model; calculating the total distance based on the shape distance and the phase distance to obtain a total distance set; performing statistical analysis on the total distance set, and determining the difference threshold based on the upper limit of the total distance set.

[0088] A difference threshold standard is established based on the image of defect-free socks to ensure the rationality of the threshold. The difference threshold is determined through statistical analysis to improve the accuracy and reliability of defect judgment. The adaptive threshold determination mechanism enhances the practicality and adaptability of the defect detection method in handling different types of socks.

[0089] Embodiment 2

[0090] The present invention also provides a sock defect detection system based on machine vision, comprising:

[0091] An image acquisition module, which acquires the image of the socks to be inspected and the corresponding image of the flawless socks and performs preprocessing;

[0092] A region segmentation module constructs a multi-stage region segmentation algorithm to process the to-be-detected sock image and the flawless sock image respectively to obtain a to-be-detected region set and a flawless region set;

[0093] A shape extraction module is used to extract the fabric structure shape of each area in the set of areas to be detected, and obtain the set of fabric structure shapes to be detected in each area; extract the fabric structure shape of each area in the set of flawless areas, and calculate the average value of all the fabric structure shapes in each area to obtain a standard fabric structure shape model of each area;

[0094] a defect detection module, for each area in the set of areas to be detected, calculating a shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model, and marking a position where the fabric structure shape to be detected is located as a defect point if the shape difference exceeds a difference threshold;

[0095] The result integration module integrates the defect detection results of all regions, determines whether there are defect points in the sock image to be detected, and obtains the sock defect detection result.

[0096] Furthermore, the specific steps of the multi-stage region segmentation algorithm include:

[0097] Constructing an energy function, and obtaining an initial region set by minimizing the energy function;

[0098] Calculating the contour curvature for each initial region in the initial region set;

[0099] Extracting a set of contour feature points of each of the initial regions according to the contour curvature;

[0100] Constructing a spatial constraint function for each of the initial regions according to the set of contour feature points, and defining a valid range of the initial region according to the spatial constraint function;

[0101] Extracting intensity features and direction features within the effective range of each of the initial regions;

[0102] Constructing a fabric structure similarity function according to the intensity feature and the direction feature, and calculating the fabric structure similarity;

[0103] According to the fabric structure similarity, a set of fabric structure consistency regions is obtained by a region adaptive growth method;

[0104] The fabric structure consistency regions with the same fabric structure but belonging to different regions are merged, and the region segmentation result is obtained after boundary optimization.

[0105] Furthermore, the specific steps of the fabric structure similarity region adaptive growth algorithm include:

[0106] For each initial region, the contour feature point set is used as the initial seed point set;

[0107] Select pixel points that meet the first constraint condition in the neighborhood of each initial seed point and add them to the initial seed point set to obtain a seed point set; the first constraint condition includes: the fabric structure consistency of the pixel point is greater than the consistency threshold, the fabric structure consistency and the consistency threshold are calculated according to the fabric structure similarity; the pixel point is within the effective range of the initial area; the distance between the pixel point and the existing seed point is greater than the seed point spacing threshold, and the seed point spacing threshold is determined by the average distance of adjacent contour feature points;

[0108] Add all seed points in the seed point set to the queue of points to be processed and the set of segmented points ;

[0109] When the queue of pending points When it is not empty, the loop executes: Take a point ;for Every point in the neighborhood of If you click Satisfying the second constraint, Add to the segmented point set and the queue of pending points ; The second constraint condition includes: point Not in the segmented point set midpoint within the effective range of the initial area; The growth probability of is greater than an adaptive threshold, wherein the growth probability and the adaptive threshold are calculated according to the fabric structure similarity;

[0110] When the queue of pending points When empty, region adaptive growth ends.

[0111] Furthermore, the specific steps of extracting the fabric structure shape include: generating a binary edge image through an edge detection operator; performing a connected domain analysis on the binary edge image to mark each independent sub-region; extracting a contour point sequence of the independent sub-region using a neighborhood tracking algorithm; performing a closure check on the contour point sequence, and when the contour is not closed, interpolating through curve fitting to obtain a set of closed contour curves; optimizing each closed contour curve in the set of closed contour curves to obtain the fabric structure shape.

[0112] Furthermore, the step of calculating the shape difference is: calculating the shape distance and the phase distance between the fabric structure shape to be detected and the standard fabric structure shape model, and calculating the total distance according to the shape distance and the phase distance to obtain the shape difference.

[0113] Furthermore, the difference threshold is calculated based on the flawless sock image, and the specific steps are: obtaining all the fabric structure shapes in each area; calculating the shape distance and phase distance between each fabric structure shape and the standard fabric structure shape model; calculating the total distance based on the shape distance and the phase distance to obtain a total distance set; performing statistical analysis on the total distance set, and determining the difference threshold based on the upper limit of the total distance set.

[0114] Although 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 the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A socks defect detection method based on machine vision, characterized in that: include: Collect the images of the socks to be inspected and the corresponding images of the flawless socks and perform preprocessing; Constructing a multi-stage region segmentation algorithm, processing the to-be-detected sock image and the flawless sock image respectively to obtain a to-be-detected region set and a flawless region set; The multi-stage region segmentation algorithm comprises: constructing an energy function to obtain an initial region set; constructing a region adaptive growth algorithm based on fabric structure similarity according to the initial region set to obtain a fabric structure consistency region set; and obtaining a region segmentation result according to the fabric structure consistency region set; Extracting the fabric structure shape of each area in the set of areas to be detected, and obtaining a set of fabric structure shapes to be detected in each area; the fabric structure shape is a shape formed by interweaving yarns in the socks; Extracting the fabric structure shape of each area in the set of flawless areas, and calculating the average value of all the fabric structure shapes in each area to obtain a standard fabric structure shape model of each area; For each area in the set of areas to be detected, calculating the shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model, and if the shape difference exceeds a difference threshold, marking the position where the fabric structure shape to be detected is located as a defect point; Integrate the detection results of all areas, determine whether there are defect points in the sock image to be detected, and obtain a sock defect detection result; The specific steps of extracting the fabric structure shape include: generating a binary edge image by an edge detection operator; performing a connected domain analysis on the binary edge image to mark each independent sub-region; extracting a contour point sequence of the independent sub-region using a neighborhood tracking algorithm; performing a closedness check on the contour point sequence, and when the contour is not closed, interpolating by curve fitting to obtain a closed contour curve set; optimizing each closed contour curve in the closed contour curve set to obtain the fabric structure shape; The square root velocity function is used to represent the fabric structure shape, specifically including: normalizing the optimized closed contour curve into a parametric equation; calculating the velocity vector and the velocity vector modulus of the closed contour curve according to the parametric equation, and obtaining the square root velocity function of the fabric structure shape, the formula is as follows: in, Represents the derivative of the closed contour curve parametric equation curve, that is, the curve in The velocity vector at the moment; represents the velocity vector modulus; .

2. The method for detecting sock defects based on machine vision according to claim 1, characterized in that: The specific steps of the multi-stage region segmentation algorithm include: Constructing an energy function, and obtaining an initial region set by minimizing the energy function; Calculating the contour curvature for each initial region in the initial region set; Extracting a set of contour feature points of each of the initial regions according to the contour curvature; Constructing a spatial constraint function for each of the initial regions according to the set of contour feature points, and defining a valid range of the initial region according to the spatial constraint function; Extracting intensity features and direction features within the effective range of each of the initial regions; Constructing a fabric structure similarity function according to the intensity feature and the direction feature, and calculating the fabric structure similarity; According to the fabric structure similarity, a set of fabric structure consistency regions is obtained by a region adaptive growth method; The fabric structure consistency regions with the same fabric structure but belonging to different regions are merged, and the region segmentation result is obtained after boundary optimization.

3. The method for detecting sock defects based on machine vision according to claim 2, characterized in that: The specific steps of extracting a set of contour feature points include: constructing a contour curvature sequence based on the contour curvature of the initial area, and processing the contour curvature sequence using a Gaussian filter; detecting the local maximum and local minimum in the contour curvature sequence after filtering; setting a curvature threshold and a minimum spacing threshold, and filtering the local maximum and the local minimum according to the curvature threshold and the minimum spacing threshold to obtain the contour feature point set.

4. The method for detecting sock defects based on machine vision according to claim 2, characterized in that: Generating the spatial constraint function and defining the effective range specifically includes: calculating the region centroid based on the contour feature point set of each initial region; constructing the spatial constraint function based on the region centroid and the contour feature point set; setting a constraint threshold to define the effective range of the initial region; adjusting the effective range of adjacent initial regions and updating the effective range of each initial region.

5. The method for detecting sock defects based on machine vision according to claim 1, characterized in that: The specific steps of the fabric structure similarity region adaptive growth algorithm include: For each initial region, the contour feature point set is used as the initial seed point set; Select pixel points that meet the first constraint condition in the neighborhood of each initial seed point and add them to the initial seed point set to obtain a seed point set; the first constraint condition includes: the fabric structure consistency of the pixel point is greater than the consistency threshold, and the fabric structure consistency and consistency threshold are calculated according to the fabric structure similarity; the pixel point is within the effective range of the initial area; the distance between the pixel point and the existing seed point is greater than the seed point spacing threshold, and the seed point spacing threshold is determined by the average distance of adjacent contour feature points; all seed points in the seed point set are added to the queue of points to be processed and the set of segmented points ; When the queue of pending points When it is not empty, the loop executes: Take a point ;for Every point in the neighborhood of If you click Satisfying the second constraint, Add to the segmented point set and the queue of pending points ; The second constraint condition includes: point Not in the segmented point set midpoint within the effective range of the initial area; The growth probability is greater than the adaptive threshold, and the growth probability and the adaptive threshold are calculated according to the fabric structure similarity; when the queue of points to be processed When empty, region adaptive growth ends.

6. The method for detecting sock defects based on machine vision according to claim 1, characterized in that: The step of calculating the shape difference is: calculating the shape distance and the phase distance between the fabric structure shape to be detected and the standard fabric structure shape model, and calculating the total distance according to the shape distance and the phase distance to obtain the shape difference.

7. The method for detecting sock defects based on machine vision according to claim 1, characterized in that: The difference threshold is calculated based on the flawless sock image, and the specific steps are: obtaining all the fabric structure shapes in each area; Calculating the shape distance and phase distance between each of the fabric structure shapes and the standard fabric structure shape model; calculating the total distance according to the shape distance and the phase distance to obtain a total distance set; Statistical analysis is performed on the total distance set, and the difference threshold is determined according to an upper limit of the total distance set.

8. A sock defect detection system based on machine vision, characterized in that: include: An image acquisition module, which acquires the image of the socks to be inspected and the corresponding image of the flawless socks and performs preprocessing; A region segmentation module constructs a multi-stage region segmentation algorithm to process the to-be-detected sock image and the flawless sock image respectively to obtain a to-be-detected region set and a flawless region set; The multi-stage region segmentation algorithm comprises: constructing an energy function to obtain an initial region set; constructing a region adaptive growth algorithm based on fabric structure similarity according to the initial region set to obtain a fabric structure consistency region set; and obtaining a region segmentation result according to the fabric structure consistency region set; A shape extraction module extracts the fabric structure shape of each area in the set of areas to be detected to obtain a set of fabric structure shapes to be detected in each area; extracts the fabric structure shape of each area in the set of flawless areas, and calculates the average value of all the fabric structure shapes in each area to obtain a standard fabric structure shape model for each area; a defect detection module, for each area in the set of areas to be detected, calculating a shape difference between each fabric structure shape to be detected in the set of fabric structure shapes to be detected and the corresponding standard fabric structure shape model, and marking a position where the fabric structure shape to be detected is located as a defect point if the shape difference exceeds a difference threshold; A result integration module integrates the defect detection results of all regions, determines whether there are defect points in the sock image to be detected, and obtains the sock defect detection result; The specific steps of extracting the fabric structure shape include: generating a binary edge image by an edge detection operator; performing a connected domain analysis on the binary edge image to mark each independent sub-region; extracting a contour point sequence of the independent sub-region using a neighborhood tracking algorithm; performing a closedness check on the contour point sequence, and when the contour is not closed, interpolating by curve fitting to obtain a closed contour curve set; optimizing each closed contour curve in the closed contour curve set to obtain the fabric structure shape; The square root velocity function is used to represent the fabric structure shape, specifically including: normalizing the optimized closed contour curve into a parametric equation; calculating the velocity vector and the velocity vector modulus of the closed contour curve according to the parametric equation, and obtaining the square root velocity function of the fabric structure shape, the formula is as follows: in, Represents the derivative of the closed contour curve parametric equation curve, that is, the curve in The velocity vector at the moment; represents the velocity vector modulus; .

Citation Information

Patent Citations

  • Cloth defect detection method based on image processing

    CN107870172A

  • Defect detection method, electronic equipment and storage medium

    CN117274133A