Machine vision-based round thread size measuring method and measuring system
Through multi-field image stitching and sub-pixel edge detection, the problem of cumulative error in multi-field coordinated measurement is solved, and high-precision measurement of circular thread parameters is realized, which improves the robustness and adaptability of measurement.
Patent Information
- Application Number
- CN202510434496.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-04-08
AI Technical Summary
The cumulative error problem caused by the splicing of different amplitudes of existing multi-field coordinated measurements leads to the attenuation of the accuracy of long-range parameters.
By obtaining multi-field image patterns, correcting the contour points of each image pattern to subpixels, constructing thread profile feature points based on equilateral triangles, optimizing the splicing of the graph pattern using the least squares method, and calculating the standard deviation of the tooth type parameter to determine whether the thread size is abnormal.
It achieves complete coverage of the full thread profile, improves measurement accuracy and reliability, reduces errors caused by geometric mismatch and viewing angle deviation, and ensures the safety and durability of circular thread connections.
Smart Images

Figure CN120274635A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of thread measurement, and in particular, to a method and system for calculating the dimensional parameters of circular threads based on machine vision. Background Art
[0002] As a widely used connection form in mechanical structures in industry, the design and manufacture of circular threads must strictly follow industry standards to ensure the sealing performance, mechanical strength and durability of the connection between different components, so as to ensure the safe operation and long-term use of industrial facilities under complex working conditions. Precision measurement of the geometric parameters of circular threads is the key to ensuring their performance, safety and reliability. Parameter deviation may lead to connection failure, and consequences such as leakage and fracture caused thereby will result in huge economic losses. Although non-contact measurement technology has been widely used in thread measurement due to its high efficiency and non-destructive characteristics, when the thread length of circular threads is long, due to the limitations of the camera field of view and the CMOS target surface size, a single image frame often cannot completely cover the entire thread profile. Therefore, based on the multi-field-of-view collaborative measurement strategy, multiple local images are collected and high-precision stitching is performed to achieve full tooth profile coverage. The comprehensive analysis of key thread parameters (such as taper, pitch, tooth profile change and minimum effective connection length) is realized, revealing potential defects during the manufacturing or use process. However, there are problems such as geometric mismatch and perspective deviation between multi-field-of-view image frames. If the stitching accuracy is insufficient, the error will be amplified, thus affecting the final measurement accuracy. Therefore, sub-pixel registration of multi-field-of-view different image frame data overcomes the limitations of single-field-of-view measurement. While improving the overall measurement accuracy, it not only reflects the thread processing error of the thread during the production process, but also provides reliable data for effectively capturing the progressive wear and stress concentration phenomena in the thread engagement area, which has important theoretical significance and practical application value.
[0003] Bai Xiaoliang et al. [1] used the Harris operator to construct an autocorrelation matrix at each pixel of the image to calculate and extract the corner points of the external thread. However, since the extraction result only has pixel-level accuracy and requires a large amount of calculation in high-resolution images, resulting in insufficient real-time performance, it relies on the sub-pixel contour points collected originally for further refinement. Niu Sentao et al. [2] obtained the sub-pixel edge of the thread image by quadratic curve fitting based on the pixel-level edge extracted by the canny algorithm, then fitted it with a cubic spline curve, and detected the corner points according to the curvature of the fitted curve. However, the selection of the curvature threshold and the spline fitting parameters in their method need to be carefully adjusted according to the specific image characteristics. Jiang Tao et al. [3] improved the canny operator using bilateral filtering and iterative thresholding method, combined with the double-threshold DP algorithm and Hough transform to segment and fit the contour, and finally used the CTAR algorithm to extract the corner points of the thread crest and root. Although the accuracy of this method has been improved, the overall process is relatively complex and the operation efficiency still needs to be improved. Generally speaking, the current research methods generally have problems such as insufficient real-time performance, low adaptability, and failure to fully reflect in the stitching process of different image frames, providing an improvement direction for subsequent consideration of real-time performance and generality while improving the corner point extraction accuracy.
[0004] References
[0005] [1] Bai Xiaoliang, Yan Hong, Liu Qing, et al. Development of a fully automatic measurement system for external threads of oil pipes [J]. Petroleum Tubular Goods & Instruments, 2020, 6(03): 6 - 10.
[0006] [2] Niu Sentao, Zhao Fengxia, Jiang Feifei, et al. An on-line inspection method for threads based on machine vision [J]. Machine Design and Research, 2021, 37(06): 170 - 173 + 183.
[0007] [3] Jiang Tao, Li Yuan, He Chenlong. A vision measurement method for key parameters of threads based on contour corner point detection [J]. Journal of Electronic Measurement and Instrumentation, 2022, 36(07): 54 - 61. Summary of the Invention
[0008] The technical problem to be solved by the present invention is aimed at the problem of the cumulative error caused by the stitching of different image frames in the existing multi-field cooperative measurement during the measurement of visual thread parameters, resulting in the attenuation of the accuracy of long-range parameters.
[0009] The present invention solves the above technical problems through the following technical means:
[0010] A method for measuring the size of circular threads based on machine vision, including:
[0011] S1. Obtain multi-field image frames, and adjacent image frames have overlapping regions;
[0012] S2. Correct the contour points of each map sheet to sub-pixels;
[0013] S3. Extraction of thread contour feature points based on equilateral triangles: Sort the obtained corrected sub-pixel contour points according to the thread contour direction. Along the contour traversal direction, construct equilateral triangles with the Euclidean distance between adjacent two sub-pixel points, and calculate the included angle θ between adjacent two equilateral triangles i , if θ i is greater than the preset threshold θ t , it is judged as the corresponding feature point;
[0014] S4. Stitch the map sheets guided by the feature points;
[0015] S5. Based on the stitched map sheets, calculate the simulated height and the measured height of the tooth profile respectively, calculate the standard deviation of the tooth profile parameters based on the simulated height and the measured height, and then judge whether the thread size is abnormal according to the standard deviation of the tooth profile parameters.
[0016] Further, the specific process of step S1 is as follows: Drive the monocular camera along the thread axis by an equidistant stepping motion through a translation stage, and obtain a sequence of images of adjacent fields of view through a time-triggered image acquisition method; among them, the map sheet F A and F B form a complementary field of view in the thread axis direction. The width and height of the map sheet are w and h respectively. To ensure that there is enough overlapping area between adjacent map sheets to completely cover the thread, the axial stepping distance L satisfies:
[0017] L < min(w, h)
[0018] To avoid misalignment or breakage in the stitching between different map sheets due to errors, it is required that the forward motion error ε be controlled within half of the pitch p, that is:
[0019] ε < 0.5 * p.
[0020] Further, step S2 is specifically as follows: For different map sheets of the thread, first use the canny operator to perform edge detection at the pixel level on the binarized map sheet to extract the thread contour:
[0021] C = {(x i , y i ) | i = 1, 2,... n}
[0022] where (x i , y idenotes the coordinates of the i-th contour point, and n is the total number of sampled points on the contour edge; the neighborhood information of the edge is obtained by using the first-order gradient and second-order gradient of the contour edge C. In order to provide an unbiased and high-precision numerical approximation for the differentiation of discrete pixels, a 7-tap interpolator and its differential kernel proposed by Farid and Simoncelli are used during gradient calculation to calculate the first-order gradients g x and g y in the x and y directions of the contour edge, and the second-order gradients g xx , g yy , g xy ; finally, Steger's unbiased curve structure detection is adopted to eliminate the systematic deviation caused by discrete sampling. The first-order and second-order derivatives of the neighborhood of the edge c i (x i , y i ) are used to construct the Hessian matrix:
[0023]
[0024] By performing singular value decomposition on H i , the eigenvector corresponding to the largest eigenvalue is selected This vector represents the unit vector along the direction perpendicular to the edge; calculate the correction amount t i in the normal direction of the contour edge c i as:
[0025]
[0026] Update the position of the edge contour pixel c i to obtain the sub-pixel coordinates:
[0027]
[0028] Furthermore, the specific steps of step S3 are as follows: First, sort the obtained corrected sub-pixel contour points according to the contour direction of the thread. c i ∈C {i = 1, 2, … n} are sub-pixel edge points. Along the contour traversal direction, equilateral triangles are constructed with two adjacent sub-pixel edge points. v i and v i+1 are the vertices of two adjacent equilateral triangles respectively. v i is obtained by rotating c i around c i+1 by an angle α, and the rotation matrix is expressed as:
[0029]
[0030] where α is the rotation angle; the coordinates of v i+1 can be calculated in the same way; the included angle θ between two adjacent equilateral trianglesi It can be calculated by the following formula:
[0031]
[0032] Then, compare θ1 with the preset threshold θ t If it is greater than θ t , it is determined as the corresponding feature point; traverse the entire contour in this order.
[0033] Furthermore, the specific steps of step S4 are as follows: Assume two image frames F A and F B , and there is a known fixed moving distance L between them. The set of feature points F A ={f A1 , f A2 , …, f An} and F B ={f B1 , f B2 , …, f Bn} extracted from the two image frames, where f Ai =(x Ai , y Ai ), f Bi =(x Bi , y Bi ) represent the coordinates of the feature points in the image frames F A and F B respectively;
[0034] First, translate the image frame F B by the given moving distance L:
[0035] B′ = B + L
[0036] For the feature point f B =(x Bi , y Bi ) in F Bi , translate it by the fixed moving distance:
[0037] (x B′ , y B′ )=(x B +L, y B +L)
[0038] Through the preliminarily translated image frame F B , calculate the matching error between the feature points and further optimize the position using the least squares method; represent the transformation matrix T as a two-dimensional affine transformation matrix:
[0039]
[0040] Among them, a11 , a 12 , a 21 , a 22 are the coefficients of the affine transformation, and t x and t y are the translation amounts; the translation amount t x and t y are for adjusting the map sheet F after the preliminary translation; the cost function E(T) represents the sum of the squares of the coordinate errors between the feature points of the map sheet F B and the corresponding feature points in the map sheet F B : A Among them, (x
[0041]
[0042] , y B′i ) are the coordinates of the translated feature points. By minimizing the cost function, the transformation matrix T is optimized to better align the feature points in the map sheet F B′i with the feature points in the map sheet F B ; to minimize the cost function, the least squares method is used to obtain the optimal transformation matrix T; the map sheet F A will be accurately aligned with the map sheet F B according to the transformation matrix optimized by the preliminary translation and the least squares method, realizing the splicing of the map sheets. A
[0043] Furthermore, the specific step S5 is as follows: after completing the spatial splicing of multi-map sheet data, the least squares method is used to parametrically model the tooth profile feature point set, and the best-fit straight line equations for the two sides of l3 and l4 are respectively established as:
[0044]
[0045] Among them, A1, B1, C1 are the parameters of the l3 straight line, and A2, B2, C2 are the parameters of the l4 straight line; assuming the center coordinate of the sphere is the perpendicular distance from c2 to l3 and l4 is expressed as:
[0046]
[0047] According to the above formula, the coordinate can be obtained, and then the actual measured height h of the tooth profile can be obtained. Then, by constructing the thread axial distribution function:
[0048]
[0049] In the above formula, h k represents the actual measured height value at the k-th sampling position, is the theoretical nominal value. For the spatial domain analysis of the tooth profile parameters, by calculating the standard deviation of the tooth profile parameters:
[0050]
[0051] It can quantitatively evaluate the discreteness of thread machining quality, effectively identify the gradual errors caused by tool wear or clamping deformation during the thread manufacturing process, and provide a quantitative basis for process optimization.
[0052] The present invention also provides a round thread size measurement system based on machine vision, including:
[0053] Image acquisition module: acquiring multi-field images, with adjacent images having overlapping areas;
[0054] Correction module: correcting the contour points of each image to sub-pixels;
[0055] Thread contour feature point extraction module: sorting the obtained corrected sub-pixel contour points according to the contour direction of the thread, constructing equilateral triangles with the Euclidean distance between adjacent two sub-pixel points along the contour traversal direction, and calculating the included angle θ between adjacent two equilateral triangles i , if θ i is greater than the preset threshold θ t , it is determined as the corresponding feature point;
[0056] Mosaic module: mosaicking the images guided by the feature points;
[0057] Model fitting module: respectively calculating the simulated height and the measured height of the tooth profile based on the mosaicked images, calculating the standard deviation of the tooth profile parameters based on the simulated height and the measured height, and then judging whether the thread size is abnormal according to the standard deviation of the tooth profile parameters.
[0058] Furthermore, the correction module is specifically: for different thread images, first using the canny operator to perform edge detection at the pixel level on the binarized image to extract the thread contour:
[0059] C = {(x i , y i ) | i = 1, 2,... n}
[0060] where (x i , y i ) represents the coordinate of the i-th contour point, and n is the total number of contour edge sampling points; obtaining the neighborhood information of the edge by using the first-order gradient and the second-order gradient of the contour edge C. In order to provide an unbiased and high-precision numerical approximation for the differentiation of discrete pixels, the 7-tap interpolator and its differential kernel proposed by Farid and Simoncelli are used during gradient calculation, and the first-order gradients g x , g y and the second-order gradients g xx , gyy , g xy ; Finally, the Steger unbiased curve structure detection is adopted to eliminate the systematic deviation caused by discrete sampling, and the edge c i (x i , y i ) The first-order and second-order derivatives in the neighborhood are used to construct the Hessian matrix:
[0061]
[0062] By performing singular value decomposition on H i , the eigenvector corresponding to the largest eigenvalue is selected This vector represents the unit vector along the direction perpendicular to the edge; Calculate the correction amount t i of the contour edge c i along the normal direction as:
[0063]
[0064] Update the position of the edge contour pixel c i to obtain the sub-pixel coordinates:
[0065]
[0066] Furthermore, the thread contour feature point extraction module is specifically: First, sort the obtained corrected sub-pixel contour points according to the contour direction of the thread, c i ∈C{i = 1, 2, …n} is the sub-pixel edge point. Along the contour traversal direction, equilateral triangles are constructed with two adjacent sub-pixel edge points, v i and v i+1 are the vertices of two adjacent equilateral triangles respectively. v i is obtained by rotating c i around c i+1 by an α angle, and the rotation matrix is expressed as:
[0067]
[0068] where α is the rotation angle; The v i+1 coordinates can be calculated in the same way; The angle θ i between two adjacent equilateral triangles can be calculated by the following formula:
[0069]
[0070] Then, compare θ1 with the preset threshold θ t . If it is greater than θ t , it is judged as the corresponding feature point; Traverse the entire contour in this order.
[0071] Furthermore, the splicing module is specifically as follows: Assuming two images F A With F B , and there is a known fixed moving distance L between them. The feature point set F extracted from the two images A ={f A1 ,f A2 ,…,f An} and F B ={f B1 ,f B2 ,…,f Bn}, where f Ai =(x Ai ,y Ai ), f Bi =(x Bi ,y Bi ) represent the image size F A and map size F B The coordinates of the feature points in ;
[0072] First, according to the given moving distance L, the image frame F B To pan:
[0073] B′=B+L
[0074] For F B The feature point f in Bi =(x Bi ,y Bi )Translate by a fixed moving distance:
[0075] (x B′ ,y B′ )=(x B +L,y B +L)
[0076] After the initial translation, the image F B , calculate the matching error between feature points, and use the least squares method to further optimize the position; express the transformation matrix T as a two-dimensional affine transformation matrix:
[0077]
[0078] Among them, a 11 ,a 12 ,a 21 ,a 22 are the coefficients of the affine transformation, t x and t y is the translation; the translation t x and t y It is for the image after the initial translation F B Adjustment; the cost function E(T) represents the image size FB The sum of the squares of the coordinate errors between the feature points and the corresponding feature points in the map sheet F A :
[0079]
[0080] where (x B′i , y B′i ) are the coordinates of the feature points after translation. By minimizing the cost function, the transformation matrix T is optimized to better align the feature points in the map sheet F B with the feature points in the map sheet F A ; To minimize the cost function, the least squares method is used to obtain the optimal transformation matrix T; The map sheet F B will be precisely aligned with the map sheet F A according to the transformation matrix optimized by the preliminary translation and the least squares method, realizing the splicing of the map sheets;
[0081] Specifically, the model fitting module is as follows: After completing the spatial splicing of multi-map sheet data, the least squares method is used to parametrically model the tooth profile feature point set, and the best-fit straight line equations for the two sides of l3 and l4 are respectively established as:
[0082]
[0083] where A1, B1, C1 are the parameters of the l3 straight line, and A2, B2, C2 are the parameters of the l4 straight line; Assuming the center coordinate of the sphere is The perpendicular distance from c2 to l3 and l4 is expressed as:
[0084]
[0085] The coordinates can be obtained according to the above formula Furthermore, the actual measured height h of the tooth profile can be obtained, and then by constructing the thread axial distribution function:
[0086]
[0087] In the above formula, h k represents the actual measured height value at the kth sampling position, is the theoretical nominal value. For the spatial domain analysis of the tooth profile parameters, by calculating the standard deviation of the tooth profile parameters:
[0088]
[0089] The discreteness degree of the thread machining quality can be quantitatively evaluated, and the gradual error caused by tool wear or clamping deformation during the thread manufacturing process can be effectively identified, providing a quantitative basis for process optimization.
[0090] The advantages of the present invention are:
[0091] The present invention firstly achieves complete coverage of the entire thread profile by collecting multiple local images, thereby overcoming the limitation that a single field of view is difficult to capture the entire thread; secondly, the contour of each image is extracted through sub-pixel edge detection, and the characteristic points in each image are deeply analyzed. Subsequently, a splicing model based on feature constraints is established to achieve precise alignment and global optimization of data from different fields of view, reduce the error amplification effect caused by geometric mismatch and viewing angle deviation, and achieve nonlinear error suppression of parameter accuracy within the measurement range. This method can perform a more comprehensive and accurate measurement of key parameters of circular threads (such as taper, pitch, tooth profile changes and minimum effective connection length). This method not only significantly improves the overall accuracy and reliability of thread measurement, but also provides a solid technical guarantee for the safety and durability of oil well pipeline connections, and has important reference value for research and application in related fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] Figure 1 is an implementation flow chart of the method in the embodiment of the present invention;
[0093] Figure 2 A schematic diagram of obtaining multi-field images in a method according to an embodiment of the present invention;
[0094] Figure 3 A schematic diagram of calculating thread feature points in a method according to an embodiment of the present invention;
[0095] Figure 4 Schematic diagram of measuring the height of a round thread profile in a method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0096] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0097] This embodiment discloses a method for measuring the size of a circular thread based on machine vision, the process is as follows: Figure 1 As shown, follow the steps below:
[0098] Step 1: Obtain multi-field-of-view images based on a monocular camera.
[0099] In order to meet the high-resolution requirements and ensure the complete acquisition of the thread projection two-dimensional image, a multi-image collaborative acquisition method (such as Figure 2as shown). The width and height of the image frame are w and h respectively. The monocular camera is driven by a translation stage to perform equidistant step motion along the thread axis, and a sequence of images of adjacent fields of view is obtained through a time-triggered image acquisition method. Among them, the image frame F A and F B form complementary fields of view in the thread axis direction. To ensure that there is enough overlapping area between adjacent image frames to completely cover the thread, the axial step distance L satisfies:
[0100] L < min(w, h)
[0101] To avoid misalignment or breakage in the stitching between different image frames due to errors, it is required that the forward motion error ε be controlled within half of the pitch p, that is:
[0102] ε < 0.5 * p
[0103] Step 2: Sub-pixel correction of the contour points of each image frame.
[0104] To accurately find the sub-pixel boundary of the thread, for different image frames of the thread. First, use the canny operator to perform edge detection at the pixel level on the binarized image frame to extract the thread contour:
[0105] C = {(x i , y i ) | i = 1, 2, … n}
[0106] where (x i , y i ) represents the coordinates of the i-th contour point, and n is the total number of contour edge sampling points. Then, use the first-order gradient and second-order gradient of the contour edge C to obtain the neighborhood information of the edge. To provide an unbiased and high-precision numerical approximation for the differentiation of discrete pixels, a 7-tap interpolator and its differential kernel proposed by Farid and Simoncelli are used during gradient calculation to calculate the first-order gradients g x , g y and the second-order gradients g xx , g yy g xy . Finally, use the Steger unbiased curve structure detection to eliminate the systematic deviation caused by discrete sampling, and use the first-order and second-order derivatives of the neighborhood of the edge c i (x i , y i ) to construct the Hessian matrix:
[0107]
[0108] By performing singular value decomposition on H i , select the eigenvector corresponding to the largest eigenvalue This vector represents a unit vector along the direction perpendicular to the edge. Calculate the contour edge c i The correction amount t along the normal direction i is:
[0109]
[0110] Update the edge contour pixel c i The position to obtain the sub-pixel coordinates:
[0111]
[0112] Step 3: Method for extracting feature points of thread contour based on equilateral triangle construction.
[0113] In order to extract the feature points of the thread contour and better realize the stitching between maps, first sort the obtained corrected sub-pixel contour points according to the contour direction of the thread. Figure 3 In c i ∈C{i = 1, 2, …n} is a sub-pixel edge point. Along the contour traversal direction, with the Euclidean distance between c1 and c2 Construct an equilateral triangle c1c2v1, with the Euclidean distance between c2 and c3 Construct an equilateral triangle c2c3v2, where v1 and v2 are the vertices of the triangles c1c2v1 and c2c3v2 respectively. v1 is regarded as obtained by rotating c1 around c2 by 60°, and the rotation matrix is expressed as:
[0114]
[0115] where α is the rotation angle. The coordinates of v2 can be calculated in the same way. The angle θ1 can be calculated by the following formula:
[0116]
[0117] Then, compare θ1 with the preset threshold θ t If θ1 is greater than θ t , then determine that this feature point is an accurate feature point. Traverse the entire contour in this order and judge whether each point is a feature point. The process of finding feature points is shown in Table 1. Figure 3 In, θ i is greater than θ t , judge as the corresponding feature point. The specific algorithm is shown in Table 1 below.
[0118] Table 1 Thread feature point extraction algorithm based on equilateral triangle
[0119]
[0120] Step 4: Map stitching guided by feature points.
[0121] When performing map sheet splicing, feature points are used for registration and the least squares method is used for optimization. Figure 2 There are two map sheets F A and F B , and there is a known fixed moving distance L between them. The sets of feature points F A ={f A1 , f A2 , …, f An} and F B ={f B1 , f B2 , …, f Bn} extracted from the two map sheets, where f Ai =(x Ai , y Ai ) and f Bi =(x Bi , y Bi ) represent the coordinates of the feature points in map sheet F A and map sheet F B respectively.
[0122] First, translate map sheet F B according to the given moving distance L:
[0123] B′ = B + L
[0124] For the feature point f B =(x Bi , y Bi ) in F Bi , translate it according to the fixed moving distance:
[0125] (x B′ , y B′ )=(x B +L, y B +L)
[0126] Calculate the matching error between the feature points through the preliminarily translated map sheet F B , and use the least squares method to further optimize the position. Represent the transformation matrix T as a two-dimensional affine transformation matrix:
[0127]
[0128] where a 11 , a 12 , a 21 , a 22 are the coefficients of the affine transformation, and t x and t y are the translation amounts. The translation amounts t x and t y are for the map sheet F after the preliminary translation.B which is adjusted. The cost function E(T) represents the coordinate error squared sum between the feature points of the drawing sheet F B and the corresponding feature points in the drawing sheet F A :
[0129]
[0130] where (x B′i , y B′i ) are the coordinates of the translated feature points. By minimizing the cost function, the transformation matrix T is optimized to better align the feature points in the drawing sheet F B with the feature points in the drawing sheet F A . To minimize the cost function, the least squares method is used to obtain the optimal transformation matrix T. The drawing sheet F B will be precisely aligned with the drawing sheet F A according to the transformation matrix optimized by the preliminary translation and the least squares method, realizing the splicing of the drawing sheets.
[0131] Step 5: Parameter measurement and calculation.
[0132] After completing the drawing sheet splicing in Step 4, in order to accurately capture the changing trend of the tooth profile height, based on the digital detection method of virtual measuring tools, a simulation height gauge is used to measure the tooth profile height parameters. As Figure 4 shown in the schematic diagram of the circular thread tooth profile height measurement principle, this method constructs a spherical virtual probe with a radius of r, making it contact the right contact surface and the left contact surface of adjacent thread profiles in space respectively. By solving the normal distance from the center of the sphere to the reference line b1_b3, the tooth profile height parameter h is deduced. After completing the spatial registration of multi-drawing sheet data (i.e., multi-drawing sheet splicing), the least squares method is used to parametrically model the tooth profile feature point set, and the best-fit straight line equations of the profiles on both sides of l3 and l4 in Figure 4 are respectively established as:
[0133]
[0134] where A1, B1, C1 are the parameters of the l3 straight line, and A2, B2, C2 are the parameters of the l4 straight line. Assuming the center of the sphere coordinates are the perpendicular distances from c2 to l3 and l4 are expressed as:
[0135]
[0136] According to the above formula, the coordinates can be obtained, and then the measured tooth profile height h can be obtained. Further, based on the digital detection method of virtual measuring tools shown in Figure 4 , by constructing the thread axial distribution function:
[0137]
[0138] In the above formula, h k represents the measured height value at the k-th sampling position, is the theoretical nominal value. For the thread profile parameters, a spatial domain analysis is performed. By calculating the standard deviation of the thread profile parameters:
[0139]
[0140] the discreteness degree of the thread machining quality can be quantitatively evaluated, the gradual error caused by tool wear or clamping deformation during the thread manufacturing process can be effectively identified, and a quantitative basis for process optimization can be provided.
[0141] In this embodiment, a discrete local map of the thread is obtained from a multi-field image acquisition system. Sub-pixel edge detection is used to extract contour feature points, and a global registration model based on feature constraints is constructed. The discrete map is mapped to a unified global coordinate system to achieve seamless reconstruction of the full thread profile data. Thus, continuous acquisition of the full thread profile of the circular thread and accurate measurement of the thread height parameters are realized. While simplifying the difficulty of thread measurement, the measurement accuracy is improved, the errors caused by geometric mismatch and perspective deviation are reduced, and the robustness and adaptability of the vision solution in thread measurement are enhanced.
[0142] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for measuring the size of circular threads based on machine vision, characterized in that, Including: S1. Obtain multi-field images, where adjacent images have overlapping regions; S2. Correct the sub-pixels of the contour points of each image; S3. Extraction of characteristic points of thread profile based on equilateral triangles: Sort the obtained corrected sub-pixel contour points according to the contour direction of the thread. Along the contour traversal direction, construct equilateral triangles with the Euclidean distance between two adjacent sub-pixel points, and calculate the included angle θ between two adjacent equilateral triangles. i If θ i is greater than the preset threshold θ t , it is judged as the corresponding characteristic point; S4. Stitch the images guided by the feature points; S5. Based on the stitched images, calculate the simulated height and the measured height of the tooth profile respectively, calculate the standard deviation of the tooth profile parameters based on the simulated height and the measured height, and then judge whether the thread size is abnormal according to the standard deviation of the tooth profile parameters.
2. The method for measuring the size of round threads based on machine vision according to claim 1, wherein The specific process of the step S1 is as follows: the monocular camera is driven by a translation stage to perform equidistant step motion along the thread axis, and a sequence of images of adjacent fields of view is obtained through a time-triggered image acquisition method; among them, the image frame F A and F B form a complementary field of view in the thread axis direction. The width and height of the image frame are w and h respectively. To ensure that there is enough overlapping area between adjacent image frames so as to completely cover the thread, the axial step distance L satisfies: L < min(w, h) To avoid misalignment or breakage in the stitching between different images due to errors, it is required that the forward motion error ε be controlled within half of the pitch p, that is: ε < 0.5 * p.
3. The method for measuring the size of circular threads based on machine vision according to claim 1, characterized in that, The specific step S2 is as follows: For different images of the thread, first use the canny operator to perform edge detection at the pixel level on the binarized image to extract the thread contour: C = {(x i , y i ) | i = 1, 2, … n} where (x i , y i ) represents the coordinates of the i-th contour point, and n is the total number of sampling points on the contour edge; the neighborhood information of the edge is obtained by using the first-order gradient and second-order gradient of the contour edge C. In order to provide an unbiased and high-precision numerical approximation for the differentiation of discrete pixels, a 7-tap interpolator and its differential kernel proposed by Farid and Simoncelli are used during gradient calculation to calculate the first-order gradients g x and g y in the x and y directions of the contour edge, and the second-order gradients g xx , g yy , g xy ; finally, the Steger unbiased curve structure detection is used to eliminate the systematic deviation caused by discrete sampling, and the first-order and second-order derivatives of the neighborhood of the edge c i (x i , y i ) are used to construct the Hessian matrix: By performing singular value decomposition on H i and selecting the eigenvector corresponding to the largest eigenvalue This vector represents the unit vector along the direction perpendicular to the edge; calculate the contour edge c i The correction amount y along the normal direction i is as follows: Update the edge contour pixel c i The position gives sub-pixel coordinates:
4. The method for measuring the size of round threads based on machine vision according to claim 1, wherein The specific steps of step S3 are as follows: First, sort the obtained corrected sub-pixel contour points in the contour direction of the thread, c i ∈ C{i = 1, 2, … n} is a sub-pixel edge point. Along the contour traversal direction, an equilateral triangle is constructed with two adjacent sub-pixel edge points, v i and v i+1 are the vertices of two adjacent equilateral triangles respectively. v i is obtained by rotating c i by an angle of α around c i+1 The rotation matrix is expressed as: where α is the rotation angle; the same method can be used to calculate the i+1 coordinates; the included angle θ between two adjacent equilateral triangles i can be calculated by the following formula: Then, compare θ1 with the preset threshold θ t ; if it is greater than θ t , it is determined as the corresponding feature point; traverse the entire contour in this order according to this method.
5. The method for measuring the size of round threads based on machine vision according to claim 1, wherein The specific steps of step S4 are as follows: Assume two map sheets F A and F B , and there is a known fixed moving distance L between them. The set of feature points F A ={f A1 , f A2 , …, f An} and F B ={f B1 , f B2 , …, f Bn} extracted from the two map sheets, where f Ai =(x Ai , y Ai ), f Bi =(x Bi , y Bi ) respectively represent the coordinates of the feature points in map sheet F A and map sheet F B ; First, translate the map sheet F according to the given moving distance L B by: b′ = B + L For F B the feature point f Bi =(x Bi , y Bi ) is translated by a fixed moving distance: (x B′ , y B′ ) = (x B + L, y B + L) The map sheet F after preliminary translation B , calculate the matching error between feature points, and further optimize the position using the least squares method; represent the transformation matrix T as a two-dimensional affine transformation matrix: Among them, a 11 , a 12 , a 21 , a 22 are the coefficients of the affine transformation, and t x and t y are the translation amounts; the translation amounts t x and t y are for adjusting the preliminarily translated map sheet F B ; the cost function E(T) represents the sum of the squares of the coordinate errors between the feature points of the map sheet F B and the corresponding feature points in the map sheet F A : Among them, (x B′i , y B′i ) are the coordinates of the feature points after translation. By minimizing the cost function, the transformation matrix T is optimized to better align the feature points in map sheet F B with the feature points in map sheet F A ; To minimize the cost function, the least squares method is used to obtain the optimal transformation matrix T; Map sheet F B will be precisely aligned with map sheet F A according to the transformation matrix optimized by the preliminary translation and the least squares method, realizing the stitching of map sheets.
6. The method for measuring the size of circular threads based on machine vision according to claim 1, wherein, The specific step S5 is as follows: After completing the spatial stitching of the multi-image data, use the least squares method to perform parametric modeling on the tooth profile feature point set, and establish the best fitting straight line equations for the contours on both sides of l3 and l4 respectively as: where A1, B1, C1 are the parameters of line l3, and A2, B2, C2 are the parameters of line l4; assuming the center coordinates of the sphere are The perpendicular distance from c2 to l3 and l4 is expressed as: The coordinates can be obtained according to the above formula Furthermore, the actual height h of the tooth profile can be obtained, and then by constructing the axial distribution function of the thread: In the above formula, h k represents the measured height value at the k-th sampling position, is the theoretical nominal value. For the analysis of thread profile parameters in the spatial domain, by calculating the standard deviation of thread profile parameters: It can quantitatively evaluate the discreteness of the thread machining quality, effectively identify the gradual error caused by tool wear or clamping deformation during the thread manufacturing process, and provide a quantitative basis for process optimization.
7. A circular thread size measurement system based on machine vision, characterized in that, Including: Image acquisition module: Obtain multi-field images, where adjacent images have overlapping regions; Correction module: Correct the sub-pixels of the contour points of each image; Thread profile feature point extraction module: Sort the obtained corrected sub-pixel contour points according to the contour direction of the thread. Along the contour traversal direction, construct an equilateral triangle with the Euclidean distance between two adjacent sub-pixel points, and calculate the included angle θ between two adjacent equilateral triangles. i , if θ i is greater than the preset threshold θ t , it is judged as the corresponding feature point; Stitching module: Stitch the images guided by the feature points; Model fitting module: Based on the stitched images, calculate the simulated height and the measured height of the tooth profile respectively, calculate the standard deviation of the tooth profile parameters based on the simulated height and the measured height, and then judge whether the thread size is abnormal according to the standard deviation of the tooth profile parameters.
8. The machine vision-based circular thread size measurement system according to claim 7, wherein The specific correction module is as follows: For different images of the thread, first use the canny operator to perform edge detection at the pixel level on the binarized image to extract the thread contour: C = {(x i , y i ) | i = 1, 2, … n} where (x i , y i ) represents the coordinates of the i-th contour point, and n is the total number of sampling points on the contour edge; the neighborhood information of the edge is obtained by using the first-order gradient and the second-order gradient of the contour edge C. In order to provide an unbiased and high-precision numerical approximation for the differentiation of discrete pixels, a 7-tap interpolator and its differential kernel proposed by Farid and Simoncelli are used during gradient calculation to calculate the first-order gradients g x and g y in the x and y directions of the contour edge, and the second-order gradients g xx , g yy , g xy ; finally, the Steger unbiased curve structure detection is adopted to eliminate the systematic bias caused by discrete sampling, and the first-order and second-order derivatives of the neighborhood of the edge c i (x i , y i ) are used to construct the Hessian matrix: By performing singular value decomposition on H i and selecting the eigenvector corresponding to the largest eigenvalue This vector represents the unit vector along the direction perpendicular to the edge; calculate the contour edge c i The correction amount t along the normal direction i is: Update the edge contour pixel c i The position gives the sub-pixel coordinates:
9. The machine vision-based circular thread size measurement system according to claim 7, wherein The thread profile feature point extraction module is specifically as follows: First, sort the obtained corrected sub-pixel contour points according to the thread profile direction, c i ∈C{i = 1, 2, … n} are sub-pixel edge points. Along the contour traversal direction, construct an equilateral triangle with two adjacent sub-pixel edge points, v i and v i+1 are the vertices of two adjacent equilateral triangles respectively. v i is obtained by rotating c i around c i+1 by an angle of α, and the rotation matrix is expressed as: where α is the rotation angle; the same method can be used to calculate the i+1 coordinates; the included angle θ between two adjacent equilateral triangles i can be calculated by the following formula: Then, compare θ1 with the preset threshold θ t ; if it is greater than θ t , it is determined as the corresponding feature point; traverse the entire contour in this order according to this method.
10. The machine vision-based circular thread dimension measurement system according to claim 7, characterized in that, The splicing module is specifically as follows: Assume two map sheets F A and F B , and there is a known fixed moving distance L between them. The set of feature points F A ={f A1 , f A2 , …, f An} and F B ={f B1 , f B2 , …, f Bn} extracted from the two map sheets, where f Ai =(x Ai , y Ai ), f Bi =(x Bi , y Bi ) respectively represent the coordinates of the feature points in the map sheet F A and the map sheet F B ; First, translate the map sheet F according to the given moving distance L B : B′ = B + L For F B the feature point f Bi =(x Bi , y Bi ) is translated by a fixed moving distance: (x B′ ,y B′ ) = (x B +L, y B +L) The map sheet F after preliminary translation B , calculate the matching error between feature points, and further optimize the position using the least squares method; represent the transformation matrix T as a two-dimensional affine transformation matrix: where a 11 , a 12 , a 21 , a 22 are the coefficients of the affine transformation, and t x and t y are the translation amounts; the translation amounts t x and t y are for adjusting the initially translated map sheet F B ; the cost function E(T) represents the sum of the squares of the coordinate errors between the feature points of the map sheet F B and the corresponding feature points in the map sheet F A : Among them, (x B′i , y B′i ) are the coordinates of the feature points after translation. By minimizing the cost function, the transformation matrix T is optimized to better align the feature points in map sheet F B with the feature points in map sheet F A . To minimize the cost function, the least squares method is used to obtain the optimal transformation matrix T. Map sheet F B will be precisely aligned with map sheet F A according to the transformation matrix optimized by the preliminary translation and the least squares method, realizing the stitching of the map sheets; The specific model fitting module is as follows: After completing the spatial stitching of the multi-image data, use the least squares method to perform parametric modeling on the tooth profile feature point set, and establish the best fitting straight line equations for the contours on both sides of l3 and l4 respectively as: where A1, B1, C1 are the parameters of the straight line l3, and A2, B2, C2 are the parameters of the straight line l4; assume the center coordinates of the sphere are The perpendicular distance from c2 to l3 and l4 is expressed as: The coordinates can be obtained according to the above formula Furthermore, the actual height h of the tooth profile can be obtained, and then by constructing the thread axial distribution function: In the above formula, h k represents the measured height value at the k-th sampling position, is the theoretical nominal value. For the analysis of thread profile parameters in the spatial domain, by calculating the standard deviation of thread profile parameters: It can quantitatively evaluate the discreteness of the thread machining quality, effectively identify the gradual error caused by tool wear or clamping deformation during the thread manufacturing process, and provide a quantitative basis for process optimization.
Citation Information
Patent Citations
Angle detection algorithm based on triangle similarity theorem
CN107092909A
Thread parameter detection method based on machine vision
CN111462066A
Design method of arc threaded connection pair
CN113420394A
Land investigation linear feature pattern spot-oriented data reduction method
CN114898095A
Rubber roller thread online detection and correction method based on machine vision
CN115127479A
Cited By
Thread vanishing point positioning method, system and equipment and storage medium
CN120890371A