Thread parameter measuring method based on machine vision

Through the thread parameter measurement method based on machine vision, improved image processing technology is used to calculate thread parameters, which solves the problems of low detection efficiency, low accuracy and poor adaptability in the existing technology, and achieves efficient, accurate and robust thread parameter measurement. .

CN119338884AInactive Publication Date: 2025-01-21HEBEI UNIV OF ENG

Patent Information

Application Number
CN202411504554.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-26
Publication Date
2025-01-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing thread parameter measurement methods have problems such as low detection efficiency, low accuracy, labor-intensive and susceptible to human factors. The existing machine vision-based methods have complex measurement processes, poor adaptability and slow calculation speed.

Method used

Using a thread parameter measurement method based on machine vision, the 7 main parameters and other parameters of the thread are calculated through image acquisition and improved image processing technology, including grayscale, preprocessing, edge detection and fitting.

Benefits of technology

It simplifies the thread parameter measurement process, improves detection speed and efficiency, enhances the adaptability and robustness of the measurement method, and avoids the influence of human factors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338884A_ABST
    Figure CN119338884A_ABST
Patent Text Reader

Abstract

The invention discloses a thread parameter measuring method based on machine vision. The thread parameter measuring method comprises the following steps: S1, acquiring an image of a thread workpiece to be measured; s2, graying and preprocessing the collected image of the to-be-detected thread workpiece to obtain thread edge image features; s3, the thread edge image features are processed, thread parameters are obtained through calculation, and the thread parameters comprise seven main parameters and other parameters. The method has the following advantages: (a) the calculation difficulty is low, and the speed is high; (b) the adaptability is high, and the robustness is high; (c) the detection process is simple, and the measurement precision is high; (d) the measurement range is wide, and measurement of more parameters can be realized; the problems of complex measurement process, few measurement parameters, tedious method, high difficulty, poor adaptability, low calculation speed and the like in the existing detection technology are solved. The method can be applied to occasions related to thread parameter measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of thread measurement, and in particular relates to a thread parameter measurement method based on machine vision. Background Art

[0002] As a common mechanical connection and transmission component, thread is widely used in machinery manufacturing, automobile, aerospace, chemical production, energy development and other fields. Accurate measurement of its parameters is crucial to ensure product quality and reliability. Thread parameters such as thread depth, pitch, outer diameter, etc. are key factors that determine the safety of related operations and production efficiency. The accuracy of thread parameters can affect the normal operation of mechanical equipment, or directly affect the safety of enterprise production. Therefore, high-precision and high-efficiency detection of thread parameters is of vital importance to improving production efficiency, ensuring product quality and promoting the development of the manufacturing industry.

[0003] At present, thread parameter measurement mainly relies on traditional contact measurement methods operated manually, such as using vernier calipers, thread micrometers, go / no-go gauges, etc. Although these traditional measurement methods are simple and fast, they have the disadvantages of low detection efficiency, low detection accuracy, labor consumption, and are easily affected by human factors. In recent years, with the continuous development of machine vision technology, thread measurement technology based on machine vision, including image acquisition and image processing, has been applied to production lines. However, these existing technologies still have certain shortcomings, such as complex measurement process, cumbersome and difficult measurement methods, slow calculation speed, and poor adaptability of measurement methods. Most of the developed thread parameter measurement methods are only for a certain type or a specific model of thread. When changing to another thread or the central axis of the collected thread image to be measured is not completely parallel to the coordinate axis of the image coordinate system, the detection accuracy will be greatly reduced or the detection method will fail.

[0004] Therefore, in order to solve the problems existing in the existing measurement methods, the present invention proposes a thread parameter measurement method based on machine vision. Summary of the invention

[0005] In view of the problems existing in the above-mentioned prior art, the purpose of the present invention is to provide a thread parameter measurement method based on machine vision, which aims to simplify the thread parameter measurement process, realize the measurement of more parameters, improve the adaptability of the measurement method and the robustness of thread detection, and improve the detection speed and efficiency while ensuring accuracy.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] A first aspect of the present invention provides a thread parameter measurement method based on machine vision, comprising the following steps:

[0008] S1, collecting images of the threaded workpiece to be measured;

[0009] S2, graying and preprocessing the collected image of the threaded workpiece to be tested to obtain thread edge image features;

[0010] S3, processing the thread edge image features, calculating and obtaining the thread parameters, wherein the thread parameters include 7 main parameters and other parameters, the 7 main parameters include "middle diameter d2", "major diameter d", "minor diameter d1", "pitch P", "lead S", "thread lead angle "," tooth angle α"; other parameters include "theoretical depth", "actual depth", "top truncation", "root truncation", "axial thickness", etc.

[0011] Preferably, in step S2, graying and preprocessing the collected image of the threaded workpiece to be measured specifically includes the following steps:

[0012] S2.1, graying the collected image of the thread to be measured to obtain a gray image of the threaded workpiece to be measured, and then determining a bilateral threshold according to a histogram feature of the gray image of the threaded workpiece;

[0013] S2.2, respectively determine the thresholds for the intervals where the pixel value of the threaded workpiece is less than 30 and the intervals where the pixel value of the threaded workpiece is greater than 140: wherein, for the interval where the pixel value of the threaded workpiece is less than 30, the average value of the maximum pixel value and the minimum pixel value is used as the minimum threshold; for the interval where the pixel value of the threaded workpiece is greater than 140, the number of pixels with a pixel value greater than 140 is calculated and the median threshold is taken as the maximum threshold;

[0014] S2.3, performing Gaussian filtering on the interval between the minimum threshold and the maximum threshold in step S2.2;

[0015] S2.4. Use the Canny operator to perform edge detection and obtain accurate thread edge image features based on sub-pixel extraction.

[0016] Preferably, in step S3, the processing of thread edge image features includes: S3.1, extraction of crest points and trough points; S3.2, arrangement and classification of edge pixels; S3.3, fitting of crests, troughs and initial mid-diameter lines; S3.4, acquisition of the optimal upper contour midline and the optimal lower contour midline based on a voting algorithm; S3.5, fitting of the thread tooth side contour line.

[0017] Preferably, the extraction of crest points and trough points in step S3.1 comprises the following steps: performing salient point detection on each contour through approximate contour; crests are usually points with larger local gradient values ​​in the gradient image, and troughs are usually points with smaller local gradient values ​​in the gradient image, and based on this characteristic, on the basis of the approximate contour salient point detection, pseudo crest points and pseudo trough points are screened out based on the change of local gradient, and the crest points and trough points of the thread to be tested are accurately extracted and marked.

[0018] Preferably, the arrangement and classification of edge pixels in step S3.2 comprises the following steps:

[0019] S321, dividing the thread edge into upper and lower contours through the central axis of the thread, and storing the coordinates of the pixel points on the upper and lower contour edges of the thread in an array respectively;

[0020] S322, find the pixel with the smallest horizontal coordinate in each of the two arrays in step S321, calculate the distances between the remaining pixels in the two arrays and the pixel with the smallest horizontal coordinate in the array, and arrange all the pixels in the two arrays in order of distance from small to large;

[0021] S323, classify the extracted peak points and trough points into upper contour peak points, upper contour trough points, lower contour peak points, and lower contour trough points, and save each into an array to obtain four arrays, in which all pixels are arranged in ascending order of the horizontal coordinate.

[0022] Preferably, the step S3.3 of fitting the peak, the trough and the initial median diameter line comprises the following steps:

[0023] S331, traverse all arranged pixels in the four arrays of upper contour peak points, upper contour trough points, lower contour peak points, and lower contour trough points respectively;

[0024] S332, respectively find the vertical coordinate value that appears most frequently in each array and record it as Mode(Y), and based on this value-taking method, compare the average value μY of the vertical coordinates of the remaining pixels in each group of the four arrays with the vertical coordinate Mode(Y) that appears most frequently in each group to verify the rationality of the value;

[0025] S333, extract all pixel points whose ordinate values ​​are the same as Mode (Y) in each array, connect the extracted pixel points with a straight line, and obtain the upper contour crest line, upper contour trough line, lower contour crest line, and lower contour trough line of the thread;

[0026] S334, by calculating the average value of the ordinate value that appears most times in the upper contour wave peak point array and the average value of the ordinate value that appears most times in the upper contour wave valley point array, a straight line is drawn through the average value, which is the initial upper contour midline, and the initial lower contour midline is obtained similarly, and then six straight lines are obtained on the image, namely, the upper contour wave peak line, the upper contour wave valley line, the lower contour wave peak line, the lower contour wave valley line, the initial upper contour midline, and the initial lower contour midline;

[0027] Or when the acquired image is not parallel to the image coordinate system, by respectively calculating the difference ΔXi between the horizontal coordinates and the difference ΔYi between the vertical coordinates of the adjacent upper contour peak points arranged in step S3.2, and then calculating the average value of the horizontal coordinate difference The average value of the difference between the vertical axis and Finally, the angle of the acquired thread image to be measured deviating from the horizontal direction of the image coordinate system is calculated. By rotating the image by an angle of β, the above six straight lines can also be obtained.

[0028] Preferably, the step S3.4 of obtaining the optimal upper contour midline and the optimal lower contour midline based on the voting algorithm comprises the following steps:

[0029] S341, moving the initial upper contour midline between the upper contour crest line and the upper contour trough line by accumulating pixel translation scanning by one pixel at a time, and recording the candidate mid-diameter line generated by moving to each different position;

[0030] S342, by measuring the widths of the grooves and protrusions on the above series of candidate mid-diameter lines, i.e., the adjacent widths, each measured width is regarded as a "vote". If two adjacent widths on a line are equal, one vote is added to this line;

[0031] S343. Compare the measured adjacent widths on each candidate median diameter line with a threshold value that is equal to the set defined width, and count the number of votes obtained by each candidate median diameter line, so as to obtain the optimal upper contour median line and the optimal lower contour median line.

[0032] Preferably, the step S3.5 of fitting the thread flank contour line comprises the following steps:

[0033] S351, by traversing the arranged upper contour wave crest points, upper contour wave trough points, and upper contour edge points, according to the structural characteristics of the thread teeth and the detected edge image of the thread, it can be known that the wave crest points and wave trough points on the thread edge appear alternately, so all points on the thread edge between adjacent upper contour wave crest points and wave trough points are defined as an upper contour thread tooth side point set;

[0034] S352, by traversing the upper contour edge points, searching for all points on the thread edge between each pair of adjacent upper contour wave crest points and wave trough points, each upper contour thread flank point set and the pixel point coordinates contained therein can be obtained. Similarly, each lower contour thread flank point set and the pixel point coordinates contained therein can be obtained in this way;

[0035] S353, based on the obtained upper profile thread flank point set and the lower profile thread flank point set, a linear regression method is used to take each thread flank point set as input to calculate the slope and intercept of each best fitting line, while ensuring that each best fitting line passes through as many points in its corresponding flank point set as possible;

[0036] S354, respectively calculating the intersection points of adjacent fitting lines of the upper profile of the thread and the intersection points of adjacent fitting lines of the lower profile, that is, obtaining the real upper profile peak point, upper profile trough point, lower profile peak point, and lower profile trough point on the thread edge in theory, and drawing the intersection points of the fitted tooth side profile straight line and the adjacent straight lines on the image;

[0037] S355, respectively draw a straight line through the obtained true upper contour wave crest point, true upper contour wave trough point, true lower contour wave crest point, and true lower contour wave trough point, thereby obtaining the true upper contour wave crest line, true upper contour wave trough line, true lower contour wave crest line, and true lower contour wave trough line of the thread.

[0038] Preferably, the calculation to obtain 7 main thread parameters includes the following steps:

[0039] S356, by calculating the distance between the optimal upper contour midline and the optimal lower contour midline, the "mid diameter d2" value of the thread is obtained;

[0040] S357, obtaining the "major diameter d" value of the thread by calculating the distance between the upper contour wave crest line and the lower contour wave trough line;

[0041] S358, obtaining the "minor diameter d1" value of the thread by calculating the distance between the upper contour trough line and the lower contour crest line;

[0042] S359, obtaining the thread upper profile "pitch P" by calculating the average distance between the true upper profile wave crest points; obtaining the thread lower profile "pitch P" by calculating the average distance between the true lower profile wave trough points;

[0043] S360. If the thread to be measured is a single-thread thread, the lead S of the thread is numerically equal to the pitch P, that is, S=P; if the thread to be measured is a multi-thread thread, the lead S of the thread is equal to the number of threads n multiplied by the pitch P, that is, S=nP;

[0044] S361, calculate the thread lead angle by the following formula

[0045]

[0046] Where d2 is the thread pitch diameter and S is the lead;

[0047] S362, calculating the angle between adjacent fitting lines of the upper thread profile to obtain the "tooth angle α" of the upper thread teeth; similarly, calculating the angle between adjacent fitting lines of the lower thread profile to obtain the "tooth angle α" of the lower thread teeth.

[0048] Preferably, the calculation to obtain other parameters of the thread, including the original triangle height of the thread, i.e., "theoretical depth", "top cutoff", "root cutoff", "axial thickness", and "actual depth", comprises the following steps:

[0049] S363, by calculating the distance between the two straight lines of the true upper contour wave crest line and the true upper contour wave trough line, the original triangle height of the thread, i.e., the “theoretical depth”, is obtained;

[0050] S364, obtaining the “top truncation” of the thread by calculating the distance between the upper contour wave crest line and the actual upper contour wave crest line of the theoretical thread;

[0051] S365, obtaining the "root cutoff" of the thread by calculating the distance between the upper profile trough line and the actual upper profile trough line of the thread in theory;

[0052] S366, by extracting the intersection points of the optimal median diameter obtained in step S3.4 and the thread edge, and calculating the average distance between adjacent intersection points, the "axial thickness" of the thread is obtained;

[0053] S367. The “actual depth” of the thread is obtained by calculating the distance between the upper contour wave crest line and the upper contour wave trough line.

[0054] The present invention has the following beneficial effects:

[0055] (1) In the present invention, the collected thread image to be measured is processed by an improved image processing method, which makes the proposed thread parameter measurement method have strong adaptability and detection robustness.

[0056] (2) Compared with the prior art (CN202110529419.6), the thread side contour line is determined by detecting the straight lines in the thread contour image, filtering out the redundant straight line segments, and screening out the straight line segments of the thread profile on both sides. The tooth side contour line fitting method proposed in the present invention first separates and extracts each tooth side point set, and uses linear regression to fit each tooth side contour straight line based on each tooth side point set, so that the fitted straight line segments of the thread profile on both sides are closer to the real edge than the prior art that uses straight line detection to screen the straight line segments of the thread profile on both sides, and at the same time avoids the situation in which the prior art cannot detect the straight line due to manufacturing burrs, oil stains, etc.

[0057] (3) Compared with the prior art (CN201910282554.8), which proposes to determine the coordinates of the center point of the rotated image by translating the image, the translated thread image is scanned and the absolute value of the difference between the number of boundary points of black pixels and the number of boundary points of black pixels in the left and right adjacent rows is calculated row by row, and then the absolute value of the difference is calculated to rotate the image in relation to the threshold value. The present invention proposes to calculate the difference ΔYi between the ordinates and ΔXi between the abscissas of the arranged adjacent upper contour peak points, and then calculate the average value of the ordinate difference and the average value of the abscissa difference respectively, and finally calculate the inverse tangent of the ratio of the two values, which is the angle β of the measured thread image deviating from the horizontal direction of the image coordinate system, thereby realizing a simpler and faster calculation method to rotate the image to be parallel to the image coordinate system, and then perform subsequent parameter measurement.

[0058] (4) The present invention proposes a new method for measuring the mean diameter of a thread, which can accurately detect the mean diameter of the thread when the major diameter and pitch of the thread are unknown, thereby eliminating the labor required by traditional detection such as thread micrometer and three-needle method, and avoiding the influence of human factors on the detection results.

[0059] (5) The thread parameter measurement method proposed in the present invention can realize the measurement of 7 main parameters of the thread ("middle diameter d2", "major diameter d", "minor diameter d1", "pitch P", "lead S", "thread lead angle" The method can accurately detect the original triangle height of the thread, i.e., the theoretical depth, top cutoff, root cutoff, axial thickness, and actual depth, with the following advantages: (a) low calculation difficulty and high speed; (b) strong adaptability and high robustness; (c) simple detection process and high measurement accuracy; (d) wide measurement range, which can realize the measurement of more parameters. It solves the problems existing in the existing detection technology, such as complex measurement process, few measurement parameters, cumbersome and difficult methods, poor adaptability, and slow calculation speed. The method of the present invention can be applied to occasions involving thread parameter measurement, for example, detecting various parameters of manufactured threads in actual production, detecting whether threaded workpieces are qualified on factory assembly lines, and detecting defects of threaded workpieces in actual engineering applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0061] Figure 1 is the histogram of the grayscale image of the threaded workpiece to be tested;

[0062] Figure 2 This is the interval map where the pixel value of the workpiece is less than 30;

[0063] Figure 3 This is the interval diagram for workpiece pixel values ​​greater than 140;

[0064] Figure 4 It is a thread edge image feature map obtained based on sub-pixel extraction in Example 1;

[0065] Figure 5 The peak points and trough points of the thread to be tested extracted and marked in Example 1;

[0066] Figure 6 The images are six straight lines obtained in Example 1, namely, the upper contour crest line, the upper contour trough line, the lower contour crest line, the lower contour trough line, the initial upper contour center line, and the initial lower contour center line;

[0067] Figure 7 is an image of the intersection of the tooth side contour straight line and the adjacent straight line fitted in Example 1;

[0068] Figure 8 The images are the real upper profile crest line, the real upper profile trough line, the real lower profile crest line and the real lower profile trough line of the thread obtained in Example 1;

[0069] Fig. 9 A schematic flow chart of a thread parameter measurement method based on machine vision provided by the present invention. DETAILED DESCRIPTION

[0070] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system structures and technologies are provided to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may also be implemented in other embodiments without these specific details.

[0071] Meaning and explanation of terms:

[0072] Peak point: the top of the tooth;

[0073] Valley point: the bottom point of the tooth;

[0074] Crest line of the upper profile: the top line of the upper teeth of the thread;

[0075] Root line of the upper profile: the bottom line of the upper thread teeth;

[0076] Crest line of the lower profile: the top line of the lower thread teeth;

[0077] Root line of the lower profile: the bottom line of the lower thread teeth;

[0078] Real crest line of the upper profile: the straight line of the vertex of the original triangle of the upper thread tooth that is overfitted;

[0079] Real root line of the upper profile: the straight line of the vertex of the original triangle of the upper thread tooth that is overfitted;

[0080] Real crest line of the lower profile: the straight line of the vertex of the original triangle of the lower thread tooth that is overfitted;

[0081] Real root line of the lower profile: The straight line that is overfitted from the vertex of the original triangle of the lower thread.

[0082] Example 1

[0083] See also Figure 1-4 and Fig. 9 , a thread parameter measurement method based on machine vision, comprising the following steps:

[0084] S1. Use a CMOS camera with a telecentric lens to collect images of the threaded workpiece to be tested on the test bench;

[0085] S2, graying and preprocessing the collected image of the thread to be tested to eliminate the influence of burrs or oil stains on the threaded workpiece to be tested during manufacturing, and obtain the thread edge image features;

[0086] Since most of the time there is noise in the collected images of the threads to be measured, even if the noise is smoothed by image filtering, it cannot be completely removed, and the edges of the threads will still have more or less noise. In addition, when a different type of thread to be measured is replaced or the central axis of the collected image of the thread to be measured is not completely parallel to the coordinate axis of the image coordinate system, most measurement methods often have large detection errors, or even the algorithm directly fails. In view of this, the present invention improves and optimizes the image processing (i.e., graying and preprocessing) method to achieve accurate detection of thread parameters as long as the thread edge is continuous and the root and tooth positions are clearly visible in the thread edge image to be measured. This makes the thread parameter measurement method proposed in the present invention highly adaptable and robust. Specifically comprising the following steps:

[0087] S2.1, graying the collected image of the thread to be measured to obtain a gray image of the threaded workpiece to be measured, and then determining a bilateral threshold according to a histogram feature of the gray image of the threaded workpiece to be measured;

[0088] S2.2, respectively determine the thresholds for the intervals where the workpiece pixel value is less than 30 and the intervals where the workpiece pixel value is greater than 140: wherein, for the interval where the workpiece pixel value is less than 30, the average of the maximum pixel value and the minimum pixel value is used as the minimum threshold; for the interval where the workpiece pixel value is greater than 140, the number of pixels with pixel values ​​greater than 140 is calculated and taken as the median threshold as the maximum threshold;

[0089] S2.3, using an improved 5×5 two-dimensional Gaussian kernel to perform Gaussian filtering on the interval between the minimum threshold and the maximum threshold in S2.2;

[0090] S2.4. Use the Canny operator to perform edge detection on the image and extract accurate thread edge image features based on sub-pixel.

[0091] S3, process the thread edge image features, calculate and obtain various thread parameters, including 7 main parameters and other parameters. The 7 main parameters include "mid-diameter d2", "major diameter d", "minor diameter d1", "pitch P", "lead S", "thread lead angle ”, “tooth angle α”; other parameters include “theoretical depth”, “actual depth”, “top cutoff”, “root cutoff”, and “axial thickness”.

[0092] Process the thread edge image features, including:

[0093] S3.1. Extraction of peak and trough points:

[0094] Each contour is detected for convex points through approximate contour; since the peak is usually the point with larger local gradient value in the gradient image, and the trough is usually the point with smaller local gradient value in the gradient image, based on this characteristic, on the basis of approximate contour convex point detection, the pseudo peak points and pseudo trough points that do not belong to the real edge of the thread due to manufacturing burrs are screened out based on the change of local gradient, so as to accurately extract and mark the peak points and trough points of the thread to be tested, see Figure 5 ;

[0095] S3.2, Arrangement and classification of edge pixels:

[0096] S321, dividing the thread edge into upper and lower contours through the central axis of the thread, and storing the coordinates of the pixel points on the upper and lower contour edges of the thread in an array respectively;

[0097] S322, find the pixel with the smallest horizontal coordinate in each of the two arrays in step S321, calculate the distances between the remaining pixels in the two arrays and the pixel with the smallest horizontal coordinate in the array, and arrange all the pixels in the two arrays in order of distance from small to large;

[0098] S323, classifying the peak points and trough points extracted in step S3.1 into upper contour peak points, upper contour trough points, lower contour peak points, and lower contour trough points, and saving each into an array. Since the peak points and trough points have the same ordinate or a small difference in ordinate values, the pixels are arranged in the above four arrays in the order of the horizontal coordinate from small to large.

[0099] S3.3, crest, trough, and initial median diameter fitting:

[0100] S331, traverse all arranged pixels in the four arrays of upper contour peak points, upper contour trough points, lower contour peak points, and lower contour trough points in step S3.2 respectively;

[0101] S332, respectively find the ordinate value that appears most frequently in each array and record it as Mode(Y), and based on this value-taking method, compare the average value μY of the ordinates of the remaining pixels in each group of the four arrays with the ordinate Mode(Y) that appears most frequently in each group, and find that the two values ​​are the same or the difference is very small, which verifies the rationality of the above value-taking;

[0102] S333, extract all the pixel points whose ordinate value is the same as Mode (Y) in each array, and connect these pixel points with a straight line to obtain the upper profile crest line (Crest line of the upper profile), the upper profile trough line (Root line of the upper profile), the lower profile crest line (Crest line of the lower profile), and the lower profile trough line (Root line of the lower profile) of the thread;

[0103] S334. By calculating the average of the ordinate value that appears most frequently in the upper profile peak point array and the ordinate value that appears most frequently in the upper profile trough point array, a straight line is drawn through the average value, which is the initial upper profile midline (Mid line of upper profile). Similarly, the initial lower profile midline (Mid line of lower profile) can be obtained. Then, the above six straight lines (upper profile peak line, upper profile trough line, lower profile peak line, lower profile trough line, initial upper profile midline, initial lower profile midline) can be obtained on the image. Figure 6 ;

[0104] In addition, a problem that is often not considered in existing methods for measuring thread parameters is that the central axis of the collected thread image to be measured is not parallel to the coordinate axis of the image coordinate system. If this problem is not solved, it will be difficult to accurately obtain the above six straight lines, which will also cause great trouble for subsequent detection. However, the current image rotation algorithm is complex and difficult. In view of this, the present invention proposes a method for obtaining the above six straight lines: by respectively calculating the difference ΔXi between the horizontal coordinates and the difference ΔYi between the vertical coordinates of the adjacent upper contour peak points and lower contour trough points arranged in step S3.2, and then calculating the average value of the horizontal coordinate difference respectively. The average value of the difference between the vertical axis and Finally, the angle of the acquired thread image to be measured deviating from the horizontal direction of the image coordinate system is calculated. By rotating the image by an angle of β, the above six straight lines (upper contour crest line, upper contour trough line, lower contour crest line, lower contour trough line, initial upper contour center line, initial lower contour center line) are obtained to prepare for the subsequent measurement of various thread parameters.

[0105] S3.4, obtaining the optimal upper contour midline and the optimal lower contour midline based on the voting algorithm, and then measuring the thread median diameter, i.e., the median diameter d2;

[0106] The calculation formula of the thread diameter d2 in the prior art is:

[0107] d2=DP×0.6495

[0108] Where D represents the major diameter of the thread, P represents the pitch, and 0.6495 represents the coefficient value;

[0109] It can be seen from the above formula that in order to calculate the thread mean diameter, it is first necessary to obtain the thread major diameter and pitch value. In view of this, the method for measuring the mean diameter proposed in the present invention can accurately detect the thread mean diameter when the thread major diameter and pitch are unknown, eliminating the labor required for traditional detection such as thread micrometer, three-needle method, etc., and avoiding the influence of human factors on the detection results.

[0110] According to the definition of thread pitch diameter in the national standard, to measure the thread pitch diameter, it is necessary to find an imaginary cylinder that bisects the groove and protrusion on the thread profile. Specifically, the thread pitch diameter is the diameter of the imaginary cylinder where the width of the groove and protrusion on the thread profile in the axial section of the thread is equal. Based on the above definition, a new thread pitch diameter measurement method has been developed, which includes the following steps:

[0111] S341, moving the initial upper contour midline between the upper contour crest line and the upper contour trough line by accumulating pixel translation scanning by one pixel at a time, and recording the candidate mid-diameter line generated by moving to each different position;

[0112] S342. Apply the voting algorithm. Based on the core idea of ​​the voting algorithm, "determine the result based on the repeated occurrence", measure the widths of the grooves and protrusions on the above series of candidate mid-diameter lines, i.e., the adjacent widths. For each measured width, regard it as a "vote". If two adjacent widths on a line are equal, add one vote to this line.

[0113] S343, according to the measured adjacent width on each candidate mid-diameter line, the threshold value equal to the defined width is compared, and the number of votes obtained by each candidate mid-diameter line is counted, so as to obtain the optimal upper contour midline and the optimal lower contour midline; the "mid-diameter d2" value of the thread is obtained by calculating the distance between the two straight lines of the optimal upper contour midline and the optimal lower contour midline;

[0114] S3.5, Fitting of thread side profile:

[0115] When fitting the thread side profile straight line, the existing measurement method usually first determines the starting point and end point of each tooth side of the thread edge, and then makes the tooth side line based on the starting point and end point. However, in fact, each tooth side edge of the thread is not ideal. Due to the influence of burrs, oil stains, etc., the tooth side profile edge of the thread will have different degrees of depression and protrusion. In this case, if the tooth side profile straight line is fitted only by determining the starting point and end point of each tooth side, it will not be guaranteed that the fitted straight line is the closest to the actual tooth side edge, which will cause very large errors in the subsequent measurement of parameters such as thread pitch and theoretical depth.

[0116] To solve this problem, the present invention provides a thread flank profile fitting method, comprising the following steps:

[0117] S351, by traversing the upper contour wave crest points, upper contour wave trough points, and upper contour edge points that have been arranged in step S3.2, according to the structural characteristics of the thread teeth and the edge image of the detected thread, it can be known that the wave crest points and wave trough points on the thread edge appear alternately, so all points on the thread edge between adjacent upper contour wave crest points and wave trough points are defined as an upper contour thread tooth side point set (Upper contour tooth edge set);

[0118] S352, by traversing the upper contour edge points, searching for all points on the thread edge between each pair of adjacent upper contour wave crest points and wave trough points, each upper contour tooth edge set and the pixel coordinates contained therein can be obtained. Similarly, each lower contour tooth edge set and the pixel coordinates contained therein can be obtained in this way;

[0119] S353, based on the obtained upper profile thread flank point set and the lower profile thread flank point set, a linear regression method is used to take each thread flank point set as input to calculate the slope and intercept of each best fitting line;

[0120] S354, respectively calculate the intersection points of the adjacent fitting lines of the upper profile of the thread and the intersection points of the adjacent fitting lines of the lower profile, obtain the real upper profile peak point, upper profile trough point, lower profile peak point, and lower profile trough point on the theoretical thread edge, and draw the intersection points of the fitted tooth side profile straight line and the adjacent straight lines on the image (see Figure 7 );

[0121] S355. Draw a straight line through the obtained real upper profile peak point, real upper profile trough point, real lower profile peak point, and real lower profile trough point, respectively, so as to obtain the real upper profile peak line (Real crestline of the upper profile), real upper profile trough line (Real root line of the upperprofile), real lower profile peak line (Real crest line of the lower profile), and real lower profile trough line (Real root line of the lower profile), see Figure 8 .

[0122] Based on the image pixels, the thread parameters other than the thread median diameter d2 are calculated and the actual size of each parameter is obtained:

[0123] The "major diameter d" value of the thread is obtained by calculating the distance between the upper contour wave crest line and the lower contour wave trough line.

[0124] By calculating the distance between the upper contour trough line and the lower contour crest line, the "minor diameter d1" value of the thread is obtained;

[0125] The original triangle height of the thread, i.e. the "theoretical depth", is obtained by calculating the distance between the two straight lines of the true upper contour wave crest line and the true upper contour wave trough line;

[0126] By calculating the average distance between the peak points of the real upper profile, the thread upper profile "pitch P" is obtained;

[0127] By calculating the average distance between the trough points of the true lower profile, the thread lower profile "pitch P" is obtained;

[0128] Calculate the "lead S" of the thread: If the thread to be measured is a single-thread thread, the lead S of the thread is numerically equal to the pitch P, that is, S = P; if the thread to be measured is a multi-thread thread, the lead S is equal to the number of threads n multiplied by the pitch P, that is, S = nP;

[0129] Based on the thread pitch diameter and lead, the thread lead angle is calculated using the following formula

[0130]

[0131] Where d2 is the thread pitch diameter and S is the lead;

[0132] By calculating the angle between adjacent fitting lines of the upper thread profile, the "tooth angle" of the upper thread teeth is obtained; similarly, by calculating the angle between adjacent fitting lines of the lower thread profile, the "tooth angle" of the lower thread teeth is obtained;

[0133] The “top truncation” of the thread is obtained by calculating the distance between the crest line of the upper profile obtained in step S3.3 and the real crest line of the upper profile of the theoretical thread obtained in step S3.5;

[0134] The “root truncation” of the thread is obtained by calculating the distance between the root line of the upper profile obtained in step S3.3 and the real root line of the upper profile of the theoretical thread obtained in step S3.5;

[0135] The “axial thickness” of the thread is obtained by extracting the intersection points of the optimal median diameter obtained in step S3.4 and the thread edge and calculating the average distance between adjacent intersection points;

[0136] The “actual depth” of the thread is obtained by calculating the distance between the crest line of the upper profile and the root line of the upper profile obtained in step S3.3.

[0137] In summary, the method of the present invention can not only successfully detect the "middle diameter d2", "major diameter d", "minor diameter d1", "pitch P", "lead S", "thread lead angle ”, “tooth angle α”, and the original triangle height of the thread, namely “theoretical depth”, “actual depth”, “top truncation”, “root truncation”, “axial thickness” and other parameters can also be measured.

[0138] The present invention is not limited to the above-mentioned specific implementation modes. Various changes made by ordinary technicians in this field based on the above-mentioned concepts without creative work are all within the protection scope of the present invention.

Claims

1. A thread parameter measurement method based on machine vision, characterized in that: The following steps are involved: S1, collecting images of the threaded workpiece to be measured; S2, graying and preprocessing the collected image of the threaded workpiece to be tested to obtain thread edge image features; S3, process the thread edge image features, calculate and obtain the thread parameters, where the thread parameters include 7 main parameters and other parameters, the 7 main parameters include "middle diameter d2", "major diameter d", "minor diameter d1", "pitch P", "lead S", "thread lead angle ", "tooth angle α"; other parameters include "theoretical depth", "actual depth", "top truncation", "root truncation" and "axial thickness".

2. The thread parameter measurement method based on machine vision according to claim 1, characterized in that: In step S2, graying and preprocessing the collected image of the threaded workpiece to be tested specifically include the following steps: S2.1, graying the collected image of the thread to be measured to obtain a gray image of the threaded workpiece to be measured, and then determining a bilateral threshold according to a histogram feature of the gray image of the threaded workpiece; S2.2, respectively determine the thresholds for the intervals where the pixel value of the threaded workpiece is less than 30 and the intervals where the pixel value of the threaded workpiece is greater than 140: wherein, for the interval where the pixel value of the threaded workpiece is less than 30, the average value of the maximum pixel value and the minimum pixel value is used as the minimum threshold; for the interval where the pixel value of the threaded workpiece is greater than 140, the number of pixels with a pixel value greater than 140 is calculated and the median threshold is taken as the maximum threshold; S2.3, performing Gaussian filtering on the interval between the minimum threshold and the maximum threshold in step S2.2; S2.

4. Use the Canny operator to perform edge detection and obtain accurate thread edge image features based on sub-pixel extraction.

3. The thread parameter measurement method based on machine vision according to claim 1, characterized in that: In step S3, the thread edge image features are processed, including: S3.1, extraction of crest points and trough points; S3.2, arrangement and classification of edge pixels; S3.3, fitting of crests, troughs and initial mid-diameter lines; S3.4, acquisition of the optimal upper contour midline and the optimal lower contour midline based on a voting algorithm; S3.5, fitting of the thread tooth side contour line.

4. The thread parameter measurement method based on machine vision according to claim 3 is characterized in that: The extraction of wave crest points and wave trough points in step S3.1 comprises the following steps: performing salient point detection on each contour through approximate contour; wave crests are usually points with larger local gradient values ​​in the gradient image, and wave troughs are usually points with smaller local gradient values ​​in the gradient image, and based on this characteristic, on the basis of the approximate contour salient point detection, pseudo wave crest points and pseudo wave trough points are screened out based on the change of local gradient, and the wave crest points and wave trough points of the thread to be tested are accurately extracted and marked.

5. The thread parameter measurement method based on machine vision according to claim 4 is characterized in that: The arrangement and classification of edge pixels in step S3.2 includes the following steps: S321, dividing the thread edge into upper and lower contours through the central axis of the thread, and storing the coordinates of the pixel points on the upper and lower contour edges of the thread in an array respectively; S322, find the pixel with the smallest horizontal coordinate in each of the two arrays in step S321, calculate the distances between the remaining pixels in the two arrays and the pixel with the smallest horizontal coordinate in the array, and arrange all the pixels in the two arrays in order of distance from small to large; S323, classify the extracted peak points and trough points into upper contour peak points, upper contour trough points, lower contour peak points, and lower contour trough points, and save each into an array to obtain four arrays, in which all pixels are arranged in ascending order of the horizontal coordinate.

6. The thread parameter measurement method based on machine vision according to claim 5, characterized in that: The step S3.3 of fitting the peak, trough and initial median diameter line comprises the following steps: S331, traverse all arranged pixels in the four arrays of upper contour peak points, upper contour trough points, lower contour peak points, and lower contour trough points respectively; S332, respectively find the vertical coordinate value that appears most frequently in each array and record it as Mode(Y), and based on this value-taking method, compare the average value μY of the vertical coordinates of the remaining pixels in each group of the four arrays with the vertical coordinate Mode(Y) that appears most frequently in each group to verify the rationality of the value; S333, extract all pixel points whose ordinate values ​​are the same as Mode (Y) in each array, connect the extracted pixel points with a straight line, and obtain the upper contour crest line, upper contour trough line, lower contour crest line, and lower contour trough line of the thread; S334, by calculating the average value of the ordinate value that appears most times in the upper contour wave peak point array and the average value of the ordinate value that appears most times in the upper contour wave valley point array, a straight line is drawn through the average value, which is the initial upper contour midline, and the initial lower contour midline is obtained similarly, and then six straight lines are obtained on the image, namely, the upper contour wave peak line, the upper contour wave valley line, the lower contour wave peak line, the lower contour wave valley line, the initial upper contour midline, and the initial lower contour midline; Or when the acquired image is not parallel to the image coordinate system, by respectively calculating the difference ΔXi between the horizontal coordinates and the difference ΔYi between the vertical coordinates of the adjacent upper contour peak points arranged in step S3.2, and then calculating the average value of the horizontal coordinate difference The average value of the difference between the vertical axis and Finally, the angle of the acquired thread image to be measured deviating from the horizontal direction of the image coordinate system is calculated. By rotating the image by an angle of β, the above six straight lines can also be obtained.

7. The thread parameter measurement method based on machine vision according to claim 6, characterized in that: The step S3.4, based on the voting algorithm, obtains the optimal upper contour midline and the optimal lower contour midline, comprising the following steps: S341, moving the initial upper contour midline between the upper contour crest line and the upper contour trough line by accumulating pixel translation scanning by one pixel at a time, and recording the candidate mid-diameter line generated by moving to each different position; S342, measuring the widths of the grooves and protrusions on the series of candidate mid-diameter lines, i.e., the adjacent widths, and treating each measured width as a "vote". If two adjacent widths on a line are equal, one vote is added to the line. S343. Compare the measured adjacent widths on each candidate median diameter line with a threshold value that is equal to the set defined width, and count the number of votes obtained by each candidate median diameter line, so as to obtain the optimal upper contour median line and the optimal lower contour median line.

8. The thread parameter measurement method based on machine vision according to claim 7, characterized in that: The step S3.5 of fitting the thread flank contour line comprises the following steps: S351, by traversing the arranged upper contour wave crest points, upper contour wave trough points, and upper contour edge points, according to the structural characteristics of the thread teeth and the detected edge image of the thread, it can be known that the wave crest points and wave trough points on the thread edge appear alternately, so all points on the thread edge between adjacent upper contour wave crest points and wave trough points are defined as an upper contour thread tooth side point set; S352, by traversing the upper contour edge points and searching for all points on the thread edge between each pair of adjacent upper contour wave crest points and wave trough points, each upper contour thread flank point set and the pixel point coordinates contained therein can be obtained. Similarly, each lower contour thread flank point set and the pixel point coordinates contained therein can also be obtained in this way; S353, using a linear regression method based on the obtained upper profile thread flank point set and the lower profile thread flank point set, taking each thread flank point set as input to calculate the slope and intercept of each best fitting line, while ensuring that each best fitting line passes through as many points in its corresponding flank point set as possible; S354, respectively calculating the intersection points of adjacent fitting lines of the upper profile of the thread and the intersection points of adjacent fitting lines of the lower profile, that is, obtaining the real upper profile peak point, upper profile trough point, lower profile peak point, and lower profile trough point on the thread edge in theory, and drawing the intersection points of the fitted tooth side profile straight line and the adjacent straight lines on the image; S355, respectively draw a straight line through the obtained true upper contour wave crest point, true upper contour wave trough point, true lower contour wave crest point, and true lower contour wave trough point, thereby obtaining the true upper contour wave crest line, true upper contour wave trough line, true lower contour wave crest line, and true lower contour wave trough line of the thread.

9. The thread parameter measurement method based on machine vision according to claim 8, characterized in that: The calculation to obtain 7 main thread parameters includes the following steps: S356, by calculating the distance between the optimal upper contour midline and the optimal lower contour midline, the "mid diameter d2" value of the thread is obtained; S357, by calculating the distance between the upper contour wave crest line and the lower contour wave trough line, the "major diameter d" value of the thread is obtained; S358, by calculating the distance between the upper contour trough line and the lower contour crest line, the "minor diameter d1" value of the thread is obtained; S359, obtaining the thread upper profile "pitch P" by calculating the average distance between the true upper profile wave crest points; obtaining the thread lower profile "pitch P" by calculating the average distance between the true lower profile wave trough points; S360. If the thread to be measured is a single-thread thread, the lead S of the thread is numerically equal to the pitch P, that is, S=P; if the thread to be measured is a multi-thread thread, the lead S of the thread is equal to the number of threads n multiplied by the pitch P, that is, S=nP; S361, calculate the thread lead angle by the following formula Where d2 is the pitch diameter of the thread and S is the lead; S362, calculating the angle between adjacent fitting lines of the upper thread profile to obtain the "tooth angle α" of the upper thread teeth; calculating the angle between adjacent fitting lines of the lower thread profile to obtain the "tooth angle α" of the lower thread teeth.

10. The thread parameter measurement method based on machine vision according to claim 9, characterized in that: The calculation to obtain other parameters of the thread, including the original triangle height of the thread, i.e., "theoretical depth", "top cutoff", "root cutoff", "axial thickness", and "actual depth", includes the following steps: S363, by calculating the distance between the two straight lines of the true upper contour wave crest line and the true upper contour wave trough line, the original triangle height of the thread, i.e., the "theoretical depth" is obtained; S364, obtaining the "top truncation" of the thread by calculating the distance between the upper contour wave crest line and the actual upper contour wave crest line of the theoretical thread; S365, obtaining the "root cutoff" of the thread by calculating the distance between the upper profile trough line and the actual upper profile trough line of the thread in theory; S366, by extracting the intersection points of the optimal median diameter obtained in step S3.4 and the thread edge, and calculating the average distance between adjacent intersection points, the "axial thickness" of the thread is obtained; S367. The "actual depth" of the thread is obtained by calculating the distance between the upper contour crest line and the upper contour trough line.

Citation Information

Patent Citations

  • Image rotation method for machine vision thread parameter measurement

    CN110211047A

  • Thread parameter measurement method and system based on three-dimensional contour

    CN113310426A

  • An online visual method for thread key size parameters under a motion background

    CN109785338A

Cited By

  • Machining method for natural gas pipeline threaded connector

    CN119624944A

  • A processing method for threaded joint of natural gas pipeline

    CN119624944B

  • High-precision measurement method for small-size thread parameters

    CN120375001A

  • Thread taper simulation measurement method based on machine vision

    CN120876381A

  • Thread taper simulation measurement method based on machine vision

    CN120876381B