Trapezoidal thread parameter measurement method and system based on machine vision
Through the trapezoidal thread parameter measurement method based on machine vision, the difficulty of image rotation complexity and central axis determination in trapezoidal thread parameter measurement is solved, and the measurement effect with high accuracy and high adaptability is achieved.
Patent Information
- Application Number
- CN202510434499.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-07-11
AI Technical Summary
The prior art has difficulty in image rotation complexity and central axis determination in the measurement of trapezoidal thread parameters, resulting in insufficient measurement accuracy and insufficient adaptability.
The trapezoidal thread parameter measurement method based on machine vision is adopted, and the thread profile features are extracted by obtaining thread images, and the threaded tooth profiles are divided by segmenting the tooth top, the tooth bottom and the threaded tooth profiles on both sides are fitted with graphic methods to calculate the central axis of the thread and other parameters.
It improves the accuracy and adaptability of trapezoidal thread measurement, simplifies measurement difficulty, and enhances the adaptability of visual solutions in trapezoidal thread measurement.
Smart Images

Figure CN120293011A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of thread measurement, and specifically relates to a trapezoidal thread parameter measurement method and system based on machine vision. Background Art
[0002] Threads are essential basic structural components in modern industrial manufacturing and are widely used in fields such as mechanical engineering, aerospace, automotive manufacturing, and construction. Threads are used to achieve the fastening of various components, the transmission of motion, and the bearing of loads, and are key factors ensuring the connection reliability and working performance of mechanical systems. Therefore, the design and manufacturing quality of threads have an important impact on the safety and stability of the entire mechanical system.
[0003] The measurement of thread dimensions is crucial for ensuring the machining accuracy and service performance of threads. Dimension measurement methods are generally divided into two types: contact measurement and non-contact measurement. Contact measurement relies on measuring tools (such as thread ring gauges, thread plug gauges, and three-wire measurement instruments) for detection. Although this method is relatively simple, it has problems such as complex manual operation, low measurement efficiency, and easy introduction of human errors. Non-contact measurement uses machine vision technology and can achieve fast and automated multi-parameter detection, which is suitable for the thread measurement requirements in mass production. Through digital image processing technology, high-precision real-time measurement of various geometric parameters of threads can be carried out. The accuracy and efficiency of thread dimension measurement directly affect the production quality of threads, and thus affect the overall performance and safety of products. With the improvement of the level of modern industrial automation, the application of non-contact optical measurement technology in thread detection is becoming more and more widespread and has gradually become the development trend in the field of thread measurement.
[0004] CN110211047 discloses an image rotation method for measuring thread parameters by machine vision. This method relies on thresholds to determine whether rotation is needed, and may not accurately reflect the actual rotation angle during rotation judgment, resulting in insufficient measurement accuracy. Additionally, the method may lack adaptability to different types of threads (such as different diameters, pitches, etc.), limiting its versatility. CN109993787 discloses an image method for solving the pitch diameter of threads. When dealing with complex thread shapes or dirty threads, this method may not accurately capture the pitch diameter points when traversing line by line, resulting in measurement deviation. Liu Yang et al. extract the inclination angle of the thread image based on the feature circle of the hough transform. However, the hough transform requires setting multiple parameters (such as thresholds, minimum and maximum radii of the circle), and inappropriate parameter selection will lead to unsatisfactory detection results of the feature circle, thus making the extraction of the feature circle and the construction of the virtual line inaccurate, affecting the subsequent measurement results. Jiang Tao et al. use the double-threshold DP algorithm and the Hough transform to segment and fit the contour while improving the accuracy of edge detection, and on this basis, use the CTAR algorithm to extract the corner points of the thread crest and thread root. However, during the process of smoothing the contour, the Hough transform may remove some important local features, resulting in the loss of detail information. Additionally, the CTAR algorithm may be sensitive to local extrema during curvature detection, resulting in a decrease in the accuracy of corner point detection. Li Xianyou uses an oriented edge detection algorithm based on Gaussian function weight determination, and assigns reasonable weights to each pixel point by calculating the distance from each point to the edge line and its normal line, thereby enhancing the expression ability of edge features. However, the performance of the algorithm depends on parameter settings, especially the selection of the edge direction. If the parameter selection is inappropriate, it may lead to a decline in the detection effect. Summary of the Invention
[0005] The technical problem to be solved by the present invention is how to improve the thread measurement accuracy in view of the complexity of image rotation and the difficulty in determining the central axis commonly existing in the measurement of trapezoidal thread parameters.
[0006] The present invention realizes the solution of the above technical problems through the following technical means:
[0007] A method for measuring trapezoidal thread parameters based on machine vision, comprising the following steps:
[0008] Obtain a thread image and perform extraction of thread contour features; based on the extracted thread contour features, perform segmentation of the thread crest, thread root and the thread profile on both sides thereof; for the thread crest contour and the thread root contour of each tooth profile, perform linear fitting to obtain a set of linear points for each thread crest, and then for the set of thread crest linear points within the visible range, fit to obtain the thread crest line, and use the same method as for the thread crest to obtain the thread root line; finally, based on the lines of the thread crest and thread root on both sides of the measured rod, calculate the thread central axis, the distances between the thread crests and the distances between the thread roots on both sides of the measured rod, the tooth height, and the tooth width.
[0009] The present invention combines graphics methods to segment the top and bottom of trapezoidal thread teeth, divides the thread parameter measurement into small-size parameter measurement and large-size parameter measurement, simplifies the difficulty of thread measurement while improving the accuracy of thread measurement, and enhances the adaptability of the vision solution in trapezoidal thread measurement.
[0010] As a further preferred solution of the above scheme, before obtaining the thread image, it further includes the step of calibrating the internal and external parameters of the camera, specifically:
[0011] Step 1.1 Internal parameter calibration: First, take multiple images containing the calibration board to ensure that the calibration board has multiple angles and positions in the image; then detect the corner points of the calibration board and calculate the pixel coordinates of each corner point on the calibration board in the image; finally, through a non-linear optimization algorithm, obtain the focal length, principal point position, and distortion parameters of the camera;
[0012] Step 1.2 External parameter calibration: Let XOY be the coordinate system of the left camera target plane, and X′O′Y′ be the coordinate system of the right camera target plane. The diameter of the cylindrical calibration block is D, that is, the true distance between the left straight line L1 and the right L2 is D. In the left camera image, the vertical line L1 of the calibration block is represented as a set of point coordinates P L,i i is the number of contour points in the left L1 direction. In the right camera image, the vertical line L2 of the calibration block is represented as another set of point coordinates P R,j , j is the number of contour points in the right L2 direction; determine the equations of L1 and L2 by least-squares fitting of a straight line; the equation of the straight line is y = ax + by, where a is the slope. For L1, the slope is a1, then its inclination angle θ1 can be expressed as:
[0013] θ1 = arctan(a1)
[0014] Similarly, for L2, the slope is a2, and its inclination angle θ2 can be expressed as:
[0015] θ2 = arctan(a2)
[0016] The relative rotation angle between the cameras is estimated by the difference in the inclination angles of L1 and L2:
[0017] Δθ = θ2 - θ1
[0018] Δθ represents the rotation angle between the left camera and the right camera. The rotation matrix R can be expressed as the matrix of rotating by Δθ around the axis perpendicular to the xoy plane:
[0019]
[0020] The resolutions of the left and right camera images are resL and resR respectively, the size of the camera target surface is m x m, the coordinates of a point on the left camera image L1 are p1(x, y), and the coordinates of a point p2(x, y) on the right camera L2. The horizontal and vertical components of the translation matrix are expressed as:
[0021]
[0022] where are the x and y coordinates of point p1, are the x and y coordinates of point p2; the two-dimensional translation matrix is expressed as:
[0023]
[0024] A certain point P on the left camera L =(x L , y L ), is transformed into the right camera coordinate system:
[0025] P R = R·P L + T
[0026] P R is the coordinate of this point in the right camera coordinate system.
[0027] As a further preferred solution of the above solution, the contour feature extraction process is specifically as follows:
[0028] Based on the camera acquiring the thread image, the canny algorithm is used for edge detection: First, the image is smoothed by Gaussian filtering to eliminate the influence of irregular noise points; then the Sobel operator is used to calculate the gradients G x and G y in the x and y directions of the image, and the edge intensity is: The gradient direction calculation formula is: Then each pixel point is checked, and the gradient amplitude of this pixel point is compared with that of its two adjacent pixel points in the gradient direction, and only the pixel point with the largest gradient amplitude is retained, while other pixel points are suppressed; finally, double-threshold detection is used to distinguish strong edge pixels, weak edge pixels, and non-edge pixels to achieve the extraction of contour features.
[0029] As a further preferred solution of the above solution, the process of segmenting the thread crest, thread root, and the thread profile on both sides is specifically as follows:
[0030] Step 3.1 Construct a two-dimensional cloth grid and simulate to find the thread crest: The size of the cloth adapts to the thread contour; for the constructed two-dimensional cloth, the direction of gravity is the thread crest - thread root direction, and it falls along the direction of gravity. The point where the contour point collides with the cloth is the thread crest contour point;
[0031] Step 3.2 Change the gravity direction and starting position of the fabric, and use the same method as in Step 3.1 to segment the tooth bottom contour and the thread contour points on both sides of the tooth profile.
[0032] As a further preferred solution of the above solution, the thread parameters are divided into small-size parameters and large-size parameters. The small-size parameters include: tooth width w, pitch P, tooth height h, load side angle α, lead-in side angle β; the large-size parameters include major diameter D and minor diameter d.
[0033] Step 4.1 Obtain the central axis direction based on the tooth top and tooth bottom contour points: For the tooth top contour points of each tooth profile, use the ransac line fitting method to obtain the set of straight line points l = {(x q , y q )|q = 1, 2, …, Q} for each tooth top. Then, for the set of tooth tops l i {i = 1, 2, … S} within the visible range, use the least squares method to fit the tooth top direction, where Q is the straight line points of a single tooth top and S is the number of thread teeth within the visible range; similarly, for each tooth bottom l′, use the same method as the tooth top to fit the tooth bottom direction, and calculate the thread central axis A based on the tooth top and tooth bottom directions of the upper and lower threads.
[0034] Step 4.2 Measurement of small-size parameters: The measurement method of tooth height h is as follows: For the set of straight lines of the tooth top l = {(x q , y q )|q = 1, 2, …, Q} and l′ = {(x p , y p )|p = 1, 2, …, P}, first calculate the direction of l using the least squares method, and then calculate the average height from the point set of l′ to the straight line l.
[0035] Measurement of lead-in side, load side, and tooth width: For the load side and lead-in side, use the least squares method to fit the directions and . The angle calculation formula is:
[0036]
[0037] where α and β are the load side angle and lead-in side angle respectively. The tooth width is the position m and n points corresponding to half of the tooth height on the lead-in side and load side. The tooth width w is the distance between points m and n.
[0038] The measurement method of pitch P is the distance between the corresponding points k1 and k2 of half of the tooth height on the load side of adjacent teeth.
[0039] Step 4.3 Measurement of large-size parameters: For the measurement of the major diameter D at a given position E, the coordinates of point E′ satisfy:
[0040] a′1x + b′1y + c′1 = 0
[0041]
[0042] a′1, b′1, c′1 are the general equations of the straight line L′. According to the above formula, the coordinates of E′ are obtained; the major diameter D is obtained as the distance between E and E′; similarly, the minor diameter is the distance between points I and I′.
[0043] The present invention also provides a trapezoidal thread parameter measurement system based on machine vision, including:
[0044] Image acquisition module: acquires the thread image;
[0045] Thread feature extraction module, which extracts the thread profile features based on the thread image;
[0046] Contour segmentation module: based on the extracted thread profile features, performs the segmentation of the tooth top, tooth bottom and the thread profile on both sides thereof;
[0047] Thread parameter calculation module: performs linear fitting on the tooth top contour and tooth bottom contour of each tooth profile to obtain the set of linear points of each tooth top, and then fits the set of tooth top linear points within the visible range to obtain the tooth top straight line. The tooth bottom straight line is obtained by the same method as the tooth top; finally, based on the straight lines of the tooth top and tooth bottom of the threads on both sides of the workpiece to be measured, the thread central axis, the distances between the tooth tops and tooth bottoms of the threads on both sides of the workpiece to be measured, the tooth height, and the tooth width are calculated.
[0048] As a further preferred solution of the above solution, the image acquisition module uses a camera to take pictures of the workpiece to be measured. Before acquiring the thread image, the internal and external parameters of the camera need to be calibrated. Specifically:
[0049] Step 1.1 Internal parameter calibration: First, take multiple images containing the calibration board to ensure that the calibration board has multiple angles and positions in the image; then detect the corner points of the calibration board and calculate the pixel coordinates of each corner point on the calibration board in the image; finally, through the non-linear optimization algorithm, the focal length, principal point position and distortion parameters of the camera are obtained;
[0050] Step 1.2 External parameter calibration: Let XOY be the coordinate system of the left camera target plane, and X′O′Y′ be the coordinate system of the right camera target plane. The diameter of the cylindrical calibration block is D, that is, the real distance between the left straight line L1 and the right L2 is D. In the image of the left camera, the vertical line L1 of the calibration block is represented as a set of point coordinates P L,i i is the number of contour points in the direction of the left L1. In the image of the right camera, the vertical line L2 of the calibration block is represented as another set of point coordinates P R,j, the number of contour points in the L2 direction on the right side of j; by fitting a straight line using the least squares method, the equations of L1 and L2 are determined; the equation of the straight line is y = ax + by, where a is the slope. For L1, the slope is a1, and then its inclination angle θ1 can be expressed as:
[0051] θ1 = arctan(a1)
[0052] Similarly, for L2, the slope is a2, and its inclination angle θ2 can be expressed as:
[0053] θ2 = arctan(a2)
[0054] The relative rotation angle between the cameras is estimated by the difference in the inclination angles of L1 and L2:
[0055] Δθ = θ2 - θ1
[0056] Δθ represents the rotation angle between the left camera and the right camera, and the rotation matrix R can be expressed as the matrix of rotating by Δθ around the axis perpendicular to the xoy plane:
[0057]
[0058] The resolutions of the left and right camera images are resL and resR respectively, the size of the camera target surface is m x m, the coordinates of a point p1(x, y) on the left camera image L1, and a point p2(x, y) on the right camera L2. The horizontal and vertical components of the translation matrix are expressed as:
[0059]
[0060]
[0061] where are the x and y coordinates of point p1, are the x and y coordinates of point p2; the two-dimensional translation matrix is expressed as:
[0062]
[0063] A certain point P on the left camera L = (x L , y L ), is transformed into the right camera coordinate system:
[0064] P R = R · P L + T
[0065] P R is the coordinate of this point in the right camera coordinate system.
[0066] As a further preferred solution of the above solution, the contour feature extraction process is specifically as follows:
[0067] Based on the thread image obtained by the camera, edge detection is performed using the Canny algorithm: First, Gaussian filtering is performed on the image to smooth the image and eliminate the influence of irregular noise points; then the Sobel operator is used to calculate the gradients G x and G y in the x and y directions of the image, and the edge intensity is: The gradient direction calculation formula is: Then each pixel point is checked, and the gradient amplitude of this pixel point is compared with the gradient amplitudes of its two adjacent pixel points in the gradient direction. Only the pixel point with the largest gradient amplitude is retained, while other pixel points are suppressed; finally, double-threshold detection is used to distinguish strong edge pixels, weak edge pixels, and non-edge pixels to achieve the extraction of contour features.
[0068] As a further preferred solution of the above solution, the specific process of segmenting the tooth top, tooth bottom, and the thread profile on both sides thereof is as follows:
[0069] Step 3.1 Construct a two-dimensional cloth grid and simulate to find the tooth top of the thread: The size of the cloth adapts to the thread contour; for the constructed two-dimensional cloth, the gravity direction is the tooth top-tooth bottom direction, and it falls along the gravity direction. The point where the contour point collides with the cloth is the tooth top contour point;
[0070] Step 3.2 Change the cloth gravity direction and starting position, and use the same method as in Step 3.1 to segment the tooth bottom contour and the thread contour points on both sides of the tooth profile.
[0071] As a further preferred solution of the above solution, the thread parameters are divided into small-size parameters and large-size parameters. The small-size parameters include: tooth width w, pitch P, tooth height h, load side angle α, lead-in side angle β; the large-size parameters include major diameter D and minor diameter d;
[0072] Step 4.1 Obtain the central axis direction according to the tooth top and tooth bottom contour points: For the tooth top contour points of each tooth profile, the ransac line fitting method is used to obtain the set of straight line points l={(x q ,y q )|q = 1, 2, …, Q} for each tooth top. Then, for the set of tooth tops l i {i = 1, 2, … S} within the visible range, the least squares method is used to fit the tooth top direction, where Q is the straight line points of a single tooth top and S is the number of thread teeth within the visible range; similarly, for each tooth bottom l′, the same method as for the tooth top is used to fit the tooth bottom direction, and the thread central axis A is calculated according to the upper and lower tooth top and tooth bottom directions of the thread;
[0073] Step 4.2 Measurement of small-size parameters: The measurement method of the tooth height h is: For the tooth top l={(x q ,y q) | q = 1, 2, …, Q} and l′ = {(x p , y p ) | p = 1, 2, …, P} of the set of straight lines. First, the least squares method is used to calculate the direction of l, and then the average height of the point set of l′ to the straight line k is calculated;
[0074] Inlet side, bearing side and tooth width measurement: For the bearing side and the inlet side, the least squares fitting is used to obtain the direction and The angle calculation formula is:
[0075]
[0076] where α and β are the angles of the bearing side and the inlet side respectively, the tooth width is the positions m and n of the points corresponding to half of the tooth height of the inlet side and the bearing side, and the tooth width w is the distance between points m and n;
[0077] The pitch P is measured as the distance between the corresponding points k1 and k2 of half of the tooth height on the bearing side of adjacent teeth;
[0078] Step 4.3 Large size parameter measurement: For the measurement of the major diameter D at the given position E, the coordinates of point E′ satisfy:
[0079] ay′1x + b′1y + c′1 = 0
[0080]
[0081] a′1, b′1, c′1 are the general equations of the straight line L′, and the coordinates of E′ are obtained according to the above formula; the major diameter D is the distance between E and E′; similarly, the minor diameter is the distance between points I and I′.
[0082] The advantages of the present invention are:
[0083] The present invention integrates the graphics method to segment the crest and root of the trapezoidal thread, divides the thread parameter measurement into small size parameter measurement and large size parameter measurement, simplifies the difficulty of thread measurement while improving the accuracy of thread measurement, and enhances the adaptability of the vision scheme in trapezoidal thread measurement. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] Figure 1 is a flowchart of the trapezoidal thread parameter measurement method based on machine vision provided by the embodiment of the present invention;
[0085] Figure 2 is a schematic diagram of the camera internal and external parameter calibration tool in the embodiment of the present invention;
[0086] Figure 3 is a schematic diagram of the camera external parameter calibration in the embodiment of the present invention;
[0087] Figure 4 is the thread profile diagram extracted by using the method in the embodiment of the present invention;
[0088] Figure 5 is the segmentation diagram of the thread crest and thread root by using the method in the embodiment of the present invention;
[0089] Figure 6 is the trapezoidal thread parameter calculation diagram by using the method in the embodiment of the present invention. Detailed implementation manners
[0090] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts shall fall within the protection scope of the present invention.
[0091] The present invention discloses a method for measuring trapezoidal thread parameters based on machine vision, and the process is as Figure 1 shown, and it is carried out according to the following steps:
[0092] Step 1: Before acquiring the thread image, calibrate the internal and external parameters of the camera.
[0093] The calibration of the internal and external parameters of the camera is used to eliminate the deviation caused by lens distortion and camera installation error during the camera imaging process, and to achieve more accurate geometric measurement.
[0094] Step 1.1 The internal parameters are a set of parameters describing the imaging characteristics of the camera, including focal length, principal point position, lens distortion coefficient, etc. First, take multiple images containing the Figure 2 calibration board shown in a), ensuring that the calibration board has multiple angles and positions in the image; then detect the corner points of the calibration board and calculate the pixel coordinates of each corner point on the calibration board in the image; finally, through a non-linear optimization algorithm, obtain the focal length, principal point position and distortion parameters of the camera.
[0095] Step 1.2 Calculate the external parameter. Figure 2 The method for the calibration tool and image acquisition is shown in b), including 1. Camera fixing plate 2. Camera equipped with a telecentric lens 3. Cylindrical calibration block 4. Parallel light source 5. Light source fixing plate. The camera and the light source are horizontally placed on the optical platform, and the cylindrical calibration block is used to measure the distance between the two cameras. Figure 3 is the schematic diagram of external parameter calibration. XOY is the coordinate system of the target surface of camera 1, and X'O'Y' is the coordinate system of the target surface of camera 2. The diameter of the cylindrical calibration block is D, that is, the true distance between the left straight line L1 and the right L2 is D. In the image of the left camera, the vertical line L1 of the calibration block is represented as a set of point coordinates PL,i Let \(i\) be the number of contour points in the left \(L1\) direction. In the right camera image, the vertical line \(L2\) of the calibration block can be represented as the coordinates \(P\) of another set of points R,j , and \(j\) be the number of contour points in the right \(L2\) direction. By least squares fitting a straight line, the equations of \(L1\) and \(L2\) are determined. The equation of the straight line is \(y = ax + b\), where \(a\) is the slope. For \(L1\), the slope is \(a1\), then its inclination angle \(\theta1\) can be expressed as:
[0096] \(\theta1=\arctan(a1)\)
[0097] Similarly, for \(L2\), the slope is \(a2\), and its inclination angle \(\theta2\) can be expressed as:
[0098] \(\theta2=\arctan(a2)\)
[0099] The relative rotation angle between the cameras (perpendicular to the \(xoy\) plane) can be estimated by the difference in the inclination angles of \(L1\) and \(L2\):
[0100] \(\Delta\theta=\theta2 - \theta1\)
[0101] \(\Delta\theta\) represents the rotation angle between the left camera and the right camera. The rotation matrix \(R\) can be represented as the matrix of rotating by \(\Delta\theta\) around the axis perpendicular to the \(xoy\) plane:
[0102]
[0103] The resolutions of the left and right camera images are \(resL\) and \(resR\) respectively. The size of the camera target surface is \(m\times m\). The coordinates of a point \(p1(x,y)\) on \(L1\) in the left camera image and a point \(p2(x,y)\) on \(L2\) in the right camera. The horizontal and vertical components of the translation matrix are expressed as:
[0104]
[0105] where are the \(x\) and \(y\) coordinates of point \(p1\), are the \(x\) and \(y\) coordinates of point \(p2\). The two-dimensional translation matrix is expressed as:
[0106]
[0107] A certain point \(P\) on the left camera L =(x L ,y L ), is transformed to the right camera coordinate system:
[0108] P R =R·P L +T
[0109] P R is the coordinate of this point in the right camera coordinate system.
[0110] Step 2: Screw thread image acquisition and contour feature extraction.
[0111] After calibration, the camera captures screw thread images for accurate capture of screw thread contour features.
[0112] Step 2.1 Based on the screw thread images obtained by the camera, the Canny algorithm is used for edge detection. First, Gaussian filtering is performed on the image to smooth the image and eliminate the influence of irregular noise points; then the Sobel operator is used to calculate the gradients G x and G y in the x and y directions of the image, and the edge intensity is: The gradient direction calculation formula is: Then each pixel point is examined, and the gradient amplitude of this pixel point is compared with the gradient amplitudes of its two adjacent pixel points in the gradient direction, and only the pixel point with the largest gradient amplitude is retained, while other pixel points are suppressed; finally, double-threshold detection is used to distinguish strong edge pixels, weak edge pixels, and non-edge pixels to achieve the extraction of contour features. Figure 4 is the screw thread contour diagram obtained by the above method.
[0113] Step 3: Segmentation of screw thread root and crest contour points.
[0114] The obtained screw thread contour is composed of a set of two-dimensional points. Due to the influence of the screw thread taper, the directions and positions of the root and crest in the contour points are unknown. To calculate the detailed parameters of the screw thread, it is necessary to segment the root and crest contour points of the screw thread contour.
[0115] Step 3.1 Construct a two-dimensional cloth grid and simulate to find the screw thread crest. Figure 5 a) The blue on the left is the cloth, and G is the direction of gravity. The size of the cloth adapts to the screw thread contour. The cloth is composed of particles - springs. Each particle is affected by internal and external forces. The internal force is mainly reflected by the springs. The internal force between the spring particles satisfies Hooke's law; at the same time, the weight of each particle is given, and the gravity received by the particle is the external force. The particles satisfy Newton's second law due to the influence of internal and external forces:
[0116]
[0117] where a is the acceleration of the particle, m is the weight of the particle, k is the elastic coefficient, Fg g is the gravity received by the particle. The acceleration of the particle determines the speed of the particle. Since:
[0118] v t = v t-1 + aΔt
[0119] v t is the current speed, v t-1is the speed at the previous moment, and Δt is the time difference. However, during the process of the continuous change of the spring length, the elastic force also changes continuously, so the force on the particle will change all the time. The Verlet integration is used to deduce the state at the next moment using the state at the previous moment:
[0120] x t+1 = x t +(x t - x t-1 ) + a t Δt 2
[0121] For the constructed two-dimensional fabric, the direction of gravity is from the tooth tip to the tooth root. It falls along the direction of gravity and collides with the thread profile Figure 5 As shown in b), the point where the contour point collides with the fabric is the tooth tip contour point ( Figure 5 the blue point in c)).
[0122] Step 3.2 Change the direction of the fabric gravity and the starting position, and segment the tooth root contour. The method is the same as that in Step 3.1. As Figure 5 shown in c), but change the initial fabric position and the direction of gravity, and collide with the thread profile ( Figure 5 d), and finally obtain the segmentation of the thread contour points on the tooth tip, tooth root and both sides of the tooth profile.
[0123] Step 4: Calculation of the detailed thread parameters.
[0124] After completing the segmentation of the thread contour points, it is applied to the calculation of the detailed thread parameters. The thread parameters are divided into small-size parameters and large-size parameters. The small-size parameters include: tooth width w, pitch P, tooth height h, load side angle α, lead-in side angle β; the large-size parameters include major diameter D and minor diameter d. Figure 6 It is a schematic diagram for calculating trapezoidal thread parameters.
[0125] Step 4.1 Obtain the central axis direction according to the tooth tip and tooth root contour points. The central axis is an important reference benchmark for thread measurement. For the tooth tip contour points of each tooth profile, the ransac line fitting method is used to obtain the set of straight line points of each tooth tip l = {(x q , y q ) | q = 1, 2,..., Q}, and then for the set of tooth tips l i {i = 1, 2,... S} within the visible range, the least squares method is used to fit the tooth tip direction, where Q is the straight line points of a single tooth tip and S is the number of thread teeth within the visible range. Figure 6 In it, L1 and L′1 are the fitted tooth tip directions. Similarly, for each tooth root l′, the same method as the tooth tip is used. Figure 6 In it, L2 and L′2 are the fitted tooth root directions, and the thread central axis A is calculated according to the tooth tip and tooth root parameters of the upper and lower threads of the thread.
[0126] Step 4.2 Measurement of small-size parameters. Figure 6 For each tooth profile, the measurement method of the tooth height h is as follows: for the tooth tip l = {(x q , y q ) | q = 1, 2, …, Q} and the set of lines l′ = {(x p , y p ) | p = 1, 2, …, P}, first use the least squares method to calculate the direction of l, and then calculate the average height of the point set l′ to the line l; for the lead side, load side, and tooth width measurement: for the load side and lead side, use the least squares method to fit the direction and The angle calculation formula is:
[0127]
[0128] where a and β are the angles of the load side and lead side respectively, Figure 6 In, the tooth width is the positions m and n of the half of the tooth height of the lead side and the load side, and the tooth width w is the distance between points m and n. Figure 6 The measurement method of the pitch P is the distance between the corresponding points k1 and k2 of half of the tooth height of the adjacent tooth load side.
[0129] Step 4.3 Measurement of large-size parameters. Figure 6 For the measurement of the major diameter D at the given position E, the coordinates of point E′ satisfy:
[0130] a′1x + b′1y + c′1 = 0
[0131]
[0132] a′1, b′1, c′1 are the general equations of the line L′, and the coordinates of E′ are obtained according to the above formula. The major diameter D is the distance between E and E′. Similarly, the minor diameter is the distance between points I and I′.
[0133] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; 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 for 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 embodiments of the present invention.
Claims
1. A method for measuring trapezoidal thread parameters based on machine vision, characterized in that It includes the following steps: Obtain a thread image and perform extraction of thread profile features; based on the extracted thread profile features, perform segmentation of the tooth crest, tooth root, and the thread profile on both sides thereof; for the tooth crest profile and the tooth root profile of each tooth profile, perform linear fitting to obtain the set of linear points of each tooth crest, and then for the set of tooth crest linear points within the visible range, fit to obtain the tooth crest line, and use the same method as the tooth crest to obtain the tooth root line; finally, based on the lines of the tooth crest and tooth root of the threads on both sides of the component to be measured, calculate the thread central axis, the distances between the tooth crests and tooth roots of the threads on both sides of the component to be measured, the tooth height, and the tooth width.
2. The method for measuring trapezoidal thread parameters based on machine vision according to claim 1, wherein Before obtaining the thread image, it also includes the step of calibrating the internal and external parameters of the camera, specifically: Step 1.1 Internal parameter calibration: First, take multiple images containing the calibration board to ensure that the calibration board has multiple angles and positions in the images; then detect the corner points of the calibration board and calculate the pixel coordinates of each corner point on the calibration board in the image; finally, through a non-linear optimization algorithm, obtain the focal length, principal point position, and distortion parameters of the camera. Step 1.2 Extrinsic Parameter Calibration: Let XOY be the coordinate system of the left camera's target plane, X ′ O δ Y ′ be the coordinate system of the right camera's target plane. The diameter of the cylindrical calibration block is D, that is, the true distance between the left straight line L1 and the right L2 is D. In the left camera image, the vertical line L1 of the calibration block is represented as a set of point coordinates P L,i i is the number of contour points in the direction of the left L1. In the right camera image, the vertical line L2 of the calibration block is represented as another set of point coordinates P R,j , j is the number of contour points in the direction of the right L2; By least squares fitting a straight line, the equations of L1 and L2 are determined; The equation of the straight line is y = ax + by, where a is the slope. For L1, the slope is a1, then its inclination angle θ1 can be expressed as: θ1 = arctan(a1) Similarly, for L2, the slope is a2, and its inclination angle θ2 can be expressed as: θ2 = arctan(a2) The relative rotation angle between the cameras is estimated by the difference in the inclination angles of L1 and L2: Δθ = θ2 - θ1 Δθ represents the rotation angle between the left camera and the right camera, and the rotation matrix R can be expressed as the matrix of rotating by Δθ around the axis perpendicular to the xoy plane: The resolutions of the left and right camera images are resL and resR respectively, the size of the camera target surface is m×m, the point coordinates on the left camera image L1 are p1(x,y), and a point p2(x,y) on the right camera L2. The horizontal and vertical components of the translation matrix are expressed as: where are the x and y coordinates of point p1, are the x and y coordinates of point p2; the two-dimensional translation matrix is represented as: A certain point P on the left camera L =(x L , y L ), transformed to the right camera coordinate system: P R = R·P L + T P R is the coordinate of this point in the right camera coordinate system.
3. The method for measuring trapezoidal thread parameters based on machine vision according to claim 1, wherein The specific process of contour feature extraction is as follows: Based on the thread image captured by the camera, the Canny algorithm is used for edge detection: First, the image is smoothed by Gaussian filtering to eliminate the influence of irregular noise points; then the Sobel operator is used to calculate the gradients G1 and G of the image in the x and y directions y , and the edge strength is: The gradient direction calculation formula is: Then each pixel point is checked, and the gradient amplitude of this pixel point is compared with that of its two adjacent pixel points in the gradient direction, and only the pixel point with the largest gradient amplitude is retained, while other pixel points are suppressed; finally, double-threshold detection is used to distinguish strong edge pixels, weak edge pixels, and non-edge pixels to achieve the extraction of contour features.
4. The method for measuring trapezoidal thread parameters based on machine vision according to claim 1, wherein The specific process of segmenting the tooth crest, tooth root, and the thread profile on both sides thereof is as follows: Step 3.1 Construct a two-dimensional cloth grid and simulate to find the tooth crest of the thread: The size of the cloth adapts to the thread profile; for the constructed two-dimensional cloth, the direction of gravity is the tooth crest - tooth root direction, and it falls along the direction of gravity. The points where the contour points collide with the cloth are the tooth crest contour points. Step 3.2 Change the direction of gravity and the starting position of the cloth, and use the same method as in Step 3.1 to segment the tooth root contour and the thread contour points on both sides of the tooth profile.
5. The method for measuring trapezoidal thread parameters based on machine vision according to any one of claims 1 to 4, characterized in that, The thread parameters are divided into small-size parameters and large-size parameters. The small-size parameters include: tooth width w, pitch P, tooth height h, load side angle α, lead-in side angle β; the large-size parameters include major diameter D and minor diameter d. Step 4.1 Obtain the central axis direction based on the tooth crest and tooth root contour points: For the tooth crest contour points of each tooth profile, use the ransac line fitting method to obtain the set of line points l = {(x q , y q ) | q = 1, 2, …, Q} for each tooth crest. Then, for the set of tooth crests l i {i = 1, 2, … S} within the visible range, use the least squares method to fit the tooth crest direction, where Q is the number of line points of a single tooth crest and S is the number of thread teeth within the visible range. Similarly, for each tooth root l ′ use the same method as for the tooth crest to fit the tooth root direction, and calculate the thread central axis A based on the tooth crest and tooth root directions of the upper and lower threads of the thread; Step 4.2 Measurement of small-size parameters: The measurement method of tooth height h is as follows: For the tooth crest l = {(x q , y q ) | q = 1, 2, …, Q} and the set of straight lines l ′ = {(x p , y p ) | p = 1, 2, …, P}, first use the least squares method to calculate the direction of l, and then calculate the average height of the point set of l ′ to the straight line l; Import side, load side and tooth width measurement: For the load side and the import side, the least squares method is used to fit the direction and The angle calculation formula is: Where a and β are the load side angle and the lead-in side angle respectively. The tooth width is the position between points m and n corresponding to half of the tooth height on the lead-in side and the load side. The tooth width w is the distance between points m and n. The measurement method of the pitch P is the distance between the corresponding points k1 and k2 of half of the tooth height on the load side of adjacent teeth. Step 4.3 Measurement of large-size parameters: For the measurement of the major diameter D at the given position E, the ′ point coordinates satisfy: a ′ 1x + b ′ 1y + c1 ′ = 0 a ′ 1, b l 1, c1 ′ is the general equation of the straight line L ′ From the above equation, the coordinate of E is obtained ′ The major diameter D is the distance between E and E ′ Similarly, the minor diameter is the distance between points I and I ′ 6. A trapezoidal thread parameter measurement system based on machine vision, characterized in that, It includes: Image acquisition module: Obtain a thread image; Thread feature extraction module, which performs extraction of thread profile features based on the thread image; Contour segmentation module: Based on the extracted thread profile features, perform segmentation of the tooth crest, tooth root, and the thread profile on both sides thereof; Thread parameter calculation module: For the tooth top contour and tooth bottom contour of each tooth profile, perform linear fitting to obtain the set of linear points of each tooth top. Then, for the set of tooth top linear points within the visible range, fit to obtain the tooth top line. Use the same method as for the tooth top to obtain the tooth bottom line. Finally, based on the lines of the tooth top and tooth bottom of the threads on both sides of the component to be measured, calculate the thread central axis, the distances between the tooth tops and tooth bottoms of the threads on both sides of the component to be measured, the tooth height, and the tooth width.
7. The machine vision-based trapezoidal thread parameter measurement system according to claim 6, wherein The image acquisition module uses a camera to take pictures of the component to be measured. Before acquiring the thread image, it is necessary to calibrate the internal and external parameters of the camera. Specifically: Step 1.1 Internal parameter calibration: First, take multiple images containing the calibration board to ensure that the calibration board has multiple angles and positions in the image. Then, detect the corner points of the calibration board and calculate the pixel coordinates of each corner point on the calibration board in the image. Finally, through a non-linear optimization algorithm, obtain the focal length, principal point position, and distortion parameters of the camera. Step 1.2 Extrinsic Parameter Calibration: Let XOY be the coordinate system of the left camera's target plane, where X ′ O ′ Y ′ is the coordinate system of the right camera's target plane. The diameter of the cylindrical calibration block is D, that is, the actual distance between the left line L1 and the right line L2 is D. In the left camera image, the vertical line L1 of the calibration block is represented as a set of point coordinates P L,i i is the number of contour points in the direction of the left L1. In the right camera image, the vertical line L2 of the calibration block is represented as another set of point coordinates P R,j , j is the number of contour points in the direction of the right L2. By least squares fitting of the straight line, the equations of L1 and L2 are determined; the equation of the straight line is y = ax + b, where a is the slope. For L1, the slope is a1, then its inclination angle θ1 can be expressed as: θ1 = arctan(a1) Similarly, for L2, the slope is a2, and its inclination angle θ2 can be expressed as: θ2 = arctan(a2) The relative rotation angle between the cameras is estimated by the difference in the inclination angles of L1 and L2: Δθ = θ2 - θ1 Δθ represents the rotation angle between the left camera and the right camera. The rotation matrix R can be expressed as the matrix of rotating by Δθ around the axis perpendicular to the xoy plane: The resolutions of the left and right camera images are resL and resR respectively. The size of the camera target surface is m×m. The point coordinates on the left camera image L1 are p1(x, y), and a point p2(x, y) on the right camera L2. The horizontal and vertical components of the translation matrix are expressed as: wherein are the x and y coordinates of point p1, are the x and y coordinates of point p2; the two-dimensional translation matrix is represented as: A certain point P on the left camera L =(x L , y L ), transformed to the right camera coordinate system: P R = R·P L + T P R are the coordinates of this point in the right camera coordinate system.
8. The trapezoidal thread parameter measurement system based on machine vision according to claim 6, characterized in that, The specific process of contour feature extraction is as follows: Based on the thread image obtained by the camera, the Canny algorithm is used for edge detection: First, the image is smoothed by Gaussian filtering to eliminate the influence of irregular noise points; then the Sobel operator is used to calculate the gradients G x and G y in the x and y directions of the image, and the edge intensity is: The gradient direction calculation formula is: Then each pixel point is checked, and the gradient magnitude of this pixel point is compared with that of its two adjacent pixel points in the gradient direction, and only the pixel point with the largest gradient magnitude is retained, while other pixel points are suppressed; finally, double-threshold detection is used to distinguish strong edge pixels, weak edge pixels and non-edge pixels to achieve the extraction of contour features.
9. The machine vision-based trapezoidal thread parameter measurement system according to claim 6, characterized in that The specific process of segmenting the tooth top, tooth bottom, and the tooth profile of the threads on both sides is as follows: Step 3.1 Construct a two-dimensional cloth grid and simulate to find the tooth top of the thread: The size of the cloth adapts to the thread contour. For the constructed two-dimensional cloth, the gravity direction is the tooth top - tooth bottom direction. When it falls along the gravity direction, the points where the contour points collide with the cloth are the tooth top contour points. Step 3.2 Change the gravity direction and starting position of the cloth, and use the same method as in Step 3.1 to segment the tooth bottom contour and the thread contour points on both sides of the tooth profile.
10. The machine vision-based trapezoidal thread parameter measurement system according to any one of claims 6 to 9, characterized in that, Thread parameters are divided into small-size parameters and large-size parameters. Small-size parameters include: tooth width w, pitch P, tooth height h, load side angle α, lead-in side angle β; large-size parameters include major diameter D and minor diameter d. Step 4.1 Obtain the central axis direction based on the tooth crest and tooth root contour points: For the tooth crest contour points of each tooth profile, use the RANSAC line fitting method to obtain the set of line points l = {(x q , y q ) | q = 1, 2, …, Q} for each tooth crest. Then, for the set of tooth crests l i {i = 1, 2, … S} within the visible range, use the least squares method to fit the tooth crest direction, where Q is the line points of a single tooth crest and S is the number of thread teeth within the visible range; Similarly, for each tooth root l ′ use the same method as for the tooth crest to fit the tooth root direction, and calculate the thread central axis A based on the tooth crest and tooth root directions of the upper and lower threads of the thread; Step 4.2 Measurement of small-size parameters: The measurement method of the tooth height h is as follows: For the tooth crest l = {(x q , y q ) | q = 1, 2, …, Q} and the set of straight lines l ′ = {(x p , y p ) | p = 1, 2, …, P}, first use the least squares method to calculate the direction of l, and then calculate the average height of the point set of l ′ to the straight line l; Import side, load side and tooth width measurement: For the load side and the import side, the least squares fitting is used to obtain the direction and The angle calculation formula is: Among them, α and β are the load side angle and lead-in side angle respectively. The tooth width is the position between points m and n corresponding to half of the tooth height on the lead-in side and the load side. The tooth width w is the distance between points m and n. The measurement method of the pitch P is the distance between the corresponding points k1 and k2 of half of the tooth height on the load side of adjacent teeth. Step 4.3 Measurement of large-size parameters: For the measurement of the major diameter D at the given position E, the ′ point coordinates satisfy: a ′ 1x + b ′ 1y + c1 ′ = 0 a ′ 1, b ′ 1, c1 ′ is the general equation of the straight line L ′ Based on the above equation, the coordinate of E is obtained ′ The major diameter D is the distance between E and E ′ Similarly, the minor diameter is the distance between I and I ′ points
Citation Information
Patent Citations
Screw thread parameter measurement method based on image measurement and processing
CN103245296A
Visual detection method for zigzag screw thread
CN105241380A
Trapezoidal thread visual detection method
CN105258652A
Triangular thread tooth tip width measurement method and apparatus thereof
CN105987667A
Outside thread multi-parameter evaluation method based on machine vision and virtual instrument
CN109781004A
Cited By
Fastener size measurement method and system based on structured contour line
CN121898263A
Thread parameter high-precision real-time detection method and system based on line laser contourgraph
CN122486511A