Bolt size measurement method and device, electronic equipment and storage medium
By using camera calibration and image processing technology, combined with improved algorithms to fit and detect bolt thread profiles, the problems of accuracy and efficiency in bolt size measurement are solved, and high-precision, real-time bolt size detection and model classification are achieved.
Patent Information
- Application Number
- CN202310555291.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2043-05-16
AI Technical Summary
Existing technologies for bolt size measurement suffer from low accuracy, low efficiency, and poor real-time performance. In particular, the frequent use of bolts in mechanical assembly leads to mixed bolt types and plastic deformation, affecting the fixing effect and the efficiency of mechanical equipment.
Camera calibration and image processing techniques are used to identify the bolt thread edge profile. The improved adaptive DP algorithm and Hough transform are combined to fit the thread profile. The optimized FRPD algorithm is used to detect the thread curvature corner point. The least squares transformation is used to calculate the major and minor diameters of the thread.
It achieves high precision, real-time performance, and accuracy in bolt size measurement, supporting rapid inspection and model/quality classification of bolt parts in the field of mechanical equipment manufacturing.
Smart Images

Figure CN116843761B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision, and in particular to a bolt size measurement method and device, electronic equipment and a storage medium. BACKGROUND
[0002] In mechanical assembly work, frequent disassembly and replacement of bolts will lead to mixed use of different types of bolts, and the bolt rod will also be plastic deformed and the hole diameter will be worn due to the transverse load, which will endanger the fixing effect of the bolt and the use efficiency of the mechanical equipment. During repeated use of the bolt, the bolt thread hole diameter will be plastic deformed due to stress, and the severely worn bolt rod will no longer meet the requirement of pre-tightening force. The change in the diameter of the bolt rod can be measured by using a vernier caliper, but the measurement process is relatively cumbersome, and the accuracy of the vernier caliper has certain limitations.
[0003] In the aspect of measuring the size of a part, the prior art mainly detects by artificial detection, but artificial detection has a great subjective factor. And the artificial measurement method has certain limitations, such as low precision, low efficiency, and poor real-time performance. SUMMARY
[0004] The main purpose of the embodiments of the present application is to provide a bolt size measurement method and device, electronic equipment and a storage medium, which can improve the precision and efficiency of bolt size measurement, and have high measurement precision, accuracy and real-time performance, and can be used for detection of bolt part size in the field of mechanical equipment manufacturing.
[0005] To achieve the above purpose, a first aspect of the embodiments of the present application provides a bolt size measurement method, which comprises:
[0006] Calibrating a camera for shooting a bolt;
[0007] Obtaining an image of the bolt shot by the camera, and identifying a thread edge contour area of the bolt from the image;
[0008] Extracting features of the thread edge contour area to obtain a thread contour of the bolt;
[0009] Segmenting the thread contour by using an improved adaptive DP algorithm to obtain a plurality of contour segments;
[0010] Fitting the contour segments by using Hough transform to obtain a smooth thread contour;
[0011] Detecting the corner points of the curvature corresponding to the smooth thread contour based on an optimized FRPD algorithm;
[0012] The corner points are fitted by using a least square transformation to calculate the size of the major diameter and minor diameter of the bolt thread.
[0013] In some embodiments, after the image of the bolt taken by the camera is acquired, and the thread edge profile region of the bolt is identified from the image, the method further comprises:
[0014] Performing image transmission transformation on the thread edge profile region to obtain a transformation matrix;
[0015] Performing image correction on the thread edge profile region according to the transformation matrix.
[0016] In some embodiments, the feature extraction on the thread edge profile region to obtain the thread profile of the bolt comprises:
[0017] Using a bilateral filter to perform noise reduction processing on the image;
[0018] Performing binarization processing on the image after noise reduction processing, and calculating the gradient amplitude and gradient angle of the image;
[0019] Performing non-maximum suppression processing on the image according to the gradient amplitude and gradient angle to obtain the threshold value and grayscale information of the image;
[0020] Using Otsu algorithm to segment the threshold value of the image;
[0021] Classifying the image into target and background using the grayscale information of the image, wherein the target is the thread profile of the bolt.
[0022] In some embodiments, the segmentation of the thread profile by the improved adaptive DP algorithm comprises:
[0023] Using the improved adaptive DP algorithm to segment the thread profile into straight lines and circular arcs according to its geometric characteristics;
[0024] Adaptively adjusting the number and position of sampling points according to the curvature characteristics and shape characteristics of the thread profile;
[0025] For each sampling point on the thread profile, the change of the curvature of the sampling point is obtained by calculating the position and curvature of a plurality of sampling points before and after the sampling point;
[0026] Determining the sampling density of the thread profile according to the change of the curvature;
[0027] Adjusting the sampling points of the thread profile according to the change of the sampling density;
[0028] Segmenting the thread profile according to the sampling points.
[0029] In some embodiments, the adjusting the sampling points of the thread profile according to the change of the sampling density comprises:
[0030] In the segmentation process, the positions of the segmentation points are adjusted based on the change of the curvature, for the region determined to need to increase the sampling density, new sampling points are inserted in the region, and for the region determined to need to reduce the sampling density, some sampling points are deleted.
[0031] The curvature-based method adjusts the positions of the segmentation points by calculating the curvature of the thread profile at each sampling point.
[0032] In some embodiments, the curvature-based method adjusts the positions of the segmentation points by calculating the curvature of the thread profile at each sampling point comprises:
[0033] For each sampling point on the thread profile, the curvature of the sampling point is calculated by calculating the positions and curvatures of several points before and after the sampling point through numerical differentiation method.
[0034] The sampling points that need to be segmented and the sampling points that need to be merged are determined according to the change of the curvature.
[0035] If the change of the curvature between two adjacent sampling points exceeds a preset threshold, it is determined that the two adjacent sampling points need to be segmented, and a new sampling point is inserted between the two adjacent sampling points.
[0036] If the change of the curvature between two adjacent sampling points does not exceed a preset threshold, it is determined that the two adjacent sampling points need to be merged, and the two adjacent sampling points are merged into one sampling point.
[0037] In some embodiments, after the fitting of the corner points using the least squares method transformation to calculate the sizes of the major diameter and minor diameter of the thread of the bolt, the method further comprises:
[0038] Comparing the sizes of the major diameter and minor diameter of the thread of the bolt with preset standard qualified sizes respectively to obtain a comparison result.
[0039] Classifying the bolt based on the comparison result.
[0040] To achieve the above object, a second aspect of an embodiment of the present application provides a bolt size measuring device, the device comprising:
[0041] A calibration module is configured to calibrate a camera for shooting a bolt.
[0042] An identification module is configured to acquire an image of the bolt shot by the camera, and identify a thread edge profile region of the bolt from the image.
[0043] an extraction module configured to extract features of the threaded edge profile region to obtain a threaded profile of the bolt;
[0044] a segmentation module configured to segment the threaded profile by using an improved adaptive DP algorithm to obtain a plurality of profile segments;
[0045] a fitting module configured to fit the profile segments by using a Hough transform to obtain a smooth threaded profile;
[0046] a detection module configured to detect corner points of a curvature of the smooth threaded profile based on an optimized FRPD algorithm;
[0047] a calculation module configured to fit the corner points by using a least square method transform to calculate sizes of a major diameter and a minor diameter of the threaded profile of the bolt.
[0048] To achieve the above object, a third aspect of embodiments of the present application provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.
[0049] To achieve the above object, a fourth aspect of embodiments of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.
[0050] This invention proposes a bolt size measurement method, device, electronic equipment, and storage medium. The method involves calibrating a camera used to photograph the bolt; acquiring an image of the bolt captured by the camera; identifying the thread edge contour region of the bolt from the image; extracting features from the thread edge contour region to obtain the bolt's thread contour; segmenting the thread contour using an improved adaptive DP algorithm to obtain multiple contour segments; fitting the contour segments using a Hough transform to obtain a smooth thread contour; detecting corner points corresponding to the curvature of the smooth thread contour based on an optimized FRPD algorithm; and fitting the corner points using a least squares transform to calculate the bolt's major and minor diameters. Based on this, by identifying the bolt's thread edge contour region from the image; extracting features from the thread edge contour region to obtain the bolt's thread contour; using an improved and optimized DP algorithm to adaptively smooth the contour; and then using an optimized FRPD algorithm to detect corner points; and fitting the detected corner points using a least squares transform to obtain the imaginary cylindrical generatrices at the major and minor diameter positions, high-precision, real-time bolt size detection and model / quality classification are achieved by calculating and measuring the distance between the two straight lines. Based on this, the bolt size measurement method of the present invention has high measurement accuracy, precision and real-time performance, and can be used for the detection of bolt part dimensions in the field of mechanical equipment manufacturing, providing important technical support for this field. Attached Figure Description
[0051] Figure 1 This is the main flowchart of the bolt size measurement method provided in the embodiments of the present invention;
[0052] Figure 2 This is a sub-flowchart of the bolt size measurement method provided in an embodiment of the present invention;
[0053] Figure 3 This is a sub-flowchart of the bolt size measurement method provided in an embodiment of the present invention;
[0054] Figure 4 This is a sub-flowchart of the bolt size measurement method provided in an embodiment of the present invention;
[0055] Figure 5 This is a sub-flowchart of the bolt size measurement method provided in an embodiment of the present invention;
[0056] Figure 6 This is a sub-flowchart of the bolt size measurement method provided in an embodiment of the present invention;
[0057] Figure 7 This is a sub-flowchart of the bolt size measurement method provided in an embodiment of the present invention;
[0058] Figure 8 This is a schematic diagram of the bolt size measuring device provided in an embodiment of the present invention;
[0059] Figure 9 Fig. 1 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application.
[0061] It should be noted that although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a manner different from the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and above-described drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0062] In view of the technical problems of low precision, low efficiency and poor real-time in manual detection in the prior art, the embodiments of the present application provide a bolt size measurement method and device, an electronic device and a storage medium. The camera for shooting the bolt is calibrated; the image of the bolt shot by the camera is obtained, and the thread edge contour area of the bolt is identified from the image; the feature of the thread edge contour area is extracted to obtain the thread contour of the bolt; the improved adaptive DP algorithm is used to segment the thread contour to obtain a plurality of contour segments; the Hough transform is used to fit the contour segments to obtain a smooth thread contour; the corner point of the curvature corresponding to the smooth thread contour is detected based on the optimized FRPD algorithm; and the least square transformation is used to fit the corner point to calculate the size of the major diameter and the minor diameter of the thread of the bolt. Based on this, the thread edge contour area of the bolt is identified from the image; the feature of the thread edge contour area is extracted to obtain the thread contour of the bolt, the improved and optimized DP algorithm is used to adaptively smooth the contour, and the optimized FRPD algorithm is used to detect the corner point based on this. The least square transformation is used to fit the detected corner point to obtain the imaginary cylindrical generatrix at the major diameter and minor diameter positions, and the high-precision and real-time detection of the bolt size and the model quality classification are realized by calculating the distance between the two straight lines. Based on this, the bolt size measurement method of the embodiments of the present application has high measurement precision, accuracy and real-time, and can be used for the detection of bolt part size in the field of mechanical equipment manufacturing, thereby providing important technical support for this field.
[0063] The bolt size measurement method and device, the electronic device and the storage medium provided by the embodiments of the present application are specifically described as follows. First, the bolt size measurement method in the embodiments of the present application is described.
[0064] Figure 1is an optional flowchart of the bolt size measurement method provided by the embodiment of the present application, Figure 1 The method in the method can include but is not limited to steps S101 to S107.
[0065] Step S101, calibrate the camera for shooting the bolt;
[0066] Step S102, acquire the image of the camera shooting the bolt, and identify the thread edge contour area of the bolt from the image;
[0067] Step S103, feature extraction is performed on the thread edge contour area to obtain the thread contour of the bolt;
[0068] Step S104, the thread contour is segmented by the improved adaptive DP algorithm to obtain a plurality of contour segments;
[0069] Step S105, the contour segments are fitted using Hough transform to obtain a smooth thread contour;
[0070] Step S106, the corner points of the curvature corresponding to the smooth thread contour are detected based on the optimized FRPD algorithm;
[0071] Step S107, the corner points are fitted using the least square method transformation to calculate the size of the major diameter and minor diameter of the thread of the bolt.
[0072] In some embodiments, in order to more accurately correct the image, a camera calibration technique is used. Camera calibration can determine the internal and external parameters of the camera, so that the correction process is more accurate. Therefore, the system needs to be calibrated in any scene application. Including camera internal parameter calibration and external parameter hand-eye calibration. Among them, the camera internal parameter calibration is to solve the influence of the camera lens distortion on the accuracy of the feature extraction algorithm in the later stage and affect the accuracy of the minor diameter calculation. And the external parameter hand-eye calibration is to solve the problem that the mechanical hand can correctly classify and process the bolt when the system is deployed to a digital intelligent manufacturing and operation factory in the later stage. Before camera calibration, the pixel coordinate system PCS (O-uv), the image coordinate system I PCS (O-XY), the camera coordinate system CCS (O-XcYcZc), the robot coordinate system RCS (O-XrYrZr) and the world coordinate system SCS (O-XwYwZw) are established.
[0073] In some embodiments, for image acquisition, the detection platform built by the industrial camera and the aperture is used for shooting. In the detection platform, the relative position of the camera and the aperture remains unchanged to ensure that the bolt image shot is clear and complete, and there is no obvious distortion.
[0074] In some embodiments, in order to extract features from the image, the image often needs to be pre-processed to meet the requirements of subsequent algorithms. Due to the random placement of the bolt, the angle between the bolt and the camera is not necessarily directly below, so the bolt image may have a certain degree of shape change, and the image needs to be corrected. In order to solve the perspective deformation, the image of the outer thread area of the bolt needs to be geometrically transformed. Perspective transformation can correct the deformed image and project it onto a new view plane. Equation (1) is the formula for image perspective transformation.
[0075]
[0076] In the formula, hj=[uj, vj, 1] represents a pixel point coordinate of the original image; hi=[ui, vi, 1] represents the coordinate of the corresponding pixel point after perspective transformation; T is the perspective transformation matrix. According to formula (2), the transformation matrix T can be calculated as follows by knowing four corresponding points before and after transformation and letting a33=0.
[0077]
[0078] In some embodiments, for the thread profile feature extraction of the bolt, the purpose of this step is to identify the bolt thread area from the image and obtain the edge profile of the bolt thread, and finally extract the bolt thread edge profile for size calculation. First, the image is denoised by using a bilateral filter. Bilateral filtering is a nonlinear filtering method that can consider both spatial proximity and pixel value similarity of the image, achieving the effect of edge-preserving denoising. Then, after denoising, the image is binarized and the gradient of the image is calculated. The first-order gradient template of the Sobel operator is used to calculate the gradient amplitude of the image, and it is extended to the first-order gradient template in four directions, i.e., horizontal, vertical, 45° and 135°. The first-order gradient components G x (x,y), G y (x,y), G 45 (x,y) and G 135 (x,y) are obtained by convolution with the convolution kernel. The gradient amplitude and gradient angle can be obtained from the four-direction first-order gradient components. Equation (3) is the gradient amplitude formula, and equation (4) is the gradient angle formula.
[0079]
[0080]
[0081] Finally, the gradient image is subjected to a non-maximum suppression operation, and then the Otsu algorithm is used to segment the threshold, and the image is classified into target and background using the gray scale information of the image.
[0082] In some embodiments, for the angle point detection of the thread profile, the embodiments of the present application use an optimized improved DP (Dynamic Programming) algorithm to segment the thread profile according to its geometric characteristics into straight lines and circular arcs, then use Hough transformation to fit the profile segments to obtain a smooth profile, remove quantization noise and local details, and finally use an optimized FRPD (fast corner detection based on the ratio of parallelogram diagonals) algorithm to estimate the curvature and detect the angle points.
[0083] In some embodiments, for the optimized improved DP algorithm, since the existing DP algorithm adopts a recursive idea, it approximates the contour by broken lines, and the contour of the curved part is over-segmented, therefore, the DP algorithm is optimized and improved: ①Adopt adaptive sampling method: according to the curvature change of the contour, automatically adjust the interval of the sampling points, so that the interval of the sampling points is larger in the place where the curvature change of the contour is small, and the interval of the sampling points is smaller in the place where the curvature change of the contour is larger. In this way, the accuracy can be guaranteed while the number of sampling points is reduced, and the algorithm efficiency is improved. The adaptive sampling method can adaptively adjust the number and position of the sampling points according to the curvature and shape of the contour, so as to realize more accurate and efficient contour description. Specifically, the following steps are adopted to realize the adaptive sampling method: 1) Calculate the curvature: for each sampling point on the contour, the curvature of the point can be obtained by calculating the position and curvature of several points before and after the point. The curvature can reflect the bending degree and shape characteristics of the contour, so it can be used to control the number and position of the sampling points. 2) Determine the sampling density: according to the change of the curvature, the sampling density of the contour can be determined. Generally speaking, if the curvature changes greatly in a certain region, the density of the sampling points in this region needs to be increased; if the curvature changes little in a certain region, the density of the sampling points in this region can be reduced. 3) Adjust the sampling points: according to the change of the sampling density, the sampling points of the contour can be adjusted. For the region where the sampling density needs to be increased, new sampling points can be inserted in this region; for the region where the sampling density needs to be reduced, some sampling points can be deleted, so as to reduce the number of sampling points. The adaptive sampling method can adaptively adjust according to the characteristics of the contour, so as to realize more accurate and efficient contour description. This method can avoid over-segmentation and under-segmentation, while reducing the number of sampling points and improving the calculation efficiency. ②Avoid over-segmentation based on curvature: adjust the position of the segmentation point based on the change of the curvature during the segmentation process. Specifically, calculate the curvature of the contour at each sampling point, and take the points with large curvature change as the segmentation points, so as to avoid over-segmentation in the curved part. The curvature-based method can adjust the position of the segmentation point by calculating the curvature of the contour at each sampling point, so as to avoid over-segmentation in the curved part. Specifically, the following steps can be adopted to realize the curvature-based method: 1) Calculate the curvature: for each sampling point on the contour, the curvature of the point can be obtained by calculating the position and curvature of several points before and after the point. The method of calculating the curvature adopts numerical differentiation method. 2) Judge the segmentation point: according to the change of the curvature, judge which points need to be segmented and which points can be combined. Generally speaking, if the curvature changes greatly between two adjacent points, the two points need to be segmented; if the curvature changes little between two adjacent points, the two points can be combined. 3) Adjust the segmentation point: according to the judgment result, the segmentation point of the contour can be adjusted.For the points needing to be segmented, a new sampling point is inserted at the point to realize segmentation; for the points that can be merged, the two points are merged into one point to reduce the number of segmented points. The curvature-based method can effectively avoid over-segmentation in curved parts, thereby improving the accuracy and efficiency of contour segmentation.
[0084] In some embodiments, for the optimized FRPD algorithm to estimate the curvature detection corner point, the FRPD algorithm estimates the curvature value by using the ratio of the diagonals of the parallelogram, the FRPD algorithm does not need square root operation, greatly reduces the calculation complexity, and the algorithm has the highest average repetition rate under the same image data set, is more accurate in positioning, has excellent corner point detection performance, the corner point detection speed is about 3 times that of the CTAR algorithm, and has good robustness to noise. However, this method may be affected by the direction of the curve when calculating the curvature value, so direction estimation and correction are needed to improve the accuracy of the curvature value. The present application optimizes the method based on the accumulator, counts the main direction of the curve by voting the chords in different directions on the curve, and rotates the curve to align the main direction with the horizontal direction to further improve the accuracy and robustness of feature detection.
[0085] In some embodiments, for the calculation of the major diameter and minor diameter of the screw thread of the bolt, the detected corner points are fitted by least squares transformation to obtain the imaginary cylindrical generatrix at the positions of the major diameter and the minor diameter, and the high-precision and real-time detection of the bolt size is realized by calculating the distance between the two straight lines.
[0086] In some embodiments, the bolt model quality classification can also be included, the bolt size measured by the above method is compared with the standard qualified size, and automatic measurement, model classification and quality control of the nut size can be realized. By judging the model, quality, new and old, and bad degree of the bolt, different bolts are quickly classified and processed by the mechanical hand. Therefore, the method can be quickly deployed to a digital intelligent manufacturing and operation factory to realize the rapid identification and classification of bolts in mechanical system production and operation.
[0087] Based on this, the thread edge contour area of the bolt is identified from the image; feature extraction is performed on the thread edge contour area to obtain the thread contour of the bolt, the improved and optimized DP algorithm is used to adaptively smooth the contour, and on this basis, the optimized FRPD algorithm is used to detect the corner point, the least square method transformation is used to fit the detected corner point to obtain the imaginary cylindrical generatrix at the large diameter and small diameter positions, and high-precision and real-time detection and model quality classification of the bolt size are realized through the calculation and measurement of the distance of the two straight lines. Based on this, the bolt size measurement method of the embodiment of the application has high measurement accuracy, accuracy and real-time performance, and can be used for the detection of bolt part size in the field of mechanical equipment manufacturing, thereby providing important technical support for the field. Compared with the existing detection method, the improved DP algorithm and the optimized FRPD corner point detection algorithm are used to realize fast and accurate measurement of the bolt size, meet the real-time requirement, have faster detection speed, higher detection accuracy and better robustness.
[0088] Please refer to Figure 2 In some embodiments, after step S102, steps S201 to S202 can also be included, but are not limited to:
[0089] Step S201, image transmission transformation is performed on the thread edge contour area to obtain a transformation matrix;
[0090] Step S202, image correction is performed on the thread edge contour area according to the transformation matrix.
[0091] In some embodiments, image transmission transformation is performed on the thread edge contour area to obtain a transformation matrix, and then image correction is performed on the thread edge contour area according to the transformation matrix, so as to ensure that the bolt image captured is clear and complete, and there is no obvious distortion.
[0092] Please refer to Figure 3 In some embodiments, step S103 can include steps S301 to S305, but is not limited to:
[0093] Step S301, a bilateral filter is used to perform noise reduction processing on the image;
[0094] Step S302, the image after the noise reduction processing is subjected to binaryzation processing, and the gradient amplitude and gradient angle of the image are calculated;
[0095] Step S303, the image is subjected to non-maximum suppression processing according to the gradient amplitude and gradient angle to obtain the threshold value and gray scale information of the image;
[0096] Step S304, the threshold value of the image is segmented using the Otsu algorithm;
[0097] Step S305, using the gray scale information of the image to classify the image into target and background, wherein the target is the thread profile of the bolt.
[0098] In some embodiments, the bolt thread area is identified from the image, and the edge profile of the bolt thread is obtained, and finally the thread edge profile of the bolt is extracted for size calculation. First, the image is denoised, and a bilateral filter is used for processing. Bilateral filtering is a nonlinear filtering method that can consider both spatial proximity and pixel value similarity of the image, achieving the effect of edge-preserving denoising. Then, the image is binarized after denoising, and the gradient of the image is calculated. The first-order gradient template of the Sobel operator is used to calculate the gradient amplitude of the image, and it is extended to the first-order gradient template in four directions, i.e., horizontal, vertical, 45° and 135°. The first-order gradient components G x (x,y)、G y (x,y)、G 45 (x,y) and G 135 (x,y) are obtained by convolution with the convolution kernel. The gradient amplitude and gradient angle can be obtained from the four-direction first-order gradient components. Equation (3) is the gradient amplitude formula, and equation (4) is the gradient angle formula.
[0099]
[0100]
[0101] Finally, the gradient image is subjected to a non-maximum suppression operation, and then the Otsu algorithm is used to segment the threshold. Using the gray scale information of the image, the image is classified into target and background.
[0102] Please refer to Figure 4 In some embodiments, step S104 can include but is not limited to steps S401 to S406:
[0103] Step S401, using the improved adaptive DP algorithm to segment the thread profile into straight lines and circular arcs according to its geometric characteristics;
[0104] Step S402, adaptively adjusting the number and position of the sampling points according to the curvature characteristics and shape characteristics of the thread profile;
[0105] Step S403, for each sampling point on the thread profile, the curvature change of the sampling point is obtained by calculating the positions and curvatures of a plurality of sampling points before and after the sampling point;
[0106] Step S404, determining the sampling density of the thread profile according to the curvature change;
[0107] Step S405, adjusting the sampling points of the thread profile according to the change of the sampling density;
[0108] Step S406, segmenting the thread profile according to the sampling points.
[0109] In some embodiments, the thread profile is segmented into straight lines and circular arcs according to its geometric features using an optimized improved DP algorithm, then the profile segments are fitted using Hough transform to obtain a smooth profile, and the quantization noise and local details are removed, and finally the curvature is estimated and the corner points are detected using an optimized FRPD algorithm. For the optimized improved DP algorithm, since the existing DP algorithm uses a recursive idea, it approximates the profile by a polyline segment, and the profile of the curved part is over-segmented. Therefore, the adaptive sampling method is used to optimize and improve the DP algorithm: according to the curvature change of the profile, the spacing of the sampling points is automatically adjusted, so that the spacing of the sampling points is larger in the place where the curvature of the profile changes little, and the spacing of the sampling points is smaller in the place where the curvature changes greatly. In this way, the precision can be guaranteed while reducing the number of sampling points and improving the algorithm efficiency. The adaptive sampling method can adaptively adjust the number and position of the sampling points according to the curvature and shape of the profile, so as to realize more accurate and efficient profile description. Specifically, the following steps are used to realize the adaptive sampling method: 1) calculating the curvature: for each sampling point on the profile, the curvature of the point can be obtained by calculating the position and curvature of several points before and after the point. The curvature can reflect the bending degree and shape feature of the profile, so it can be used to control the number and position of the sampling points. 2) determining the sampling density: according to the change of the curvature, the sampling density of the profile can be determined. Generally, if the curvature changes greatly in a certain region, the density of the sampling points in that region needs to be increased; if the curvature changes little in a certain region, the density of the sampling points in that region can be reduced. 3) adjusting the sampling points: according to the change of the sampling density, the sampling points of the profile can be adjusted. For the region where the sampling density needs to be increased, new sampling points can be inserted in that region; for the region where the sampling density needs to be reduced, some sampling points can be deleted, so as to reduce the number of sampling points. The adaptive sampling method can adaptively adjust according to the features of the profile, so as to realize more accurate and efficient profile description. This method can avoid over-segmentation and under-segmentation, and at the same time can reduce the number of sampling points and improve the calculation efficiency.
[0110] Please refer to Figure 5 In some embodiments, step S405 can include but is not limited to steps S501 to S502:
[0111] Step S501, in the segmentation process, the position of the segmentation point is adjusted based on the change of the curvature, for the region determined to need to increase the sampling density, a new sampling point is inserted in the region, for the region determined to need to reduce the sampling density, some sampling points are deleted;
[0112] Step S502, the position of the segmentation point is adjusted based on the curvature method by calculating the curvature of the thread profile at each sampling point.
[0113] In some embodiments, the curvature-based method avoids over-segmentation, in the segmentation process, the position of the segmentation point is adjusted based on the change of the curvature. Specifically, the curvature of the profile at each sampling point is calculated, and the point with large curvature change is taken as the segmentation point, so as to avoid the case of over-segmentation in the curved part. The curvature-based method can adjust the position of the segmentation point by calculating the curvature of the profile at each sampling point, so as to avoid the case of over-segmentation in the curved part.
[0114] Please refer to Figure 6 In some embodiments, step S502 can include but is not limited to steps S601 to S604:
[0115] Step S601, for each sampling point on the thread profile, the curvature of the sampling point is obtained by calculating the positions and curvatures of several points before and after the sampling point through numerical differentiation method;
[0116] Step S602, determine the sampling points needing segmentation and the sampling points needing merging according to the change of the curvature;
[0117] Step S603, if the change of the curvature between two adjacent sampling points exceeds a preset threshold, it is determined that the two adjacent sampling points need to be segmented, and a new sampling point is inserted between the two adjacent sampling points;
[0118] Step S604, if the change of the curvature between two adjacent sampling points does not exceed the preset threshold, it is determined that the two adjacent sampling points need to be merged, and the two adjacent sampling points are merged into one sampling point.
[0119] In some embodiments, the following steps can be taken to implement the curvature-based method to adjust the positions of the segmentation points by calculating the curvature of the thread profile at each sampling point: 1) Calculate the curvature: For each sampling point on the profile, the curvature of the point can be obtained by calculating the positions and curvatures of several points before and after it. The method of calculating the curvature uses numerical differentiation. 2) Determine the segmentation points: According to the change of curvature, determine which points need to be segmented and which points can be merged. Generally speaking, if the curvature changes greatly between two adjacent points, the two points need to be segmented; if the curvature changes little between two adjacent points, the two points can be merged. 3) Adjust the segmentation points: According to the judgment result, the segmentation points of the profile can be adjusted. For points that need to be segmented, a new sampling point is inserted at the point to achieve segmentation; for points that can be merged, the two points are merged into one point to reduce the number of segmentation points. The curvature-based method can effectively avoid over-segmentation in curved parts, thereby improving the accuracy and efficiency of profile segmentation.
[0120] Referring to Figure 7 In some embodiments, after step S107, steps S701-S702 can be further included, but are not limited to:
[0121] Step S701, compare the sizes of the major diameter and minor diameter of the thread of the bolt with the preset standard qualified sizes respectively to obtain a comparison result;
[0122] Step S702, classify the bolt by type and quality based on the comparison result.
[0123] In some embodiments, the sizes of the major diameter and minor diameter of the thread of the bolt are compared with the preset standard qualified sizes respectively to obtain a comparison result, and the bolt is classified by type and quality based on the comparison result. By judging the type, quality, new or old, and bad degree of the bolt, the mechanical hand can quickly classify and process different bolts. Therefore, the method can be quickly deployed in a digital intelligent manufacturing and operation factory to realize the rapid identification and classification of bolts in mechanical system production and operation.
[0124] In summary, the embodiment of the present application processes the image of the bolt, combines bilateral filtering, Sobel operator to calculate the gradient amplitude of the image and Otsu algorithm to segment the threshold to obtain the accurate contour feature image of the thread, uses the improved and optimized DP algorithm to adaptively smooth the contour, and on this basis, uses the optimized FRPD algorithm to detect the corner point, uses the least square method transformation to fit the detected corner point to obtain the imaginary cylindrical generatrix at the large diameter and small diameter positions, and realizes the high-precision and real-time detection of the bolt size and the model quality classification through the calculation of the distance of the two straight lines. The method has high measurement accuracy, accuracy and real-time performance, and can be used for the detection of the size of the bolt part in the field of mechanical equipment manufacturing, and provides important technical support for the field.
[0125] Please refer to Figure 8 The embodiment of the present application also provides a bolt size measuring device, which can realize the bolt size measuring method described above, and the device comprises:
[0126] The calibration module 810 is configured to calibrate the camera for shooting the bolt.
[0127] The recognition module 820 is configured to acquire the image of the bolt shot by the camera, and identify the thread edge contour area of the bolt from the image.
[0128] The extraction module 830 is configured to perform feature extraction on the thread edge contour area to obtain the thread contour of the bolt.
[0129] The segmentation module 840 is configured to segment the thread contour by using the improved adaptive DP algorithm to obtain a plurality of contour segments.
[0130] The fitting module 850 is configured to use Hough transformation to fit the contour segments to obtain a smooth thread contour.
[0131] The detection module 860 is configured to detect the corner point corresponding to the curvature of the smooth thread contour based on the optimized FRPD algorithm.
[0132] The calculation module 870 is configured to use the least square method transformation to fit the corner point to calculate the size of the large diameter and the small diameter of the thread of the bolt.
[0133] Based on this, the bolt size measuring device of the embodiment of the application, the calibration module 810 calibrates the camera for shooting the bolt; the recognition module 820 obtains the image of the bolt shot by the camera, and recognizes the thread edge contour area of the bolt from the image; the extraction module 830 extracts the features of the thread edge contour area to obtain the thread contour of the bolt; the segmentation module 840 segments the thread contour by using the improved adaptive DP algorithm to obtain a plurality of contour segments; the fitting module 850 fits the contour segments by using the Hough transform to obtain a smooth thread contour; the detection module 860 detects the corner points of the curvature corresponding to the smooth thread contour based on the optimized FRPD algorithm; and the calculation module 870 fits the corner points by using the least square method to calculate the size of the major diameter and the minor diameter of the thread of the bolt. Based on this, the camera for shooting the bolt is calibrated; the image of the bolt shot by the camera is obtained, and the thread edge contour area of the bolt is recognized from the image; the features of the thread edge contour area are extracted to obtain the thread contour of the bolt; the thread contour is segmented by using the improved adaptive DP algorithm to obtain a plurality of contour segments; the contour segments are fitted by using the Hough transform to obtain a smooth thread contour; the corner points of the curvature corresponding to the smooth thread contour are detected based on the optimized FRPD algorithm; and the corner points are fitted by using the least square method to calculate the size of the major diameter and the minor diameter of the thread of the bolt. Based on this, the thread edge contour area of the bolt is recognized from the image; the features of the thread edge contour area are extracted to obtain the thread contour of the bolt, the improved and optimized DP algorithm is used to adaptively smooth the contour, and the corner points are detected based on the optimized FRPD algorithm, the detected corner points are fitted by using the least square method, the imaginary cylindrical generatrix at the positions of the major diameter and the minor diameter is obtained, the high-precision and real-time detection of the bolt size is realized by calculating the distance between the two straight lines, and the model quality classification is realized. Based on this, the bolt size measuring method of the embodiment of the application has high measurement precision, accuracy and real-time performance, and can be used for the detection of the bolt size in the field of mechanical equipment manufacturing, thereby providing important technical support for the field.
[0134] The specific embodiments of the bolt size measuring device are basically the same as the specific embodiments of the bolt size measuring method described above, and will not be described herein again.
[0135] The embodiment of the application further provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor realizes the bolt size measuring method described above when executing the computer program. The electronic device can be any intelligent terminal, such as a tablet computer or a vehicle-mounted computer.
[0136] Please refer to Figure 9 , Figure 9 The hardware structure of the electronic device of another embodiment is illustrated, which comprises:
[0137] The processor 901 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute related programs to implement the technical solutions provided by the embodiments of the present application.
[0138] The memory 902 can be implemented by a ROM (ReadOnly Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory), and the like. The memory 902 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 902 and are called and executed by the processor 901 to implement the bolt size measurement method of the embodiments of the present application, that is, by calibrating the camera for shooting the bolt; obtaining an image of the bolt shot by the camera, identifying a thread edge contour area of the bolt from the image; performing feature extraction on the thread edge contour area to obtain a thread contour of the bolt; segmenting the thread contour by using an improved adaptive DP algorithm to obtain a plurality of contour segments; fitting the contour segments by using a Hough transform to obtain a smooth thread contour; detecting an angle point of the curvature corresponding to the smooth thread contour based on an optimized FRPD algorithm; and fitting the angle point by using a least square method transformation to calculate the size of the major diameter and the minor diameter of the thread of the bolt. Based on this, the thread edge contour area of the bolt is identified from the image; the feature extraction is performed on the thread edge contour area to obtain the thread contour of the bolt, the improved and optimized DP algorithm is used to adaptively smooth the contour, and the optimized FRPD algorithm is used to detect the angle point based on this, the least square method transformation is used to fit the detected angle point to obtain the imaginary cylindrical generatrix at the major diameter and the minor diameter positions, and the high-precision and real-time detection and model quality classification of the bolt size are realized by calculating the distance between the two straight lines. Based on this, the bolt size measurement method of the embodiments of the present application has high measurement precision, accuracy and real-time performance, and can be used for the detection of the size of the bolt part in the field of mechanical equipment manufacturing, and provides important technical support for the field.
[0139] The input / output interface 903 is configured to realize information input and output.
[0140] The communication interface 904 is configured to realize the communication interaction between the device and other devices, and can realize the communication through a wired manner (for example, a USB, a network cable, etc.) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, etc.).
[0141] A bus transmits information between various components (for example, the processor 901, the memory 902, the input / output interface 903, and the communication interface 904) of the device.
[0142] The processor 901, the memory 902, the input / output interface 903, and the communication interface 904 are communicatively connected to each other within the device through the bus.
[0143] The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the bolt size measurement method.
[0144] The memory is a non-transitory computer readable storage medium, and can be used to store a non-transitory software program and a non-transitory computer executable program. In addition, the memory can include a high-speed random access memory, and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and the remote memory can be connected to the processor through a network. Examples of the network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0145] The bolt size measurement method, the bolt size measurement device, the electronic device, and the storage medium provided by the embodiments of the present application calibrate the camera for shooting the bolt, obtain an image of the bolt shot by the camera, identify a thread edge contour region of the bolt from the image, extract features of the thread edge contour region to obtain a thread contour of the bolt, segment the thread contour by using an improved adaptive DP algorithm to obtain a plurality of contour segments, fit the contour segments by using a Hough transform to obtain a smooth thread contour, detect corner points of the curvature corresponding to the smooth thread contour based on an optimized FRPD algorithm, and fit the corner points by using a least square method transformation to calculate the size of the major diameter and the minor diameter of the thread of the bolt. Based on this, the thread edge contour region of the bolt is identified from the image, the features of the thread edge contour region are extracted to obtain the thread contour of the bolt, the improved and optimized DP algorithm is used to adaptively smooth the contour, and the optimized FRPD algorithm is used to detect the corner points on this basis, the detected corner points are fitted by using the least square method transformation, the imaginary cylindrical generatrix at the positions of the major diameter and the minor diameter is obtained, the high-precision and real-time detection of the bolt size and the model quality classification are realized by calculating the distance between the two straight lines. Based on this, the bolt size measurement method of the embodiments of the present application has high measurement precision, accuracy, and real-time performance, and can be used for the detection of the bolt part size in the field of mechanical equipment manufacturing, and provides important technical support for the field.
[0146] Those skilled in the art can understand that all or some of the steps in the method disclosed above can be implemented by software, firmware, hardware, and appropriate combinations thereof. Some or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software can be distributed on a computer readable medium, which can include computer storage media (or non-transitory media) and communication media (or transitory media). As known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable programs, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, as known to those skilled in the art, communication media generally includes computer readable programs, data structures, program modules or other data in modulated data signals such as carrier waves or other transmission mechanisms, and can include any information delivery medium.
[0147] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems as technology evolves and new application scenarios appear.
[0148] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than shown in the figures, or combine certain steps, or different steps.
[0149] The device embodiments described above are only schematic, and units described as separate components can or can not be physically separate, i.e. can be located in one place or distributed over multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0150] Those skilled in the art can understand that all or some of the steps in the method disclosed above, the functions of the modules / units in the system and the device can be implemented as software, firmware, hardware, and appropriate combinations thereof.
[0151] The terms "first", "second", "third", "fourth", and the like in the description and in the claims of this application, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of the terms so termed is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of orderly or chronological mundane operation, reverse order operation, based on completion of some desired or other convenient events, or based on other modification that can be wished to those with average skill in the art. Additionally, the terms "comprising", "having", "including", and "containing" are to be construed as open-ended terms (i.e., meaning "including, but not limited to", "comprising, but not limited to", "having, but not limited to", or "including, but not limited to") unless otherwise noted. Recitation of ranges of values herein are merely intended to serve as a shorthand method of referring individually to each separate value falling within the range, unless otherwise indicated herein and each separate value is incorporated into the specification as if it were individually recited herein. The use of any of the following terms "coupled", "connected", or "communicatively coupled", means the elements so connected are electrically or otherwise directly connected without any additional intervening elements. The use of any of the following terms "in communication with", "in connection with", or "in communication therewith", means the elements so connected are electrically or otherwise directly connected without any additional intervening elements.
[0152] It should be understood that, in this application, "at least one", means one or more, "multiple" means two or more. "And / or", used to describe the relationship between associated objects, means that there can be three relationships, for example, "A and / or B" can mean: only A, only B, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally represents that the associated objects before and after are "or" relationship. "At least one of the following" or similar expressions means any combination of these items, including single or multiple items. For example, at least one of a, b or c, can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0153] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the above-described device embodiments are only illustrative, for example, the division of the above-mentioned units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0154] The units described above as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0155] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0156] When the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in the form of a contribution to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods in the embodiments of the present application. The foregoing storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0157] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and are not intended to limit the scope of the embodiments of the present application. Any modification, equivalent replacement, and improvement made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.
Claims
1. A method for measuring bolt dimensions, characterized in that, The method includes: Calibrate the camera used to photograph bolts; The camera captures an image of the bolt, and the bolt's thread edge contour region is identified from the image. Feature extraction is performed on the thread edge contour region to obtain the thread contour of the bolt; The thread profile is segmented using an improved adaptive dynamic programming (DP) algorithm to obtain multiple profile segments. The segmentation of the thread profile using the improved adaptive DP algorithm includes: using the improved adaptive DP algorithm to segment the thread profile into straight lines and arcs according to its geometric features; adaptively adjusting the number and position of sampling points based on the curvature and shape features of the thread profile; for each sampling point on the thread profile, calculating the change in curvature of the sampling point by considering the position and curvature of several sampling points before and after the sampling point; determining the sampling density of the thread profile based on the change in curvature; adjusting the sampling points of the thread profile based on the change in sampling density; and segmenting the thread profile based on the sampling points. The adjustment of the sampling points of the thread profile based on the change in sampling density includes: in... During the segmentation process, the positions of the segmentation points are adjusted based on changes in curvature. For regions where sampling density needs to be increased, new sampling points are inserted within these regions; for regions where sampling density needs to be decreased, some sampling points are deleted. For each sampling point on the thread profile, the curvature of the sampling point is obtained by calculating the positions and curvatures of several points before and after each sampling point using numerical differentiation. Based on the changes in curvature, sampling points that need to be segmented and sampling points that need to be merged are determined. If the change in curvature between two adjacent sampling points exceeds a preset threshold, it is determined that these two adjacent sampling points need to be segmented, and a new sampling point is inserted between them. If the change in curvature between two adjacent sampling points does not exceed the preset threshold, it is determined that these two adjacent sampling points need to be merged, and these two adjacent sampling points are merged into one sampling point. The Hough transform is used to fit the contour segment to obtain a smooth thread contour. The optimized FRPD algorithm is used to detect the corner points of the curvature corresponding to the smooth thread profile. The FRPD algorithm estimates the curvature value by using the ratio of the diagonals of a parallelogram. The corner points are fitted using the least squares method to calculate the major and minor diameters of the bolt thread.
2. The method according to claim 1, characterized in that, After acquiring an image of the bolt captured by the camera and identifying the threaded edge contour region of the bolt from the image, the method further includes: Perform image transmission transformation on the thread edge contour region to obtain the transformation matrix; The image of the thread edge contour region is corrected according to the transformation matrix.
3. The method according to claim 1, characterized in that, The step of extracting features from the thread edge contour region to obtain the thread contour of the bolt includes: The image is denoised using a bilateral filter; The image after noise reduction is binarized, and the gradient magnitude and gradient angle of the image are calculated. Non-maximum suppression processing is performed on the image based on the gradient magnitude and the gradient angle to obtain the threshold and grayscale information of the image; The image is segmented using the Otsu algorithm based on a threshold. The image is classified into target and background using grayscale information, wherein the target is the thread profile of the bolt.
4. The method according to any one of claims 1 to 3, characterized in that, After performing a least-squares transformation on the corner points to fit the data and calculate the major and minor diameters of the bolt thread, the method further includes: The major and minor diameters of the bolt threads are compared with preset standard qualified dimensions to obtain the comparison results. Based on the comparison results, the bolts are classified by model and quality.
5. A bolt size measuring device, characterized in that, The device includes: The calibration module is used to calibrate the camera used to photograph bolts; The recognition module is used to acquire an image of the bolt captured by the camera and to identify the thread edge contour region of the bolt from the image; The extraction module is used to extract features from the thread edge contour region to obtain the thread contour of the bolt. A segmentation module is used to segment the thread profile using an improved adaptive dynamic programming (DP) algorithm to obtain multiple profile segments. The segmentation of the thread profile using the improved adaptive DP algorithm includes: using the improved adaptive DP algorithm to segment the thread profile into straight lines and arcs according to its geometric features; adaptively adjusting the number and position of sampling points based on the curvature and shape features of the thread profile; for each sampling point on the thread profile, calculating the change in curvature of the sampling point by considering the positions and curvatures of several sampling points before and after the sampling point; determining the sampling density of the thread profile based on the change in curvature; adjusting the sampling points of the thread profile based on the change in sampling density; and segmenting the thread profile based on the sampling points. The step of adjusting the sampling points of the thread profile based on the change in sampling density includes... In the segmentation process, the positions of the segmentation points are adjusted based on changes in curvature. For regions where sampling density needs to be increased, new sampling points are inserted within those regions; for regions where sampling density needs to be reduced, some sampling points are deleted. For each sampling point on the thread profile, the curvature of the sampling point is obtained by calculating the positions and curvatures of several points before and after each sampling point using numerical differentiation. Based on the changes in curvature, sampling points that need to be segmented and those that need to be merged are determined. If the change in curvature between two adjacent sampling points exceeds a preset threshold, it is determined that these two adjacent sampling points need to be segmented, and a new sampling point is inserted between them. If the change in curvature between two adjacent sampling points does not exceed the preset threshold, it is determined that these two adjacent sampling points need to be merged, and they are merged into one sampling point. The fitting module is used to fit the contour segment using the Hough transform to obtain a smooth thread contour. The detection module is used to detect the corner points corresponding to the curvature of the smooth thread profile based on the optimized FRPD algorithm. The FRPD algorithm estimates the curvature value by using the ratio of the diagonals of a parallelogram. The calculation module is used to fit the corner points using the least squares transformation to calculate the major and minor diameters of the bolt thread.
6. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the bolt size measurement method according to any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the bolt size measurement method according to any one of claims 1 to 4.