Image-based Sub-pixel High-precision Two-dimensional Dimension Online Measurement Method and System
Through the image-based high-precision two-dimensional dimension online measurement method, combined with image correction and edge detection technology, the problem of high-precision online measurement is solved, and efficient and low-cost two-dimensional dimension detection is achieved.
Patent Information
- Application Number
- CN202510192613.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-02-21
AI Technical Summary
现有在线测量技术在高精度要求下成本高,低分辨率测量精度不足,难以实现高效、低成本的二维尺寸检测。
The image-based high-precision two-dimensional dimension online measurement method is adopted, and the image correction, edge detection and corrosion treatment is combined with the Canny edge detection algorithm and the Zernike moment subpixel edge detection to achieve high-precision measurement of part images.
It realizes high-precision measurement at the micron level, reduces hardware costs, improves detection efficiency and automation, and meets the real-time inspection needs of industrial production.
Smart Images

Figure CN119665861B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of workpiece online measurement, and in particular to an image-based sub-pixel-level high-precision two-dimensional dimension online measurement method and system. Background Art
[0002] In modern manufacturing, the dimensional accuracy of parts is one of the important indicators for measuring product quality. Especially in high-precision industries such as aerospace, automobile manufacturing, and electronic products, the dimensional control of parts directly affects the assembly accuracy and final performance of the product. Traditional dimensional measurement methods mainly rely on manual use of measuring tools, such as vernier calipers, micrometers, etc. This method is not only time-consuming and labor-intensive, but also has certain human errors. In order to improve measurement efficiency and accuracy, online measurement technology has gradually received attention. As one of them, two-dimensional dimension online measurement technology can measure and control the two-dimensional dimensions of parts in real time on the production line. Compared with traditional measurement methods, online measurement technology has the following advantages: 1. High efficiency, it can detect part dimensions in real time during the production process, greatly improving the detection efficiency. 2. High precision, by using high-precision optical measuring equipment, high-precision dimension detection at the micron level can be achieved. 3. Automation, the online measurement system can be integrated into the automated production line, reducing manual intervention, human errors and labor costs.
[0003] However, high-precision online measurement also places corresponding requirements on the high resolution of the imaging equipment. While improving the online measurement accuracy, it also often increases the cost of the measurement system, and the requirements for hardware cannot be ignored. Similarly, low-resolution measurement systems have lower costs, but their measurement accuracy is inevitably greatly reduced. Summary of the invention
[0004] The present invention provides an image-based sub-pixel-level high-precision two-dimensional dimension online measurement method and system to solve the technical problems mentioned in the background technology.
[0005] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0006] The present invention provides an image-based sub-pixel-level high-precision two-dimensional dimension online measurement method, comprising the following steps:
[0007] S1, collecting input part images, and performing denoising and binarization processing on the collected part images;
[0008] S2. Using an image correction method based on Hough edge detection to correct the binarized part image, the longest straight edge of the target in the part image is rotated to the horizontal direction, so as to straighten the part image and obtain a corrected part image;
[0009] S3. Successively use the Canny edge detection algorithm and the Zernike moment sub-pixel edge detection method to perform edge detection on the corrected part image in S2. The detection result is several edge line segments. According to the size of the part, group the line segments by different slopes and intercepts, and each group represents a straight edge of the part;
[0010] S4. Combine the line segments in each group into a straight line , and take the slopes and intercepts of all the line segments in each group and to obtain the average values
[0011] as the slope and intercept of the straight line; S5. Obtain the intersection coordinates of all the combined straight lines , erode the binarized part image in S1, filter out the point coordinates outside the black area of the eroded image, and obtain the new intersection coordinates . These intersection coordinates serve as the two endpoints of the edge straight line, and connect a straight line between the two endpoints . The straight line
[0012] is the contour edge straight line of the part;
[0013] Further, the specific steps of S1 are as follows:
[0014] S11. Place the part to be measured on the stage of the measuring device, and then collect the input part image through a telecentric camera;
[0015] S12. Denoise the collected part image, then obtain the binarization threshold through the binarization threshold selection formula, and perform binarization processing on the denoised part image using the binarization threshold; all pixels are divided into two categories, C1 and C2, through binarization processing;
[0016] Among them, the binarization threshold selection formula is specifically as follows:
[0017] ;
[0018] ;
[0019] ;
[0020] ;
[0021] , ;
[0022] In the formula, is the global mean; represents the binarization gray threshold; is at the pixel level of the part image, and its value ranges from 0 to 255; represents the between-class variance; and respectively represent the probabilities of the pixel values C1 and C2 occurring; represents the binarization gray threshold of the cumulative mean; and are respectively the means of the two types of pixels C1 and C2; represents the pixel value appearing probability.
[0023] Furthermore, the S2 specifically includes the following steps:
[0024] S21. First, use the Hough line detection method to detect the edge contour of the part image to obtain several line segments; then calculate the slopes of the several line segments;
[0025] S22. The slopes of the line segments on the same edge are the same. Select the slope value with the largest number of line segments , and the edge with the largest number of line segments is the target longest straight edge; calculate the angle between the line segment with the slope value of and the horizontal direction of the image coordinate axis . The specific calculation formula of the angle
[0026] ;
[0027] The absolute value of the angle , that is, is the rotation angle of the image. If , the rotation direction is clockwise: if , the rotation direction is counterclockwise;
[0028] S23. Rotate the target longest straight edge in the part image to the horizontal direction according to the angle to straighten the part image; obtain the corrected part image.
[0029] Furthermore, the S3 specifically includes the following steps:
[0030] S31. The Canny edge detection algorithm detects the edge of the part image by setting high and low thresholds; and uses non-maximum suppression to process the part image; among them, the specific calculation formulas of the high and low thresholds are as follows:
[0031] ;
[0032] wherein is the high threshold, i.e., the optimal segmentation threshold; is the low threshold, and points higher than the high threshold are considered edge points. At the same time, points lower than the low threshold are not considered edge points;
[0033] S32. Then, perform edge detection on the part image after non-maximum suppression processing through the Zernike moment sub-pixel edge detection method to obtain multiple sub-pixel edge coordinates. Then, connect the multiple sub-pixel edge coordinates according to the contour of the part to obtain the detection result, i.e., several edge segments;
[0034] S33. Group the line segments according to different slopes and intercepts according to the size of the part, and each group represents a straight edge of the part.
[0035] Furthermore, the S32 specifically includes the following steps:
[0036] S321. Represent the coordinate points in the part image after non-maximum suppression processing through the Zernike moment of order n and degree m;
[0037] S322. Then rotate the part image after non-maximum suppression processing by an angle , and the rotated Zernike moment is ;
[0038] S323. Calculate the Zernike moments of different orders according to the rotational invariance of the moments;
[0039] S324. Substitute the Zernike moments of different orders into the sub-pixel edge coordinate derivation formula to obtain the sub-pixel edge coordinate values corresponding to the coordinate points ;
[0040] S325. Loop S321 to S324 until the loop count reaches the set number of times to obtain multiple sub-pixel edge coordinates;
[0041] S326. Then connect the multiple sub-pixel edge coordinates according to the contour of the part to obtain the detection result, i.e., several edge segments.
[0042] Furthermore, the order degree Zernike moment in S321 is represented as follows:
[0043] ;
[0044] wherein , are both integers and satisfy , is even and ; is the conjugate complex number on the polar coordinates, is the orthogonal polynomial on the polar coordinates, is the coordinate point in polar coordinates, is the vector length between the origin and the coordinate point , is the angle between this vector and the counterclockwise direction of the x-axis.
[0045] Further, the derivation formula of the sub-pixel edge coordinates in the S324 is specifically as follows:
[0046] ;
[0047] wherein, is the sub-pixel edge coordinate, represents the vertical distance from the origin to the ideal edge.
[0048] Further, the S5 specifically includes the following steps:
[0049] S51. Obtain the intersection coordinates of all synthetic lines ;
[0050] S52. Create a one-dimensional array with all elements being 1 as the convolution kernel for the erosion process. The value range of the array is 0 to 255, and then set the number of iterations of the erosion operation; and perform multiple rounds of erosion on the binary-processed part image in S1; the erosion operation can be expressed as:
[0051] ;
[0052] wherein, Structure A represents the image, and Structure B represents the convolution kernel;
[0053] S53. Traverse the intersection coordinates , and judge whether the coordinate is located in the black area of the eroded image, and retain the point coordinates within this area as ;
[0054] S54. Traverse the point coordinates , select two intersection coordinates on the same synthetic line from S4, use these two intersection coordinates as the two endpoints of the line, and connect a line between the two endpoints. The line is the contour edge line of the part.
[0055] Further, the following steps are also included between S5 and S7:
[0056] S6. Use the Hough transform method to detect the circular contour of the part, and draw the contour of the circular hole of the part. The straight line of the contour edge of the part and the contour of the circular hole of the part constitute the contour of the part.
[0057] Further, the S6 specifically includes the following steps:
[0058] S61. Approximate the contour obtained by polygon approximation Canny detection of the image, and initially screen out the contours that meet the preset conditions. The preset conditions are that the number of corner points of the contour needs to be greater than 10.
[0059] S62. Use the least squares method to fit the screened contour, approximate it to a circle, obtain the coordinates of the center of the circle (xp, yp) and the radius rp of the circle, and screen out the circles that meet the radius according to the set minimum radius and maximum radius.
[0060] S63. Perform sub-pixel positioning on the contour of the circular hole of the part according to the Zernike moment algorithm, and use the RANSAC algorithm for data fitting to remove the deviated points, so as to obtain the contour of the circular hole of the part; the straight line of the contour edge of the part and the contour of the circular hole of the part constitute the contour of the part.
[0061] On the other hand, the present invention also provides a sub-pixel-level high-precision two-dimensional dimension online measurement system, including a computer device, which is programmed or configured to execute the above sub-pixel-level high-precision two-dimensional dimension online measurement method;
[0062] Or, a computer program programmed or configured to execute the above sub-pixel-level high-precision two-dimensional dimension online measurement method is stored in the memory of the computer device.
[0063] The beneficial effects of the present invention:
[0064] 1. The present invention proposes a sub-pixel-level high-precision two-dimensional dimension online measurement method based on images, which solves the measurement problems of high resolution and high cost associated with existing high-precision measurements. The present invention uses part images to perform high-precision measurement of the two-dimensional dimensions of objects, making the measurement accuracy reach the micron level, realizing efficient, accurate, and automated detection of part dimensions during the production process, and providing strong support for quality control and production optimization in the manufacturing industry.
[0065] 2. The present invention realizes high-precision automated part detection in industrial production. At the same time, it does not require major modifications to the production line, saving unnecessary expenses. At the same time, the present invention does not require precision detection under a high-resolution imaging system, which also greatly reduces the hardware cost of the detection equipment;
[0066] 3. The present invention can ensure that the measurement accuracy meets the requirements of industrial inspection by means of a low-resolution imaging system. At the same time, the measurement speed of seconds also improves the efficiency of real-time inspection of product quality in industrial production, thus solving the problem of high efficiency and high cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 is a flow chart of the present invention;
[0068] Figure 2 This is an example diagram of a part image captured by a telecentric camera in the present invention;
[0069] Figure 3 It is a sub-pixel edge local fitting enlarged image of the example image of the part image in the embodiment of the invention;
[0070] Figure 4 This is an example diagram of measuring the contour of a part in an embodiment of the present invention;
[0071] Figure 5 The ideal model diagram for sub-pixel edge detection, where (a) represents the original edge image model; (b) is the rotated edge image model. DETAILED DESCRIPTION
[0072] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Preferred embodiments of the present invention are provided in the drawings. However, the present invention can be implemented in many other different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive.
[0073] Reference Figure 1 The present application embodiment provides an image-based sub-pixel-level high-precision two-dimensional dimension online measurement method, comprising the following steps:
[0074] S1, collecting input part images, and performing denoising and binarization processing on the collected part images;
[0075] S2. Using an image correction method based on Hough edge detection to correct the binarized part image, the longest straight edge of the target in the part image is rotated to the horizontal direction, so as to straighten the part image and obtain a corrected part image;
[0076] S3, using the Canny edge detection algorithm and the Zernike moment sub-pixel edge detection method in turn, to perform edge detection on the part image corrected in S2. The detection result is a number of edge line segments. According to the size of the part, the line segments are grouped according to different slopes and intercepts. Each group represents a straight line edge of the part.
[0077] S4. Combine the line segments in each group into a straight line , and obtain the slopes of all the line segments within each group and the intercepts of their average values and , and use them as the slope and intercept of the straight line;
[0078] S5. Obtain the intersection coordinates of all the combined straight lines , erode the binary-processed part image in S1, filter out the point coordinates outside the black area of the eroded image, and obtain the new intersection coordinates . Use these intersection coordinates as the two endpoints of the edge straight line, and connect a straight line between the two endpoints . The straight line is the contour edge straight line of the part;
[0079] S7. Measure the contour of the part to obtain measurement data.
[0080] In some embodiments, S1 specifically includes the following steps:
[0081] S11. Place the part to be measured on the stage of the measuring device, and then collect the input part image through a telecentric camera. For an example diagram of the part image, see Figure 2 ;
[0082] S12. Denoise the collected part image, then obtain the binary threshold through the binary threshold selection formula, and perform binary processing on the denoised part image using the binary threshold; all pixels are divided into two categories, C1 and C2, through binary processing;
[0083] The binary threshold selection formula is specifically as follows:
[0084] ;
[0085] ;
[0086] ;
[0087] ;
[0088] , ;
[0089] In the formula, is the global mean; represents the binary gray threshold; is the pixel level of the part image, and its value ranges from 0 to 255; represents the between-class variance; and Respectively represent the probability of occurrence of pixel values C1 and C2; Represents the binary grayscale threshold The cumulative mean of and are the mean values of pixels of categories C1 and C2 respectively; Represents pixel value Probability of occurrence.
[0090] The selected threshold All pixels are divided into two categories C1 and C2, C1 consists of pixels with gray levels in [0, k-1], and C2 consists of pixels with gray levels in [k, 255].
[0091] In some embodiments, S2 specifically includes the following steps:
[0092] S21. First, the edge contour of the part image is detected using the Hough line detection method to obtain a number of line segments; then the slopes of the line segments are calculated;
[0093] S22. If the slopes of the line segments on the same edge are the same, select the slope value with the largest number of line segments. , the edge with the largest number of line segments is the longest straight line edge of the target; the slope value is calculated as The angle between the line segment and the horizontal direction of the image coordinate axis , angle The calculation formula is as follows:
[0094] ;
[0095] Angle The absolute value of is the rotation angle of the image, if , the rotation direction is clockwise: If , the direction of rotation is counterclockwise;
[0096] S23, according to the angle The longest straight edge of the target in the part image is rotated to the horizontal direction to straighten the part image; thus, a corrected part image is obtained.
[0097] In some embodiments, S3 specifically includes the following steps:
[0098] S31, Canny edge detection algorithm detects the edge of the part image by setting high and low thresholds; and uses non-maximum suppression to process the part image; the calculation formulas of the high and low thresholds are as follows:
[0099] ;
[0100] in is the high threshold, i.e., the optimal segmentation threshold; is the low threshold;
[0101] Points higher than the high threshold are considered edge points. At the same time, points lower than the low threshold are not considered edge points; In discontinuous parts, if the points between and are near the edge points, they are regarded as edge points to smooth the edge.
[0102] S32. Then, edge detection is performed on the part image after non-maximum suppression processing by the Zernike moment sub-pixel edge detection method to obtain multiple sub-pixel edge coordinates. Then, according to the contour of the part, the multiple sub-pixel edge coordinates are connected to obtain the detection result, i.e., several edge segments;
[0103] S33. According to the size of the part, the line segments are grouped according to different slopes and intercepts, and each group represents a straight edge of the part.
[0104] In some embodiments, the S32 specifically includes the following steps:
[0105] S321. Represent the coordinate points in the part image after non-maximum suppression processing by order and degree Zernike moments; The representation by
[0106] order
[0107] and degree Zernike moments is specifically as follows: where , are all integers and satisfy , is an even number and ; is the conjugate complex number of in polar coordinates, is the orthogonal polynomial in polar coordinates, is the polar coordinate of the coordinate point , is the vector length between the origin and the coordinate point
[0108] S322. Then rotate the part image after non-maximum suppression processing by an angle . The rotated Zernike moment is ;
[0109] Refer to Figure 5 , where the straight line contained in the unit circle represents the ideal edge, and the gray values on both sides of the straight line are and , is the gray value difference, is the perpendicular distance from the origin to the ideal edge, is the angle between and the x-axis. The edge parameters can be determined by Zernike moments, that is, the function , , , , , and their corresponding integral kernel functions can be calculated from the polynomial definition of Zernike moments:
[0110] , , , , ;
[0111] S323. Calculate Zernike moments of different orders according to the rotation invariance of moments;
[0112] ;
[0113] From the above equations, can be calculated , , , , let . From equation it can be known that , where and are the real and imaginary parts of respectively, and the rotation angle can be calculated therefrom;
[0114] S324. Substitute Zernike moments of different orders into the sub-pixel edge coordinate derivation formula to obtain the sub-pixel edge coordinate values corresponding to the coordinate points ; The sub-pixel edge coordinate derivation formula in S324 is specifically as follows:
[0115] ;
[0116] Among them, is the sub-pixel edge coordinate, represents the perpendicular distance from the origin to the ideal edge.
[0117] Considering the template magnification effect, for the template of , the derivation formula can be corrected to:
[0118] ;
[0119] S325. Loop S321 to S324 until the number of loops reaches the set number, obtaining multiple sub-pixel edge coordinates;
[0120] S326. Then connect the multiple sub-pixel edge coordinates according to the contour of the part to obtain the detection result, that is, several edge line segments.
[0121] In some embodiments, the S5 specifically includes the following steps:
[0122] S51. Obtain the intersection coordinates of all synthetic straight lines ;
[0123] S52. Create a all-1 array as the convolution kernel for the erosion process. The value range of the array is 0 to 255, and then set the number of iterations of the erosion operation to 5 times; and perform multiple rounds of erosion on the binary-processed part image in S1; the erosion operation can be expressed as:
[0124] ;
[0125] Among them, structure A represents the image, and structure B represents the convolution kernel;
[0126] S53. Traverse the intersection coordinates , and judge whether the coordinate is located in the black area of the eroded image. Keep the point coordinates within this area as ;
[0127] S54. Traverse the point coordinates , select two intersection coordinates on the same synthetic straight line from S4, connect a straight line between the two endpoints of the straight line, and the straight line is the contour edge straight line of the part.
[0128] In some embodiments, the following steps are further included between S5 and S7:
[0129] S6. Use the Hough transform method to detect the circular contour of the part and draw the circular hole contour of the part. The contour edge straight line of the part and the circular hole contour of the part constitute the contour of the part.
[0130] In some embodiments, the S6 specifically includes the following steps:
[0131] S61. Approximate the contour obtained by Canny edge detection on the image with a polygon, and initially filter out the contours that meet the preset conditions. The preset condition is that the number of corner points of the contour needs to be greater than 10;
[0132] S62. Use the least squares method to fit the filtered contours, approximate them into circles, obtain the coordinates of the center of the circle (xp, yp) and the radius rp of the circle, and filter out the circles that meet the radius according to the set minimum radius and maximum radius;
[0133] S63. Perform sub-pixel positioning on the circular hole contour of the part according to the Zernike moment algorithm, and use the RANSAC algorithm for data fitting to remove the deviated points, obtaining a refined circular contour, thereby obtaining the circular hole contour of the part. The straight line of the contour edge of the part and the circular hole contour of the part constitute the contour of the part. For the schematic diagram of the contour of the part, see Figure 4 。
[0134] The present invention realizes high-precision automatic part detection in industrial production. At the same time, it does not require major modifications to the production line, saving unnecessary expenses. At the same time, the present invention does not require precision detection under a high-resolution imaging system, which also greatly reduces the hardware cost of the detection equipment;
[0135] With the help of a low-resolution imaging system, the present invention can also ensure that the measurement accuracy meets the requirements of industrial detection. At the same time, the measurement speed in seconds also improves the efficiency of the product quality in real-time detection in industrial production. It solves the problem of high efficiency and high cost.
[0136] On the other hand, the present invention also provides a sub-pixel level high-precision two-dimensional dimension on-line measurement system, including a computer device, which is programmed or configured to execute the above sub-pixel level high-precision two-dimensional dimension on-line measurement method;
[0137] Or, a computer program programmed or configured to execute the above sub-pixel level high-precision two-dimensional dimension on-line measurement method is stored in the memory of the computer device.
[0138] As described above, only the specific embodiments of the present invention are provided, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should be covered within the protection scope of the present invention. Moreover, the technical solutions between the various embodiments of the present invention can be combined with each other, but it must be based on the realization by those of ordinary skill in the art. When the combination of technical solutions results in contradictions or cannot be realized, it should be considered that such a combination of technical solutions does not exist and is not within the protection scope required by the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. An image-based online measurement method for sub-pixel level high-precision two-dimensional dimensions, characterized in that The steps include: S1, collecting input part images, and performing denoising and binarization processing on the collected part images; S2. Using an image correction method based on Hough edge detection to correct the binarized part image, the longest straight edge of the target in the part image is rotated to the horizontal direction, so as to straighten the part image and obtain a corrected part image; S3, using the Canny edge detection algorithm and the Zernike moment sub-pixel edge detection method in turn, to perform edge detection on the part image corrected in S2. The detection result is a number of edge line segments. According to the size of the part, the line segments are grouped according to different slopes and intercepts. Each group represents a straight line edge of the part. S4. Combine the line segments of each group into a straight line , and obtain the slopes and intercepts of all the line segments within each group and , and use them as the slope and intercept of the straight line; S5. Obtain the intersection coordinates of all synthetic straight lines , erode the binary-processed part image in S1, filter out the point coordinates outside the black area of the eroded image, and obtain new intersection coordinates , use these intersection coordinates as the two endpoints of the edge straight line, and connect a straight line between the two endpoints , the straight line is the contour edge straight line of the part; S6. Detect the circular contour of the part using the Hough transform method and draw the circular hole contour of the part. The contour edge straight line of the part and the circular hole contour of the part constitute the contour of the part. S7, measuring the contour of the part to obtain measurement data; The S6 specifically includes the following steps: S61, using polygons to approximate the contours obtained by the Canny detection image, and preliminarily screening out contours that meet a preset condition, where the preset condition is that the number of corner points of the contour must be greater than 10; S62, using the least square method to fit the selected contour, approximating it to a circle, obtaining the fitted center coordinates (xp, yp) and the radius rp of the circle, and selecting a circle that meets the radius according to the set minimum radius and maximum radius; S63. Perform sub-pixel positioning on the circular hole contour of the part according to the Zernike moment algorithm, and use the RANSAC algorithm to perform data fitting and remove deviation points to obtain the circular hole contour of the part.
2. The online measurement method for sub-pixel level high-precision two-dimensional dimensions based on an image according to claim 1, characterized in that, The S1 specifically includes the following steps: S11, placing the part to be measured on the stage of the measuring device, and then collecting the input part image through the telecentric camera; S12, denoising the collected part image, then obtaining a binarization threshold through a binarization threshold selection formula, and binarizing the part image after denoising using the binarization threshold; dividing all pixels into two categories, C1 and C2, through the binarization process; The binary threshold selection formula is as follows: ; ; ; ; , ; Wherein, is the global mean value; represents the binarization gray threshold; is the pixel level of the part image, and its value ranges from 0 to 255; represents the between-class variance; and respectively represent the probabilities of the pixel values C1 and C2 occurring; represents the binarization gray threshold and its cumulative mean value; and are respectively the mean values of the two types of pixels C1 and C2; represents the pixel value and the probability of its occurrence.
3. The on-line measurement method for sub-pixel level high-precision two-dimensional dimension based on image according to claim 2, characterized in that, The S2 specifically includes the following steps: S21. First, the edge contour of the part image is detected using the Hough line detection method to obtain a number of line segments; then the slopes of the line segments are calculated; S22. The slopes of the line segments on the same edge are the same. Select the slope value with the largest number of line segments. , and the edge with the largest number of line segments is the target longest straight line edge; calculate the angle between the line segment with the slope value and the horizontal direction of the image coordinate axis . The specific calculation formula for the angle is as follows: ; The absolute value of the included angle , that is is the rotation angle of the image. If , the rotation direction is clockwise; if , the rotation direction is counterclockwise; S23, according to the angle Rotate the longest straight edge of the target in the part image to the horizontal direction to straighten the part image; Get the corrected part image.
4. The online measurement method for sub-pixel level high-precision two-dimensional dimensions based on an image according to claim 3, characterized in that The S3 specifically includes the following steps: S31, Canny edge detection algorithm detects the edge of the part image by setting high and low thresholds; and uses non-maximum suppression to process the part image; the calculation formulas of the high and low thresholds are as follows: ; wherein is the high threshold, i.e., the optimal segmentation threshold; is the low threshold, and points higher than the high threshold are considered edge points, and at the same time, points lower than the low threshold are not considered edge points; S32, then performing edge detection on the part image after non-maximum suppression processing by using a Zernike moment sub-pixel edge detection method to obtain a plurality of sub-pixel edge coordinates, and then connecting the plurality of sub-pixel edge coordinates according to the contour of the part to obtain a detection result, i.e., a plurality of edge line segments; S33. According to the size of the part, group the line segments with different slopes and intercepts. Each group represents a straight line edge of the part.
5. The on-line measurement method for sub-pixel level high-precision two-dimensional dimension based on image according to claim 4, wherein The S32 specifically includes the following steps: S321. Represent the coordinate points in the part image after non-maximum suppression processing by order Zernike moments of degree; S322. Then rotate the part image after non-maximum suppression processing by an angle , and the rotated Zernike moment is ; S323. Calculate Zernike moments of different orders according to the rotational invariance of moments. S324. Substitute Zernike moments of different orders into the derivation formula of sub-pixel edge coordinates to obtain coordinate points The corresponding sub-pixel edge coordinate values; S325. Loop through S321 to S324 until the number of loops reaches the set number of times to obtain multiple sub-pixel edge coordinates. S326. Then connect the multiple sub-pixel edge coordinates according to the contour of the part to obtain the detection result, that is, several edge segments.
6. The on-line measurement method for two-dimensional sub-pixel level high-precision dimensions based on an image according to claim 5, characterized in that In the S321, order is represented by the Zernike moments of degree, specifically as follows: ; Among them, , are all integers and satisfy , is an even number and ; is the conjugate complex number on the polar coordinates, is the orthogonal polynomial on the polar coordinates, is the polar coordinates of the coordinate point , is the vector length between the origin and the coordinate point , is the included angle between this vector and the counterclockwise direction of the x-axis.
7. The on-line measurement method for high-precision two-dimensional sub-pixel dimension based on image according to claim 5, characterized in that The derivation formula of the sub-pixel edge coordinates in S324 is specifically as follows: ; Among them, is the sub-pixel edge coordinate, indicating the perpendicular distance from the origin to the ideal edge.
8. The online measurement method for sub-pixel level high-precision two-dimensional dimensions based on images according to claim 7, characterized in that S5 specifically includes the following steps: S51. Obtain the intersection coordinates of all synthetic straight lines ; S52. Create a all-1 array as the convolution kernel for the erosion process. The value range of the array is 0 to 255, and then set the number of iterations of the erosion operation; and perform multiple rounds of erosion on the binary-processed part image in S1. The erosion operation can be expressed as: ; Among them, structure A represents an image, and structure B represents a convolution kernel. S53. Traverse the intersection coordinates , and judge the coordinate whether it is located in the black area of the eroded image, and retain the point coordinates within this area as ; S54. Traversal point coordinates , select two intersection coordinates on the same synthesis line from S4 . Using these two intersection coordinates as the two endpoints of a line, connect a line between the two endpoints . The line is the contour edge line of this part.
9. An online measurement system for two-dimensional dimensions with sub-pixel level high precision, including a computer device, characterized in that, The computer device is programmed or configured to execute the sub-pixel level high-precision two-dimensional dimension online measurement method according to any one of claims 1 to 8. Or, a computer program programmed or configured to execute the sub-pixel level high-precision two-dimensional dimension online measurement method according to any one of claims 1 to 8 is stored in the memory of the computer device.