Thread detection methods, apparatus, systems and equipment based on image recognition and deep learning

By using a thread detection method based on image recognition and deep learning, the problems of low detection efficiency and low accuracy in existing technologies are solved, achieving comprehensive thread detection and efficient, low-cost detection results.

CN120931998BActive Publication Date: 2026-06-30JIANGSU JINGYI INTELLIGENT CONTROL TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JIANGSU JINGYI INTELLIGENT CONTROL TECH CO LTD
Filing Date
2025-07-28
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing thread inspection methods suffer from low inspection efficiency, low accuracy, and high equipment and labor costs, making them unable to effectively detect the integrity of threads and potential quality issues.

Method used

This study employs an image recognition and deep learning approach. By acquiring multi-angle thread images and filtering them using image gradients and information entropy, the study measures the thread's inner and outer diameters, pitch, and angle. A deep learning model is then used to detect thread defects, and a classification and segmentation network is combined to determine whether the thread is qualified.

Benefits of technology

It enables comprehensive inspection of threads, reduces inspection costs, improves inspection efficiency and accuracy, and solves the problems of low inspection efficiency and low accuracy in existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120931998B_ABST
    Figure CN120931998B_ABST
Patent Text Reader

Abstract

This invention relates to the field of thread inspection technology, and discloses a thread inspection method, apparatus, system, and device based on image recognition and deep learning (DL). The method includes: acquiring thread images from multiple angles; filtering the thread images by combining image gradients and information entropy; measuring the thread's inner and outer diameters, thread pitch, and thread angle using image recognition methods based on the filtered thread images; detecting whether there are damage or folding defects in the thread teeth; detecting whether there are crack defects in the thread as a whole; and using a deep learning model combining classification and segmentation networks to detect whether there are crack defects at the top, waist, and bottom of the thread; comparing the measured thread inner and outer diameters, thread pitch, and thread angle with standard specifications; and determining whether the thread is qualified based on the defect detection results of the thread teeth, the thread as a whole, and the top, waist, and bottom of the thread. This invention can reduce inspection costs and improve inspection efficiency and accuracy while achieving overall thread inspection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of thread inspection technology, and in particular to a thread inspection method, apparatus, system and equipment based on image recognition and deep learning. Background Technology

[0002] A thread is a helical, continuous, raised section with a specific cross-section formed on the surface of a cylinder or cone. In mechanical structures, it serves to fasten connections, transmit power, and seal. In recent years, with the continuous improvement of mechanical design precision, the requirements for thread precision have also increased, and correspondingly, the requirements for thread inspection have become increasingly stringent.

[0003] In existing technologies, thread inspection methods can be divided into two categories: single-item inspection methods and comprehensive inspection methods. Single-item inspection methods use techniques such as the needle gauge method and the double-ball method to inspect threads. These methods typically only detect a single characteristic of the thread, resulting in low inspection efficiency and an inability to assess the completeness of the thread, thus failing to effectively eliminate potential quality issues. Comprehensive inspection methods utilize multiple inspection methods, such as using a go-end thread gauge to check the thread's spunness, using a no-go thread gauge to check the pitch diameter, and using a coordinate measuring machine (CMM) or a thread measuring instrument for thread inspection. Compared to single-item inspection methods, comprehensive inspection methods can improve inspection efficiency and accuracy. However, comprehensive inspection methods typically cannot provide specific geometric parameter values ​​for the thread, resulting in lower inspection accuracy. Furthermore, when using a CMM or thread measuring instrument, there are issues with high equipment and labor costs, as well as long equipment operation times leading to low inspection efficiency. Summary of the Invention

[0004] Therefore, the technical problem to be solved by the present invention is to overcome the shortcomings of the prior art and provide a thread detection method, device, system and equipment based on image recognition and deep learning, which can reduce detection costs and improve detection efficiency and accuracy while realizing overall thread detection.

[0005] To address the aforementioned technical problems, this invention provides a thread detection method based on image recognition and deep learning, comprising:

[0006] Obtain thread images from multiple angles, and filter the thread images by combining image gradient and information entropy;

[0007] Based on the screened thread images, image recognition methods are used to measure the thread inner and outer diameters, thread pitch, and thread angle, detect whether there are damage or folding defects in the thread teeth, detect whether there are crack defects in the thread as a whole, and use a deep learning model that combines classification network and segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread.

[0008] The measured inner and outer diameters of the thread, the thread pitch, and the thread angle are compared with the standard specifications. The thread quality is determined by combining the defect detection results of the thread teeth, the overall thread, and the top, waist, and bottom of the thread.

[0009] Furthermore, the method for measuring the inner and outer diameters of the thread is as follows:

[0010] The thread image is corrected using affine transformation, and the thread image is denoised using Gaussian filtering.

[0011] The template matching method is used to identify the thread shape in the thread image, and the dynamic threshold segmentation method is used to extract the feature region in the thread shape that meets the threshold range.

[0012] The feature region is expanded, and the Harris corner detection method is used to extract the edge points of each inner diameter and outer diameter of the thread respectively.

[0013] The K-means clustering method is used to screen the inner and outer diameter edge points of the thread. Based on the screened inner and outer diameter edge points, the distance between each pair of edge points on the inner and outer diameters is calculated to obtain the inner and outer diameters of the thread.

[0014] Furthermore, the method for measuring the thread pitch is as follows:

[0015] Affine transformation is used to correct the thread image, the Canny algorithm is used to extract the thread edges, and the Sobel algorithm is used to perform gradient calculations to find the thread contour.

[0016] Use shape descriptors to identify the shape and characteristics of the thread to obtain the thread segment;

[0017] The similarity of thread segments is calculated using Euclidean distance, and thread segments that conform to the thread profile are selected.

[0018] The Hough transform is used to extract the helix from the filtered thread segments, and pairwise traversal is used to reduce noise in the connected regions of the helix.

[0019] Calculate the spacing between adjacent helical lines to obtain the thread pitch.

[0020] Furthermore, the method for measuring the thread angle is as follows:

[0021] Affine transformation is used to correct the thread image, and global threshold segmentation is used to filter the feature regions of the thread that meet the threshold range.

[0022] Gaussian filtering is used to eliminate noise in the feature region, and image dilation and erosion operations are used to divide the feature region into multiple regions.

[0023] The least squares method is used to fit straight lines to the center of different regions, and the angle between adjacent fitted lines is taken as the thread angle.

[0024] Furthermore, the detection of whether the thread teeth are damaged or folded specifically involves:

[0025] Affine transformation is used to correct the thread image, performing contrast and gamma correction.

[0026] Global threshold segmentation is used to extract the feature regions of the thread that meet the threshold range, and limit filtering is used to eliminate random interference in the feature regions.

[0027] The thread target in the feature region is divided into multiple regions of different sizes by image erosion operation. If there is a tooth decay defect, the area of ​​the corresponding region is smaller than the normal area. If there is a folding defect in the depth or length direction, the area of ​​the corresponding region is larger than the normal area. The presence of tooth decay, folding defect in the depth or length direction of the thread is determined by the area size of the segmented regions.

[0028] The detection of whether the overall thread has cracks or defects specifically involves:

[0029] The thread image is corrected using affine transformation, and contrast and gamma corrections are performed on the thread image.

[0030] Global threshold segmentation is used to obtain multiple feature regions of different area sizes that meet the threshold range for thread crack defects, and Gaussian filtering is used to eliminate noise in the feature regions.

[0031] If a crack defect exists, the area of ​​the corresponding feature region is smaller than the area under normal conditions. Based on the area size of the feature region obtained after Gaussian filtering, the feature regions where the crack may be located are screened. The least squares method is used to fit the center of the screened feature regions with line segments. The presence of a crack defect is determined based on the total length of the line segments.

[0032] Furthermore, the method of using a deep learning model combining a classification network and a segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread is as follows:

[0033] The spiral image is segmented into top, waist, and bottom images, preprocessed, and then divided into training and testing sets respectively.

[0034] A thread crack detection model is constructed, comprising a classification network and a segmentation network. The model is trained using training sets of top, waist, and bottom images, respectively. During training, the overall loss function is constructed by combining the segmentation and classification losses:

[0035] s=λ1*Wd +λ2*W f ,

[0036] Where λ1 and λ2 are preset parameters, W d To divide the loss, W f For classification loss;

[0037] The thread crack detection model was trained by inputting test sets of top, waist, and bottom images respectively, and the detection results of whether there are crack defects at the top, waist, and bottom of the thread were obtained.

[0038] Furthermore, the W d The calculation method is as follows:

[0039] W d =-(G*log(S)+(1-G)*log(1-S)),

[0040] Where S is the output value of the segmentation network, and G is the true label of the segmentation network;

[0041] The W d The calculation method is as follows:

[0042] W f =-(Y*log(C)+(1-Y)*log(1-C)),

[0043] Where C is the output value of the classification network, and Y is the true label of the classification network.

[0044] The present invention also provides a thread detection device based on image recognition and deep learning, comprising:

[0045] A turntable, with a threaded object to be tested placed at the end of the turntable and rotated under the drive of the turntable;

[0046] At least one camera is positioned around the end of the turntable to capture multi-angle images of the thread as the object under test rotates;

[0047] A light source, used to emit parallel light that shines towards the end of the turntable;

[0048] The processor and a computer-readable storage medium, on which a computer program is stored, implement the described thread detection method based on image recognition and deep learning when executed by the processor.

[0049] This invention also provides a thread detection system based on image recognition and deep learning, comprising:

[0050] The image acquisition and processing module is used to acquire thread images from multiple angles and filter thread images by combining image gradients and information entropy.

[0051] The thread measurement module is used to measure the inner and outer diameters of the thread, the thread pitch, and the thread angle using image recognition methods based on the screened thread images.

[0052] The defect detection module is used to detect whether there is damage or folding defects in the thread teeth, and whether there are crack defects in the thread as a whole. It uses a deep learning model that combines a classification network and a segmentation network to detect whether there are crack defects at the top, waist and bottom of the thread.

[0053] The result judgment module is used to compare the measured inner and outer diameters of the thread, the thread pitch, and the thread angle with the standard specification values, and to judge whether the thread is qualified by combining the defect detection results of the thread teeth, the thread as a whole, and the top, waist, and bottom of the thread.

[0054] The present invention also provides a thread detection device based on image recognition and deep learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the thread detection method based on image recognition and deep learning.

[0055] Compared with the prior art, the above-described technical solution of the present invention has the following advantages:

[0056] This invention achieves comprehensive inspection of the entire thread by acquiring multi-angle images of the thread and measuring the thread's inner and outer diameters, thread pitch, thread angle data, and detecting defects in the thread teeth, the thread as a whole, and various parts of the thread. At the same time, the inspection process uses image recognition and deep learning to reduce reliance on equipment and manual operation, effectively reducing costs while improving inspection efficiency and accuracy. Attached Figure Description

[0057] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein:

[0058] Figure 1 This is a flowchart of a method in a preferred embodiment of the present invention.

[0059] Figure 2 This is a schematic diagram of the device in a preferred embodiment of the present invention.

[0060] Explanation of the reference numerals in the accompanying drawings: 1. Turntable; 101. End of turntable; 2. Camera; 3. Light source. Detailed Implementation

[0061] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.

[0062] Reference Figure 1 As shown, this invention discloses a thread detection method based on image recognition and deep learning, comprising the following steps:

[0063] S1: Obtain thread images from multiple angles, and filter thread images by combining image gradient and information entropy.

[0064] The method for calculating image gradients is as follows:

[0065] f(x,y)=(s(x+1,y)-s(x,y)) 2 +(s(x,y+1)-s(x,y)) 2 ,

[0066] Where f(x,y) is the image gradient, that is, the gradient value at coordinates (x,y) in the thread image, and s(x,y) is the gray value at coordinates (x,y) in the image.

[0067] The method for calculating information entropy is as follows:

[0068]

[0069] Where f is the information entropy of the thread image, and r i Let q(r) be the gray level of the i-th level. i ) represents the probability of the i-th gray level value appearing, and R represents the maximum value of the image gray level.

[0070] The greater the image gradient, the clearer the edges; the greater the information entropy, the clearer the image. Therefore, in this embodiment, after acquiring thread images from multiple angles, the image gradient and information entropy are calculated and compared with a preset threshold to select high-quality thread images for subsequent detection.

[0071] S2: Based on the screened thread images, use image recognition methods to measure the thread inner diameter, outer diameter, thread pitch, and thread angle.

[0072] S2-1: The inner and outer diameters of a thread refer to the diameters of the inner and outer sides of the thread. The inner diameter is an important parameter reflecting the quality of thread machining, while the outer diameter directly affects the tightening effect of the thread. The method for measuring the inner and outer diameters of the thread is as follows:

[0073] S2-1-1: Use affine transformation to correct the thread image and Gaussian filtering to denoise the thread image; affine transformation includes operations such as scaling, rotating, and translating the image matrix, while Gaussian filtering can eliminate noise that is randomly distributed or follows a normal distribution.

[0074] S2-1-2: Use template matching to identify thread patterns in thread images to determine the detection target. Use dynamic thresholding to extract feature regions in the thread pattern that meet the threshold range.

[0075] S2-1-3: Perform an expansion operation on the feature region to make it more prominent. Use the Harris corner detection method to extract the edge points of each inner diameter and outer diameter of the thread.

[0076] S2-1-4: Use K-means clustering to filter the inner and outer diameter edge points of the thread. Calculate the distance between each pair of edge points on the inner and outer diameters based on the filtered inner and outer diameter edge points to obtain the inner and outer diameters of the thread.

[0077] S2-2: The distance between adjacent thread teeth affects the tightening performance of the thread. The method for measuring the thread pitch is as follows:

[0078] S2-2-1: Use affine transformation to correct the thread image, use the Canny algorithm to extract the thread edges, and use the Sobel algorithm to perform gradient calculations to find the thread profile.

[0079] S2-2-2: Use shape descriptors to identify the shape and characteristics of the thread and obtain the thread segment.

[0080] S2-2-3: Calculate the similarity of thread segments using Euclidean distance to filter out thread segments that conform to the thread profile.

[0081] S2-2-4: Use Hough transform to extract helices from the filtered thread segments, and use pairwise traversal method as a connected component algorithm to reduce noise in the connected regions of the helices.

[0082] S2-2-5: Calculate the spacing between adjacent helical lines to obtain the thread pitch.

[0083] S2-3: The angle between adjacent thread teeth has a significant impact on thread engagement. The method for measuring the thread angle is as follows:

[0084] S2-3-1: Use affine transformation to correct the thread image, and use global threshold segmentation to filter the feature regions of the thread that meet the threshold range.

[0085] S2-3-2: Use Gaussian filtering to eliminate noise in the feature region, and divide the feature region into multiple regions through image dilation and erosion operations.

[0086] S2-3-3: Use the least squares method to fit a straight line to the center of different regions, and use the angle between adjacent fitted lines as the thread angle.

[0087] S3: Use image recognition methods to detect whether there is damage or folding defects in the depth and length directions of the thread teeth. The specific detection method is as follows:

[0088] S3-1: Use affine transformation to correct the thread image, performing contrast and gamma correction on the thread image.

[0089] S3-2: Use global threshold segmentation to extract the feature regions of the thread that meet the threshold range, and use limit filtering to eliminate random interference in the feature regions.

[0090] S3-3: The thread target in the feature area is divided into multiple regions of different sizes by image erosion operation. If there is a tooth decay defect, the area of ​​the corresponding region is smaller than the normal area. If there is a folding defect in the depth or length direction, the area of ​​the corresponding region is larger than the normal area. The presence of tooth decay, folding defect in the depth or length direction of the thread is determined based on the area size of the segmented regions.

[0091] S4: Use image recognition methods to detect the presence of cracks in the overall thread. Cracks in the overall thread are typically a relatively long, longitudinally extending straight line or curve. The specific detection method is as follows:

[0092] S4-1: Use affine transformation to correct the thread image, and perform contrast correction and gamma correction on the thread image.

[0093] S4-2: Use global threshold segmentation to obtain multiple feature regions of different area sizes that meet the threshold range for thread crack defects. Use Gaussian filtering to eliminate noise that is randomly distributed or follows a normal distribution in the feature regions.

[0094] S4-3: If a crack defect exists, the area of ​​the corresponding feature region is smaller than the area under normal conditions. Based on the area size of the feature region obtained after Gaussian filtering, the feature regions where cracks may be located are screened. The least squares method is used to fit the center of the screened feature regions with line segments. The presence of crack defects is determined based on the total length of the line segments. Cracks are generally long straight lines or curves. If the line segment length is too short, it is generally not a crack. The cases that are not cracks are screened out in this step.

[0095] S5: Use a deep learning (DL) model that combines a classification network and a segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread. Specifically:

[0096] S5-1: Segment the thread image into top, waist, and bottom images, preprocess them, and divide them into training and test sets respectively. The preprocessing methods include affine transformation and Gaussian filtering.

[0097] S5-2: Construct a thread crack detection model that includes a classification network and a segmentation network. Train the thread crack detection model using training sets of top, waist, and bottom images, respectively. During training, combine the segmentation loss and classification loss to construct the total loss function. The classification network can be a convolutional neural network, and the segmentation network can be a fully convolutional network, or it can be adjusted according to the actual situation.

[0098] The total loss function is:

[0099] s=λ1*W d +λ2*W f ,

[0100] Where λ1 and λ2 are preset parameters, W d To divide the loss, W f For classification loss;

[0101] W d The calculation method is as follows:

[0102] W d =-(G*log(S)+(1-G)*log(1-S)),

[0103] Where S is the output value of the segmentation network, and G is the true label of the segmentation network;

[0104] W d The calculation method is as follows:

[0105] W f =-(Y*log(C)+(1-Y)*log(1-C)),

[0106] Where C is the output value of the classification network, and Y is the true label of the classification network.

[0107] S5-3: The thread crack detection model trained by inputting test sets of top, waist, and bottom images respectively is used to obtain the detection results of whether there are crack defects at the top, waist, and bottom of the thread.

[0108] S6: Compare the measured inner and outer diameters of the thread, the thread pitch, and the thread angle with the standard specifications, and determine whether the thread is qualified by combining the defect detection results of the thread teeth, the overall thread, and the top, waist, and bottom of the thread.

[0109] This invention also discloses a thread detection device based on image recognition and deep learning, such as... Figure 2As shown, the device includes: a turntable 1, on which a threaded object to be tested is placed at the end 101 of the turntable and rotates at a constant speed under the drive of the turntable 1; at least one camera 2, arranged around the end 101 of the turntable, to capture multi-angle images of the thread during the rotation of the object to be tested; a light source 3, used to emit parallel light toward the end 101 of the turntable, providing illumination compensation to the camera 2 and improving the acquisition quality of the thread images; a processor and a computer-readable storage medium, on which a computer program is stored, which, when executed by the processor, implements a thread detection method based on image recognition and deep learning.

[0110] In this embodiment, two cameras 2 are used as an example. The two cameras 2 are located on both sides of the turntable end 101, and the light source 3 is located between the two cameras 2, facing the turntable end 101. The center of the light source 3, the camera 2 and the turntable end 101 are located on the same plane. After the object to be tested is placed in place, the turntable 1 drives the object to be tested to rotate at a constant speed, while the camera 2 takes pictures at certain time intervals to collect 360-degree thread images of the surface of the object to be tested.

[0111] In this embodiment, a processor and computer-readable storage medium are deployed on the industrial control computer, and camera debugging software is installed. After successful camera debugging, thread images are acquired through the camera. The software development uses Vision Studio 2022. In addition, two or more gigabit network ports are installed on the industrial control computer to connect the camera and receive and send feedback signals.

[0112] This invention also discloses a thread inspection system based on image recognition and deep learning, comprising: an image acquisition and processing module for acquiring thread images from multiple angles and filtering the thread images by combining image gradient and information entropy; a thread measurement module for measuring the inner and outer diameters, thread pitch, and thread angle of the thread using image recognition methods based on the filtered thread images; a defect detection module for detecting whether there are damage or folding defects in the thread teeth, detecting whether there are crack defects in the thread as a whole, and using a deep learning model combining a classification network and a segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread; and a result judgment module for comparing the measured inner and outer diameters, thread pitch, and thread angle of the thread with standard specification values, and judging whether the thread is qualified by combining the defect detection results of the thread teeth, the thread as a whole, and the top, waist, and bottom of the thread.

[0113] The present invention also discloses a thread detection device based on image recognition and deep learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements a thread detection method based on image recognition and deep learning.

[0114] Compared with the prior art, the advantages of the present invention are:

[0115] 1. This invention achieves comprehensive inspection of the entire thread by acquiring multi-angle thread images and measuring the thread inner and outer diameters, thread pitch, thread angle data, and detecting defects in the thread teeth, the thread as a whole, and various parts of the thread.

[0116] 2. The detection process of this invention uses image recognition and deep learning to reduce reliance on equipment and manual operation, thereby improving detection efficiency and accuracy while effectively reducing costs and solving the problem of poor consistency in manual detection.

[0117] 3. When measuring the inner and outer diameters of the thread, the thread pitch, the thread angle, and inspecting defects in the thread teeth, the thread as a whole, and various parts of the thread, different measurement and inspection methods are designed based on the characteristics of each part of the thread to achieve accurate inspection of each part and effectively improve the thread inspection accuracy.

[0118] This invention has been applied in actual production lines and can achieve the following effects:

[0119] 1. The time it takes for the thread on the test object to rotate one revolution, for the camera to acquire multi-angle thread images, and for the processing to obtain the detection results is defined as the production cycle time. The average production cycle time obtained by testing one hundred threads is 2.8 seconds.

[0120] 2. When testing 10,000 threaded objects, the false negative rate for those with defective threads is 0.04%.

[0121] 3. When testing 10,000 threaded objects, the pass rate for those with qualified threads but detected as abnormal is 0.03%.

[0122] 4. The accuracy of the thread image captured by the camera can reach 0.012mm.

[0123] 5. The utilization rate is 98%.

[0124] When using traditional inspection methods for thread inspection, the average production cycle time is 3.5 seconds, the missed inspection rate is 0.1%, the over-inspection rate is 0.08%, the image acquisition accuracy is 0.025 mm, and the utilization rate is 90%. Therefore, it is evident that this invention can indeed improve inspection efficiency and accuracy compared to traditional inspection methods.

[0125] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can be used in the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can be used as a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0126] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0127] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0128] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0129] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.

Claims

1. A thread inspection method based on image recognition and deep learning, characterized in that, include: Obtain thread images from multiple angles, and filter the thread images by combining image gradient and information entropy; Based on the screened thread images, image recognition methods are used to measure the thread inner and outer diameters, thread pitch, and thread angle, detect whether there are damage or folding defects in the thread teeth, detect whether there are crack defects in the thread as a whole, and use a deep learning model that combines classification network and segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread. The measured inner and outer diameters of the thread, the thread pitch, and the thread angle are compared with the standard specifications. The thread quality is determined by combining the defect detection results of the thread teeth, the overall thread, and the top, waist, and bottom of the thread. The detection of whether the thread teeth are damaged or have folding defects specifically involves: Affine transformation is used to correct the thread image, performing contrast and gamma correction. Global threshold segmentation is used to extract the feature regions of the thread that meet the threshold range, and limit filtering is used to eliminate random interference in the feature regions. The thread target in the feature region is divided into multiple regions of different sizes by image erosion operation. If there is a tooth decay defect, the area of ​​the corresponding region is smaller than the normal area. If there is a folding defect in the depth or length direction, the area of ​​the corresponding region is larger than the normal area. The presence of tooth decay, folding defect in the depth or length direction of the thread is determined by the area size of the segmented regions. The detection of whether the overall thread has cracks or defects specifically involves: The thread image is corrected using affine transformation, and contrast and gamma corrections are performed on the thread image. Global threshold segmentation is used to obtain multiple feature regions of different area sizes that meet the threshold range for thread crack defects, and Gaussian filtering is used to eliminate noise in the feature regions. If a crack defect exists, the area of ​​the corresponding feature region is smaller than the area under normal conditions. Based on the area of ​​the feature region obtained after Gaussian filtering, the feature regions where the crack may be located are screened. The least squares method is used to fit the center of the screened feature regions with line segments. The presence of a crack defect is determined based on the total length of the line segments. The method of using a deep learning model combining a classification network and a segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread is as follows: The spiral image is segmented into top, waist, and bottom images, preprocessed, and then divided into training and testing sets respectively. A thread crack detection model is constructed, comprising a classification network and a segmentation network. The model is trained using training sets of top, waist, and bottom images, respectively. During training, the overall loss function is constructed by combining the segmentation and classification losses: , wherein, λ 1 and λ 2 are preset parameters, W d is a segmentation loss, W f is a classification loss; The thread crack detection model was trained by inputting test sets of top, waist, and bottom images respectively, and the detection results of whether there are crack defects at the top, waist, and bottom of the thread were obtained.

2. The thread detection method based on image recognition and deep learning according to claim 1, characterized in that: The method for measuring the inner and outer diameters of the thread is as follows: The thread image is corrected using affine transformation, and the thread image is denoised using Gaussian filtering. The template matching method is used to identify the thread shape in the thread image, and the dynamic threshold segmentation method is used to extract the feature region in the thread shape that meets the threshold range. The feature region is expanded, and the Harris corner detection method is used to extract the edge points of each inner diameter and outer diameter of the thread respectively. The K-means clustering method is used to screen the inner and outer diameter edge points of the thread. Based on the screened inner and outer diameter edge points, the distance between each pair of edge points on the inner and outer diameters is calculated to obtain the inner and outer diameters of the thread.

3. The thread detection method based on image recognition and deep learning according to claim 1, characterized in that: The method for measuring the thread pitch is as follows: Affine transformation is used to correct the thread image, the Canny algorithm is used to extract the thread edges, and the Sobel algorithm is used to perform gradient calculations to find the thread contour. Use shape descriptors to identify the shape and characteristics of the thread to obtain the thread segment; The similarity of thread segments is calculated using Euclidean distance, and thread segments that conform to the thread profile are selected. The Hough transform is used to extract the helix from the filtered thread segments, and pairwise traversal is used to reduce noise in the connected regions of the helix. Calculate the spacing between adjacent helical lines to obtain the thread pitch.

4. The thread detection method based on image recognition and deep learning according to claim 1, characterized in that: The method for measuring the thread angle is as follows: Affine transformation is used to correct the thread image, and global threshold segmentation is used to filter the feature regions of the thread that meet the threshold range. Gaussian filtering is used to eliminate noise in the feature region, and image dilation and erosion operations are used to divide the feature region into multiple regions. The least squares method is used to fit straight lines to the center of different regions, and the angle between adjacent fitted lines is taken as the thread angle.

5. The thread detection method based on image recognition and deep learning according to claim 1, characterized in that: The W d The calculation method is as follows: , in, S The output value of the segmentation network, G For the true labels of the segmented network; The W d The calculation method is as follows: , in, C The output value of the classification network. Y The true labels for classifying the network.

6. A thread detection device based on image recognition and deep learning, characterized in that, include: A turntable, with a threaded object to be tested placed at the end of the turntable and rotated under the drive of the turntable; At least one camera is positioned around the end of the turntable to capture multi-angle images of the thread as the object under test rotates; A light source, used to emit parallel light that shines towards the end of the turntable; A processor and a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program, when executed by the processor, implements the thread detection method based on image recognition and deep learning as described in any one of claims 1-5.

7. A thread detection system based on image recognition and deep learning, characterized in that, include: The image acquisition and processing module is used to acquire thread images from multiple angles and filter thread images by combining image gradients and information entropy. The thread measurement module is used to measure the inner and outer diameters of the thread, the thread pitch, and the thread angle using image recognition methods based on the screened thread images. The defect detection module is used to detect whether there is damage or folding defects in the thread teeth, and whether there are crack defects in the thread as a whole. It uses a deep learning model that combines a classification network and a segmentation network to detect whether there are crack defects at the top, waist and bottom of the thread. The result judgment module is used to compare the measured inner and outer diameters of the thread, the thread pitch, and the thread angle with the standard specification values, and to judge whether the thread is qualified by combining the defect detection results of the thread teeth, the thread as a whole, and the top, waist, and bottom of the thread. The detection of whether the thread teeth are damaged or have folding defects specifically involves: Affine transformation is used to correct the thread image, performing contrast and gamma correction. Global threshold segmentation is used to extract the feature regions of the thread that meet the threshold range, and limit filtering is used to eliminate random interference in the feature regions. The thread target in the feature region is divided into multiple regions of different sizes by image erosion operation. If there is a tooth decay defect, the area of ​​the corresponding region is smaller than the normal area. If there is a folding defect in the depth or length direction, the area of ​​the corresponding region is larger than the normal area. The presence of tooth decay, folding defect in the depth or length direction of the thread is determined by the area size of the segmented regions. The detection of whether the overall thread has cracks or defects specifically involves: The thread image is corrected using affine transformation, and contrast and gamma corrections are performed on the thread image. Global threshold segmentation is used to obtain multiple feature regions of different area sizes that meet the threshold range for thread crack defects, and Gaussian filtering is used to eliminate noise in the feature regions. If a crack defect exists, the area of ​​the corresponding feature region is smaller than the area under normal conditions. Based on the area of ​​the feature region obtained after Gaussian filtering, the feature regions where the crack may be located are screened. The least squares method is used to fit the center of the screened feature regions with line segments. The presence of a crack defect is determined based on the total length of the line segments. The method of using a deep learning model combining a classification network and a segmentation network to detect whether there are crack defects at the top, waist, and bottom of the thread is as follows: The spiral image is segmented into top, waist, and bottom images, preprocessed, and then divided into training and testing sets respectively. A thread crack detection model is constructed, comprising a classification network and a segmentation network. The model is trained using training sets of top, waist, and bottom images, respectively. During training, the overall loss function is constructed by combining the segmentation and classification losses: , in, λ 1 and λ 2 is the preset parameter. W d To divide the loss, W f For classification loss; The thread crack detection model was trained by inputting test sets of top, waist, and bottom images respectively, and the detection results of whether there are crack defects at the top, waist, and bottom of the thread were obtained.

8. A thread inspection device based on image recognition and deep learning, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the thread detection method based on image recognition and deep learning as described in any one of claims 1-5.