Gear parameter measurement method and device based on polar coordinate transformation, equipment and storage medium
Patent Information
- Application Number
- CN202611173634.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]本申请的主要目的在于提供一种基于极坐标变换的齿轮参数测量方法、装置、设备以及存储介质,旨在解决如何提高齿轮参数测量的准确率的技术问题
[0016]本申请提供了一种基于极坐标变换的齿轮参数测量方法,本申请获取待检测齿轮的灰度图像和齿高先验值,对所述灰度图像进行预处理和二值化处理,得到二值掩码,并根据所述二值掩码进行连通域分析,得到初始圆心和初始外径;采用与所述齿高先验值成比例的结构元素对所述二值掩码进行形态学差分运算,提取出齿区域二值图像;根据所述初始圆心、所述初始外径、所述齿高先验值以及所述齿区域二值图像,对所述灰度图像中的环形齿区域进行极坐标变换,生成矩形展开图;在所述矩形展开图中沿径向方向检测梯度峰值,对所述梯度峰值位置的邻域进行二次曲线拟合,得到齿顶点集;对所述齿顶点集进行离群点剔除,并对剔除后的齿顶点集进行最小二乘圆拟合,得到外圆圆心和外圆半径;根据所述外圆圆心和所述外圆半径统计齿数,并根据所述外圆半径与预设系数的乘积确定内圆半径;根据所述外圆半径和所述内圆半径计算齿顶距和齿底距,输出所述齿数、所述外圆半径、所述内圆半径、所述齿顶距、所述齿底距。本申请通过形态学差分运算直接提取齿区域,避免了边缘检测对表面缺陷的敏感性问题;通过极坐标变换将环形齿分布展开为矩形图,将二维环形检测问题降维为一维峰值检测问题,降低了检测复杂度并提升了抗干扰能力;通过二次曲线拟合获得亚像素精度的齿顶点集,突破了像素级定位的精度瓶颈;通过对外圆拟合与齿数统计的解耦处理,避免了参数之间的迭代累积误差,从而提高了齿轮参数测量的准确率。
Smart Images

Figure CN123015645A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of gear parameter measurement technology, and in particular to a gear parameter measurement method, apparatus, device, and storage medium based on polar coordinate transformation. Background Technology
[0002] Existing gear visual inspection technologies mainly include two types of solutions: edge detection and deep learning. However, these solutions all process circular distribution features in the Cartesian coordinate system, which suffers from insufficient pixel-level accuracy, low computational efficiency, and cumulative errors due to parameter coupling, resulting in low accuracy in gear parameter measurement. Therefore, how to improve the accuracy of gear parameter measurement remains a problem that needs to be solved.
[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this application is to provide a method, apparatus, device, and storage medium for measuring gear parameters based on polar coordinate transformation, aiming to solve the technical problem of how to improve the accuracy of gear parameter measurement.
[0005] To achieve the above objectives, this application proposes a gear parameter measurement method based on polar coordinate transformation, the method comprising: The grayscale image and tooth height prior value of the gear to be detected are obtained. The grayscale image is preprocessed and binarized to obtain a binary mask. Connected component analysis is performed based on the binary mask to obtain the initial center and initial outer diameter. Morphological difference operation is performed on the binary mask using a structuring element proportional to the prior value of the tooth height to extract the binary image of the tooth region; Based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region, polar coordinate transformation is performed on the annular tooth region in the grayscale image to generate a rectangular unfolded image. In the rectangular unfolded diagram, gradient peaks are detected along the radial direction, and quadratic curve fitting is performed on the neighborhood of the gradient peak location to obtain the tooth vertex set; Outlier points are removed from the set of tooth vertices, and least-squares circle fitting is performed on the removed set of tooth vertices to obtain the center and radius of the outer circle. The number of teeth is counted based on the outer circle center and the outer circle radius, and the inner circle radius is determined based on the product of the outer circle radius and a preset coefficient. Calculate the tooth tip distance and tooth root distance based on the outer circle radius and the inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
[0006] In one embodiment, the step of performing morphological difference operations on the binary mask using a structuring element proportional to the prior value of the tooth height to extract the binary image of the tooth region includes: Obtain the binary mask and the prior value of the tooth height; The binary mask is eroded using a first circular structuring element to obtain an eroded binary image. The radius of the first circular structuring element is the product of a first preset multiple and the prior value of the tooth height. The binary mask is dilated using a second circular structuring element to obtain a dilated binary image. The radius of the second circular structuring element is the product of a second preset multiple and the prior value of the tooth height. Perform a set difference operation on the erosion binary image and the dilation binary image to obtain an intermediate difference image; The intermediate difference image and the binary mask are subjected to a pixel-by-pixel logical AND operation to obtain the binary image of the tooth region.
[0007] In one embodiment, the step of performing polar coordinate transformation on the annular tooth region in the grayscale image based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region to generate a rectangular unfolded image includes: The annular region to be transformed is determined based on the binary image of the tooth region; Determine the center point of the polar coordinate transformation based on the initial circle center; The radial scanning range is determined based on the initial outer diameter and the prior value of the tooth height. A reverse mapping table is established based on the center point and the radial scan range; The pixels within the annular region are resampled according to the inverse mapping table to generate a rectangular unfolded image.
[0008] In one embodiment, the step of performing quadratic curve fitting on the neighborhood of the gradient peak location to obtain the tooth vertex set includes: Calculate the gradient magnitude along the radial direction in the rectangular unfolded diagram; Non-maximum suppression is applied to the calculated gradient magnitude to obtain the peak position with pixel precision; Perform quadratic curve fitting on the gradient magnitude in the neighborhood of the peak position to calculate the sub-pixel offset of the peak position; The peak position is corrected based on the sub-pixel offset to obtain a set of tooth vertices with sub-pixel precision.
[0009] In one embodiment, the steps of removing outliers from the set of tooth vertices and performing least-squares circle fitting on the removed set of tooth vertices to obtain the outer circle center and outer circle radius include: The set of tooth vertices is iteratively sampled using a random sampling consensus algorithm to construct candidate circles. Calculate the distance from each point in the tooth vertex set to the candidate circle, and divide the points whose distance is less than a preset threshold into an interior point set; The candidate circle with the largest number of interior points in the interior point set is determined as the target circle; The set of interior points corresponding to the target circle is determined as the set of effective tooth vertices; The effective tooth vertex set is fitted with a least-squares circle to obtain the outer circle center and outer circle radius.
[0010] In one embodiment, after the steps of counting the number of teeth based on the outer circle center and the outer circle radius, and determining the inner circle radius based on the product of the outer circle radius and a preset coefficient, the method further includes: The number of teeth is compared with a preset threshold. If the number of teeth is less than a preset threshold, then the polar coordinate transformation is re-executed and the set of tooth vertices is extracted.
[0011] In one embodiment, after the steps of outputting the number of teeth, the outer radius, the inner radius, the tooth tip distance, and the tooth root distance, the method further includes: The rectangular unfolded diagram is translated along the angular direction and then subjected to polar coordinate transformation again to obtain the second unfolded diagram; The radial deviation corresponding to each angular position is obtained by subtracting the rectangular unfolded image from the second unfolded image pixel by pixel, and the radial deviation is used as the tooth profile error. Output the tooth profile error.
[0012] Furthermore, to achieve the above objectives, this application also proposes a gear parameter measuring device based on polar coordinate transformation, the gear parameter measuring device based on polar coordinate transformation comprising: The acquisition module is used to acquire the grayscale image and tooth height prior value of the gear to be detected, preprocess and binarize the grayscale image to obtain a binary mask, and perform connected component analysis based on the binary mask to obtain the initial center and initial outer diameter. The difference module is used to perform morphological difference operations on the binary mask using structuring elements proportional to the prior value of the tooth height, and extract the binary image of the tooth region. The transformation module is used to perform polar coordinate transformation on the annular tooth region in the grayscale image based on the initial circle center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region, to generate a rectangular unfolded image. The fitting module is used to detect gradient peaks in the radial direction in the rectangular unfolded diagram, and to perform quadratic curve fitting on the neighborhood of the gradient peak position to obtain a set of tooth vertices. The elimination module is used to eliminate outliers from the set of tooth vertices and perform least-squares circle fitting on the eliminated set of tooth vertices to obtain the center and radius of the outer circle. The determining module is used to count the number of teeth based on the outer circle center and the outer circle radius, and to determine the inner circle radius based on the product of the outer circle radius and a preset coefficient; The output module is used to calculate the tooth tip distance and tooth root distance based on the outer circle radius and the inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
[0013] Furthermore, to achieve the above objectives, this application also proposes a gear parameter measurement device based on polar coordinate transformation, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the gear parameter measurement method based on polar coordinate transformation as described above.
[0014] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the gear parameter measurement method based on polar coordinate transformation as described above.
[0015] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the gear parameter measurement method based on polar coordinate transformation as described above.
[0016] This application provides a gear parameter measurement method based on polar coordinate transformation. The method acquires a grayscale image of the gear to be tested and a prior value for tooth height. The grayscale image is preprocessed and binarized to obtain a binary mask. Connected component analysis is performed on the binary mask to obtain the initial center and initial outer diameter. Morphological difference operations are performed on the binary mask using a structuring element proportional to the prior value for tooth height to extract the binary image of the tooth region. Based on the initial center, the initial outer diameter, the prior value for tooth height, and the binary image of the tooth region, a polar coordinate transformation is performed on the annular tooth region in the grayscale image. Generate a rectangular unfolded diagram; detect gradient peaks along the radial direction in the rectangular unfolded diagram, perform quadratic curve fitting on the neighborhood of the gradient peak position to obtain a set of tooth vertices; remove outliers from the set of tooth vertices, and perform least-squares circle fitting on the removed set of tooth vertices to obtain the outer circle center and outer circle radius; count the number of teeth based on the outer circle center and outer circle radius, and determine the inner circle radius based on the product of the outer circle radius and a preset coefficient; calculate the tooth tip distance and tooth root distance based on the outer circle radius and inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance. This application directly extracts the tooth region through morphological difference operations, avoiding the sensitivity of edge detection to surface defects; it expands the annular tooth distribution into a rectangular image through polar coordinate transformation, reducing the two-dimensional annular detection problem to a one-dimensional peak detection problem, thus reducing detection complexity and improving anti-interference ability; it obtains a tooth vertex set with sub-pixel accuracy through quadratic curve fitting, breaking through the accuracy bottleneck of pixel-level positioning; and it avoids iterative accumulation errors between parameters by decoupling the outer circle fitting and tooth count statistics, thereby improving the accuracy of gear parameter measurement. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating an embodiment of the gear parameter measurement method based on polar coordinate transformation provided in this application. Figure 2 This is a grayscale image diagram of the gear provided in Embodiment 1 of the gear parameter measurement method based on polar coordinate transformation of this application; Figure 3This is a rectangular unfolded view of the gear provided in Embodiment 1 of the gear parameter measurement method based on polar coordinate transformation of this application; Figure 4 This is a flowchart illustrating Embodiment 2 of the gear parameter measurement method based on polar coordinate transformation in this application. Figure 5 This is a schematic diagram of gear corrosion treatment provided in Embodiment 2 of the gear parameter measurement method based on polar coordinate transformation of this application; Figure 6 This is a schematic diagram of gear expansion processing provided in Embodiment 2 of the gear parameter measurement method based on polar coordinate transformation of this application; Figure 7 This is a binary image of the tooth region provided in Embodiment 2 of the gear parameter measurement method based on polar coordinate transformation of this application; Figure 8 This is a schematic diagram of the module structure of the gear parameter measuring device based on polar coordinate transformation according to an embodiment of this application; Figure 9 This is a schematic diagram of the device structure of the hardware operating environment involved in the gear parameter measurement method based on polar coordinate transformation in the embodiments of this application.
[0020] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0021] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0023] This application acquires a grayscale image and prior tooth height values of the gear to be detected. The grayscale image is preprocessed and binarized to obtain a binary mask. Connected component analysis is performed on the binary mask to obtain the initial center and initial outer diameter. Morphological difference operations are performed on the binary mask using a structuring element proportional to the prior tooth height values to extract the binary image of the tooth region. Based on the initial center, initial outer diameter, prior tooth height values, and the binary image of the tooth region, polar coordinate transformation is performed on the annular tooth region in the grayscale image to generate a rectangular unfolded image. In the unfolded diagram, gradient peaks are detected along the radial direction. A quadratic curve is fitted to the neighborhood of the gradient peak location to obtain a set of tooth vertices. Outliers are removed from the set of tooth vertices, and least-squares circle fitting is performed on the removed set of tooth vertices to obtain the outer circle center and outer circle radius. The number of teeth is counted based on the outer circle center and outer circle radius, and the inner circle radius is determined based on the product of the outer circle radius and a preset coefficient. The tooth tip distance and tooth root distance are calculated based on the outer circle radius and inner circle radius, and the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance are output.
[0024] Existing gear visual inspection technologies mainly include two types of solutions: edge detection and deep learning. However, these solutions all process circular distribution features in the Cartesian coordinate system, which suffers from insufficient pixel-level accuracy, low computational efficiency, and cumulative errors due to parameter coupling, resulting in low accuracy in gear parameter measurement. Therefore, how to improve the accuracy of gear parameter measurement remains a problem that needs to be solved.
[0025] This application directly extracts the tooth region through morphological difference operations, avoiding the sensitivity of edge detection to surface defects; it expands the annular tooth distribution into a rectangular image through polar coordinate transformation, reducing the two-dimensional annular detection problem to a one-dimensional peak detection problem, thus reducing detection complexity and improving anti-interference ability; it obtains a tooth vertex set with sub-pixel accuracy through quadratic curve fitting, breaking through the accuracy bottleneck of pixel-level positioning; and it avoids iterative accumulation errors between parameters by decoupling the outer circle fitting and tooth count statistics, thereby improving the accuracy of gear parameter measurement.
[0026] All user-related data involved in this application were obtained with the user's permission or consent; that is, when this application is applied to specific products or technologies, user permission is required to obtain and process the relevant data, and the processing of the relevant data must comply with the relevant laws, regulations and regulatory standards of the relevant countries and regions.
[0027] Based on this, embodiments of this application provide a gear parameter measurement method based on polar coordinate transformation, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the gear parameter measurement method based on polar coordinate transformation of this application.
[0028] In this embodiment, the gear parameter measurement method based on polar coordinate transformation includes steps S10~S70: Step S10: Obtain the grayscale image and tooth height prior value of the gear to be detected, preprocess and binarize the grayscale image to obtain a binary mask, and perform connected component analysis based on the binary mask to obtain the initial center and initial outer diameter; It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of performing the above functions, such as a gear parameter measuring device based on polar coordinate transformation. The following description uses a gear parameter measuring device based on polar coordinate transformation as an example to illustrate this embodiment and the subsequent embodiments.
[0029] It should be noted that, firstly, an industrial camera can be used to acquire the original image of the gear to be inspected. The acquired color image is then converted into a grayscale image. Gaussian filtering is then applied to the grayscale image to remove image noise. Next, an adaptive thresholding method is used to separate the foreground and background of the gear, resulting in a binary mask. Specifically, Otsu's method can be used to calculate the globally optimal segmentation threshold. Otsu's method adaptively determines the threshold based on the grayscale histogram by maximizing the inter-class variance between the foreground and background. This threshold is then used to perform global thresholding on the grayscale image. Pixels with grayscale values greater than the threshold are set to white, and pixels with grayscale values less than or equal to the threshold are set to black, resulting in a binary mask. White pixels (grayscale value of 255) represent the gear body area, and black pixels (grayscale value of 0) represent the background and the internal holes of the gear. Subsequently, morphological opening and closing operations are performed on the binary mask to remove minor noise and fill holes. Then, connected component analysis is used to identify all white connected regions. The connected region with the largest area is selected as the gear region. Finally, the minimum circumcircle of this gear region is calculated, and its center is used as the initial center, and its radius as the initial outer diameter. (See reference.) Figure 2 , Figure 2 This is a schematic diagram of a grayscale image of a gear.
[0030] Step S20: Perform morphological difference operation on the binary mask using a structuring element proportional to the prior value of the tooth height to extract the binary image of the tooth region; It should be noted that the prior value of the tooth height is the total tooth height of the gear, predetermined based on the gear design parameters. A structuring element is a "probe" or "template" used in mathematical morphology for image erosion and dilation operations; in a digital image, it is represented as a two-dimensional grid composed of 0s and 1s. The geometric dimensions (radius) of the structuring element used in this embodiment have a fixed proportional relationship with the prior value of the gear's tooth height. The binary image of the tooth region refers to the binary image extracted from the original gear image that belongs only to the annular region of the teeth.
[0031] By using circular structuring elements proportional to the prior value of tooth height to perform morphological operations on the binary mask, and through a combination of erosion and dilation operations as well as set difference operations, a binary image of the tooth region containing only the tooth ring area can be extracted from the binary mask, eliminating interference from the internal region of the tooth root and the external background.
[0032] Step S30: Based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region, perform polar coordinate transformation on the annular tooth region in the grayscale image to generate a rectangular unfolded image; It should be noted that the initial circle center is used as the center point of the polar coordinate transformation, the radial scanning range is determined by the initial outer diameter and tooth height prior values, and the annular region to be transformed is determined by the binary image of the tooth region. This allows the pixels within the annular region to be mapped from the Cartesian coordinate system to the polar coordinate system. Through polar coordinate transformation, the originally curved tooth tip and tooth root contours can be mapped to horizontal straight lines in the rectangular unfolded image, thus transforming the search for peaks on the circumference into the search for column peaks in the rectangular image.
[0033] In one feasible approach, the step of performing polar coordinate transformation on the annular tooth region in the grayscale image based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region to generate a rectangular unfolded image includes: determining the annular region to be transformed based on the binary image of the tooth region; determining the center point of the polar coordinate transformation based on the initial center; determining the radial scanning range based on the initial outer diameter and the prior value of the tooth height; establishing a reverse mapping table based on the center point and the radial scanning range; and resampling the pixels within the annular region according to the reverse mapping table to generate a rectangular unfolded image.
[0034] It should be noted that, firstly, the binary image of the tooth region is used as a spatial constraint mask to determine the annular region to be transformed. The area corresponding to the white pixels. The annular area corresponds to the tooth-shaped ring area of the gear. The initial center point obtained earlier... As the center point of the polar coordinate transformation, the center point can be used to calculate ρ and θ in subsequent polar coordinate transformations. Specifically, the lower limit of the radial scan range is the initial outer diameter R0 minus the prior tooth height h, denoted as R_inner, and the upper limit is the initial outer diameter R0 or R0 plus a preset value, denoted as R_outer, i.e., ρ∈[R_inner,R_outer]. This range covers the entire radial thickness of the tooth ring.
[0035] After obtaining the center point and the radial scan range, a reverse mapping table can be established using the reverse mapping method. The goal of establishing the reverse mapping table is to generate a rectangular unfolded image I_p with a width W × height H. First, the parameters are calculated: W = 2π·R_outer H = R_outer - R_inner Where W is the width, obtained by calculating the circumference of the outer circle, corresponding to the direction of angle θ. H is the height, obtained by calculating the radial range, corresponding to the direction of radius ρ. After obtaining the width and height, a reverse mapping table is constructed (traversing each pixel of the unfolded image), and the corresponding Cartesian coordinates are calculated for each pixel coordinate (u, v) in the unfolded image.
[0036] Where u∈[0, W-1], corresponding to the angle θ = u / R_outer; v∈[0, H-1], corresponding to the radius ρ = R_inner + v. Calculate the corresponding Cartesian coordinates: x = x0 + ρ·cos(θ) y = y0 + ρ·sin(θ) This establishes a reverse mapping table LUT[u][v] = (x, y). LUT stands for lookup table. Based on the reverse mapping table, the rectangular unfolded graph I_p can be obtained, which can be referenced. Figure 3 , Figure 3 This is a rectangular unfolded diagram of the gear.
[0037] Since (x, y) are usually not integer pixel coordinates, resampling (interpolation) can be performed. Specifically, bilinear interpolation can be used. Let the four neighboring pixels of (x, y) be: Q 11 = (floor(x), floor(y)) Q 12 = (floor(x), ceil(y)) Q 21 = (ceil(x), floor(y)) Q 22 = (ceil(x), ceil(y)) Among them, Q 11Q is the top-left pixel (x rounded down, y rounded down). 12 For the bottom left pixel (x rounded down, y rounded up), Q 21 Q is the top right pixel (x rounded up, y rounded down). 22 This represents the bottom right pixel (x rounded up, y rounded up). `floor` indicates a round-down operation, and `ceil` indicates a round-up operation.
[0038] The interpolation weights are: dx = x - floor(x) dy = y - floor(y) Where dx is the decimal part of x, representing the horizontal offset of (x, y) from the top-left pixel (floor(x), floor(y)); dy is the decimal part of y, representing the vertical offset.
[0039] The interpolation result is:
[0040] The above formula is a weighted average of the gray values of (x, y) and their distances to four neighboring pixels. This represents the pixel grayscale value at coordinate position Q in the original grayscale image.
[0041] Step S40: Detect gradient peaks along the radial direction in the rectangular unfolded diagram, and perform quadratic curve fitting on the neighborhood of the gradient peak location to obtain the tooth vertex set; It should be noted that the gradient magnitude can be calculated radially (ρ direction) in the rectangular unfolded image. The location with the largest gradient magnitude corresponds to the region in the image where the brightness changes most drastically, i.e., the transition boundary from the tooth root to the tooth tip. The peak position is initially located by non-maximum suppression, and then a quadratic curve fitting is performed on the gradient magnitude in the neighborhood of each peak position to calculate the sub-pixel offset, correct the peak position, and finally obtain the tooth vertex set with sub-pixel accuracy.
[0042] In one feasible approach, the step of performing quadratic curve fitting on the neighborhood of the gradient peak position to obtain the tooth vertex set includes: calculating the gradient magnitude along the radial direction in the rectangular unfolded diagram; performing non-maximum suppression on the calculated gradient magnitude to obtain the peak position with pixel precision; performing quadratic curve fitting on the gradient magnitude in the neighborhood of the peak position to calculate the sub-pixel offset of the peak position; and correcting the peak position according to the sub-pixel offset to obtain the tooth vertex set with sub-pixel precision.
[0043] It should be noted that gradient calculation is performed first, with the aim of detecting abrupt changes in grayscale values in the radial direction (ρ direction) of the unfolded image. The calculation method involves calculating the first-order difference along the ρ direction: G(u,v) = I_p(u, v+1) - I_p(u, v) Where G(u,v) represents the gradient magnitude at position (u,v). I_p(u,v) represents the pixel grayscale value at position (u,v) in the unfolded image.
[0044] Or use the Sobel operator: G_ρ = I_p [-1, 0, 1]
[0045] Where G_ρ represents the gradient magnitude along the radial direction. [-1, 0, 1] This represents a 3×1 convolution kernel. This represents the convolution operator.
[0046] Each pixel value in the gradient map G represents the intensity of the grayscale change at that point along the radial direction.
[0047] Then, non-maximum suppression (NMS) is performed to precisely locate peak positions and eliminate false edges. Specifically, this involves scanning column-by-column along direction θ, and for each angle u, along the radial direction v: (1) Find all positions that satisfy G(u,v)>τ (τ = gradient threshold, it is recommended to take 2~3 times the average gradient). (2) For each candidate point, compare it with its immediate and next adjacent points. If G(u,v) ≥ G(u,v-1) and G(u,v) ≥ G(u,v+1), then it is a local maximum; otherwise, suppress it (set it to zero).
[0048] (3) Record the positions (u, v_i) of all local maxima.
[0049] Next, sub-pixel precision localization (i.e., quadratic curve fitting) is performed to overcome the integer pixel precision limitation and achieve sub-pixel level accuracy. The method used is to perform quadratic curve fitting on the gradient values of the neighborhood [v_i-1, v_i, v_i+1] of each peak position v_i obtained by NMS: Let the coordinates of the three points be (-1, G1), (0, G2), and (1, G3); the fitted quadratic function is: f(v) = a·v² + b·v + c Solving for: a = (G1 + G3 - 2G2) / 2 b = (G3 - G1) / 2 c = G2 Therefore, the subpixel offset can be obtained as: Δv = -b / (2a), and the final subpixel position is: v_sub = v_i + Δv Next, coordinate transformation is performed: the coordinates (u, v_sub) of the unfolded graph are transformed back to polar coordinates: θ_i = u / R_outer ρ_i = R_inner + v_sub Final output: Tooth vertex set P1 = {(θ_i, ρ_i)}, where ρ_i is the sub-pixel precision.
[0050] Step S50: Remove outliers from the set of tooth vertices, and perform least-squares circle fitting on the removed set of tooth vertices to obtain the outer circle center and outer circle radius; It should be noted that the Random Sample Consensus (RANSAC) algorithm can be used to iteratively sample the tooth vertex set. In each iteration, a preset number of points are randomly selected to construct candidate circles. The distance from each point in the tooth vertex set to the candidate circle is calculated, and points with a distance less than a preset threshold are classified as interior points. The interior point set corresponding to the candidate circle with the largest number of interior points is selected as the effective tooth vertex set, and outliers caused by factors such as oil stains and burrs are removed. An algebraic distance equation is constructed for the effective tooth vertex set and minimized. Solving this minimization problem yields the center and radius of the outer circle.
[0051] In one feasible approach, the steps of removing outliers from the set of tooth vertices and performing least-squares circle fitting on the removed set of tooth vertices to obtain the outer circle center and outer circle radius include: iteratively sampling the set of tooth vertices using a random sampling consensus algorithm to construct candidate circles; calculating the distance from each point in the set of tooth vertices to the candidate circles, and dividing points with distances less than a preset threshold into an inner point set; determining the candidate circle with the most inner points in the inner point set as the target circle; determining the inner point set corresponding to the target circle as the effective set of tooth vertices; and performing least-squares circle fitting on the effective set of tooth vertices to obtain the outer circle center and outer circle radius.
[0052] It should be noted that this embodiment uses RANSAC to remove outliers. The tooth vertex set may contain false peaks (such as spurious peaks caused by oil stains or scratches), and RANSAC can robustly remove these outliers. The specific steps are as follows: (1) Setting the number of iterations: The number of iterations N_iter = 100~500 times (adjusted according to the proportion of outliers) (2) In each iteration, three points (non-collinear) are randomly sampled from the tooth vertex set P to form the minimum sample set S; a candidate circle (three points define a circle) is fitted by S. Let the three points be A(x1,y1), B(x2,y2), and C(x3,y3). Calculate the center O_c and radius R_c (through the intersection of the perpendicular bisectors). Use the candidate circle (O_c, R_c) to evaluate all points. Calculate the distance d_i from each point p_i to the center of the circle = ||p_i - O_c||. If |d_i - R_c| < ε (ε = 1~2 pixels), then p_i is an inlier; otherwise, it is an outlier. Record the number of inliers and the set of inliers in this round.
[0053] (3) Select the result of the round with the most interior points as the optimal solution.
[0054] (4) Refit the circle using the optimal set of interior points.
[0055] Next, least squares circle fitting (algebraic distance method) is performed. The goal is to fit the optimal circle to the inlier set P_inlier = {(x_i, y_i)}, with center (x_c, y_c) and radius r. The algebraic equation of the circle is: (x - x_c)² + (y - y_c)² = r² Expanding, we get: x² + y² - 2x_c·x - 2y_c·y + (x_c² + y_c² - r²) = 0 make: A = -2x_c B = -2y_c C = x_c² + y_c² - r² The equation then transforms into a linear form: x² + y² + A·x + B·y + C = 0 Construct the error equation for each point (x_i, y_i): e_i = x_i² + y_i² + A·x_i + B·y_i + C Where e_i represents the error (residual) at the i-th point, which represents the deviation between the fitted value and the actual value at that point.
[0056] Minimize objective: min Σ e_i² = Σ(x_i² + y_i² + A·x_i + B·y_i + C)² This transforms the problem into a system of linear equations, where partial derivatives with respect to A, B, and C equal to 0, yielding A, B, and C. Then, the center and radius of the circle can be reconstructed. x_c = -A / 2 y_c = -B / 2 r = √(x_c² + y_c² - C) Then estimate the inner circle. The center of the inner circle (root circle) is the same as that of the outer circle (concentric assumption): O2 = O1 Radius estimated proportionally: R2 = α·R1 Where α∈[0.4, 0.6] are empirical coefficients.
[0057] Finally, the number of teeth is counted, and the number of teeth N = |P_inlier| (the number of interior points after RANSAC filtering is the actual number of teeth).
[0058] Step S60: Count the number of teeth based on the outer circle center and the outer circle radius, and determine the inner circle radius based on the product of the outer circle radius and a preset coefficient; It should be noted that the number of tooth vertices in the tooth vertex set is counted and used as the tooth count. The inner circle radius R2 is determined by multiplying the outer circle radius R1 by a preset coefficient α, i.e., R2 = α·R1, where α ranges from 0.4 to 0.6. The center of the inner circle is located at the same position as the center of the outer circle, meaning that the inner and outer circles share the same center, thus simplifying parameter calculations and avoiding iterative accumulation errors.
[0059] In one feasible approach, after the steps of counting the number of teeth based on the outer circle center and the outer circle radius, and determining the inner circle radius based on the product of the outer circle radius and a preset coefficient, the method further includes: comparing the number of teeth with a preset threshold; if the number of teeth is less than the preset quantity threshold, then re-performing the polar coordinate transformation and extracting the tooth vertex set.
[0060] It should be noted that after obtaining the number of teeth N, it is compared with a preset threshold. This preset threshold can be pre-set according to the design parameters of the gear to be detected, for example, set to 80% or 90% of the designed number of teeth. If the number of teeth N is less than the preset threshold, it indicates that the current detection result is abnormal, possibly due to initial positioning deviation or image quality issues causing incorrect tooth counting. In this case, the rectangular unfolded image is slightly translated along the angular direction (e.g., translated by 1 to 3 pixels), and then polar coordinate transformation is performed again. Gradient peak detection and quadratic curve fitting steps are then re-executed to extract a new set of tooth vertices. The number of teeth is then re-counted based on the new set of tooth vertices. If the number of teeth is still less than the preset threshold after re-detection, the transformation parameters can be adjusted again and the above process can be repeated until the number of teeth meets the requirements or the preset maximum number of retries (e.g., 3 times) is reached. This fault tolerance mechanism improves the stability and reliability of the method.
[0061] Step S70: Calculate the tooth tip distance and tooth root distance based on the outer circle radius and the inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
[0062] It should be noted that, specifically, the outer radius is the same as the addendum circle radius, and the inner radius is the same as the root circle radius. The addendum distance is the addendum circle diameter, and the root distance is the root circle diameter. The calculated number of teeth, outer radius, inner radius, addendum distance, and root distance are formatted and output, and pushed to a display screen or Manufacturing Execution System (MES) for quality control personnel to view. The tooth height can be calculated based on half the difference between the addendum distance and the root distance, or it can be output along with the tooth height.
[0063] In one feasible approach, after the steps of outputting the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance, the method further includes: translating the rectangular unfolded image along the angular direction and performing polar coordinate transformation again to obtain a second unfolded image; calculating the difference between the rectangular unfolded image and the second unfolded image pixel by pixel to obtain the radial deviation corresponding to each angular position, using the radial deviation as the tooth profile error; and outputting the tooth profile error.
[0064] It should be noted that the rectangular unfolded image is slightly translated along the angular direction (horizontal axis) (e.g., 1 to 3 pixels), and then transformed again using the same polar coordinate transformation parameters to obtain the second unfolded image. This translation operation is equivalent to fine-tuning the circumferential starting position of the gear in actual physical space, resulting in different starting angles for the tooth profile in the two transformations. This allows for the extraction of deviation information of the tooth profile at different angular positions. Pixel-by-pixel difference calculations are performed between the original rectangular unfolded image and the second unfolded image to calculate the radial (ρ direction) deviation corresponding to each angular position. These radial deviations reflect the degree of deviation of the gear tooth profile from the ideal tooth profile and are used as tooth profile error data. Tooth profile error is a key indicator for gear accuracy evaluation. The calculated tooth profile error data is formatted and output, and pushed to the display screen or production execution system along with parameters such as the number of teeth, outer radius, inner radius, tip distance, and root distance. Tooth profile error can be presented in the form of a curve graph or numerical table.
[0065] This embodiment acquires the grayscale image and prior tooth height values of the gear to be detected. The grayscale image is preprocessed and binarized to obtain a binary mask. Connected component analysis is performed on the binary mask to obtain the initial center and initial outer diameter. Morphological difference operations are performed on the binary mask using a structuring element proportional to the prior tooth height values to extract the binary image of the tooth region. Based on the initial center, the initial outer diameter, the prior tooth height values, and the binary image of the tooth region, polar coordinate transformation is performed on the annular tooth region in the grayscale image to generate a rectangular unfolded image. In the unfolded diagram, gradient peaks are detected along the radial direction. A quadratic curve is fitted to the neighborhood of the gradient peak location to obtain a set of tooth vertices. Outliers are removed from the set of tooth vertices, and least-squares circle fitting is performed on the removed set of tooth vertices to obtain the outer circle center and outer circle radius. The number of teeth is counted based on the outer circle center and the outer circle radius, and the inner circle radius is determined based on the product of the outer circle radius and a preset coefficient. The tooth tip distance and tooth root distance are calculated based on the outer circle radius and the inner circle radius, and the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance are output. This embodiment directly extracts the tooth region through morphological difference operations, avoiding the sensitivity of edge detection to surface defects; it expands the annular tooth distribution into a rectangular image through polar coordinate transformation, reducing the two-dimensional annular detection problem to a one-dimensional peak detection problem, thus reducing detection complexity and improving anti-interference ability; it obtains a tooth vertex set with sub-pixel accuracy through quadratic curve fitting, breaking through the accuracy bottleneck of pixel-level positioning; and it avoids iterative accumulation errors between parameters by decoupling the outer circle fitting and tooth count statistics, thereby improving the accuracy of gear parameter measurement.
[0066] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 Step S20 also includes steps S201 to S205: Step S201: Obtain the binary mask and the prior value of the tooth height; It should be noted that the binary mask and the prior value of the tooth height are both known and can be obtained directly.
[0067] Step S202: The binary mask is eroded using a first circular structuring element to obtain an eroded binary image. The radius of the first circular structuring element is the product of a first preset multiple and the prior value of the tooth height. It should be noted that the radius of the first circular structuring element SE(r) is the product of a first preset multiple and the prior value of the tooth height, specifically SE(0.1h). The formula for eroding the binary mask using the first circular structuring element is as follows: M e=M SE(0.1h) in, This indicates an etching process, where M is the binary mask for the gear. (See reference.) Figure 5 , Figure 5 This is a schematic diagram of gear corrosion treatment.
[0068] Step S203: The binary mask is dilated using a second circular structuring element to obtain a dilated binary image. The radius of the second circular structuring element is the product of a second preset multiple and the prior value of the tooth height. It should be noted that the radius of the second circular structuring element is the product of a second preset multiple and the prior value of the tooth height, specifically SE(0.3h). The formula for dilating the binary mask using the second circular structuring element is as follows: M d =M⊕SE(0.3h) Where ⊕ represents dilation. M is the binary mask for the gear. (See reference...) Figure 6 , Figure 6 This is a schematic diagram of gear expansion processing.
[0069] Step S204: Perform a set difference operation on the erosion binary image and the dilation binary image to obtain an intermediate difference image; It should be noted that the formula for set difference operation is: M e - M d Among them, M e - M d This represents the intermediate difference image.
[0070] Step S205: Perform a pixel-by-pixel logical AND operation between the intermediate difference image and the binary mask to obtain a binary image of the tooth region.
[0071] It should be noted that the formula for performing a pixel-by-pixel logical AND operation between the intermediate difference image and the binary mask is as follows: M_t = (M e - M d ) ∩ M M_t is the binary image of the tooth region. (See reference...) Figure 7 , Figure 7 This is a binary image of the tooth region.
[0072] This embodiment obtains the binary mask and the prior value of the tooth height; it erodes the binary mask using a first circular structuring element to obtain an eroded binary image, where the radius of the first circular structuring element is the product of a first preset multiple and the prior value of the tooth height; it then dilates the binary mask using a second circular structuring element to obtain an dilated binary image, where the radius of the second circular structuring element is the product of a second preset multiple and the prior value of the tooth height; it performs a set difference operation on the eroded binary image and the dilated binary image to obtain an intermediate difference image; and it performs a pixel-by-pixel logical AND operation on the intermediate difference image and the binary mask to obtain a binary image of the tooth region. This embodiment uses a structuring element proportional to the tooth height for the combined erosion and dilation operations, allowing the structuring element size to adapt to gears of different modules without manual parameter adjustment; simultaneously, it extracts the tooth ring region directly from the binary mask through morphological difference, without relying on edge detection, avoiding edge breakage problems caused by surface defects; and it eliminates tooth root and background interference through set difference and logical AND operations, thereby improving the robustness and accuracy of the measurement.
[0073] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the gear parameter measurement method based on polar coordinate transformation of this application. Any simple transformations based on this technical concept are within the protection scope of this application.
[0074] This application also provides a gear parameter measuring device based on polar coordinate transformation, please refer to... Figure 8 The gear parameter measuring device based on polar coordinate transformation includes: The acquisition module 10 is used to acquire the grayscale image and tooth height prior value of the gear to be detected, preprocess and binarize the grayscale image to obtain a binary mask, and perform connected component analysis based on the binary mask to obtain the initial center and initial outer diameter. Difference module 20 is used to perform morphological difference operation on the binary mask using a structuring element proportional to the prior value of the tooth height, and extract the binary image of the tooth region; Transformation module 30 is used to perform polar coordinate transformation on the annular tooth region in the grayscale image based on the initial circle center, the initial outer diameter, the prior value of tooth height, and the binary image of the tooth region to generate a rectangular unfolded image; The fitting module 40 is used to detect gradient peaks in the radial direction in the rectangular unfolded diagram, and to perform quadratic curve fitting on the neighborhood of the gradient peak position to obtain a set of tooth vertices. The elimination module 50 is used to eliminate outliers from the set of tooth vertices and perform least-squares circle fitting on the set of eliminated tooth vertices to obtain the center and radius of the outer circle. The determining module 60 is used to count the number of teeth based on the outer circle center and the outer circle radius, and to determine the inner circle radius based on the product of the outer circle radius and a preset coefficient; The output module 70 is used to calculate the tooth tip distance and tooth root distance based on the outer circle radius and the inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
[0075] This application acquires a grayscale image and prior tooth height values of the gear to be detected. The grayscale image is preprocessed and binarized to obtain a binary mask. Connected component analysis is performed on the binary mask to obtain the initial center and initial outer diameter. Morphological difference operations are performed on the binary mask using a structuring element proportional to the prior tooth height values to extract the binary image of the tooth region. Based on the initial center, initial outer diameter, prior tooth height values, and the binary image of the tooth region, polar coordinate transformation is performed on the annular tooth region in the grayscale image to generate a rectangular unfolded image. In the unfolded diagram, gradient peaks are detected along the radial direction. A quadratic curve is fitted to the neighborhood of the gradient peak location to obtain a set of tooth vertices. Outliers are removed from the set of tooth vertices, and least-squares circle fitting is performed on the removed set of tooth vertices to obtain the outer circle center and outer circle radius. The number of teeth is counted based on the outer circle center and outer circle radius, and the inner circle radius is determined based on the product of the outer circle radius and a preset coefficient. The tooth tip distance and tooth root distance are calculated based on the outer circle radius and inner circle radius, and the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance are output. This application directly extracts the tooth region through morphological difference operations, avoiding the sensitivity of edge detection to surface defects; it expands the annular tooth distribution into a rectangular image through polar coordinate transformation, reducing the two-dimensional annular detection problem to a one-dimensional peak detection problem, thus reducing detection complexity and improving anti-interference ability; it obtains a tooth vertex set with sub-pixel accuracy through quadratic curve fitting, breaking through the accuracy bottleneck of pixel-level positioning; and it avoids iterative accumulation errors between parameters by decoupling the outer circle fitting and tooth count statistics, thereby improving the accuracy of gear parameter measurement.
[0076] In one embodiment, the difference module 20 is further configured to: acquire the binary mask and the prior tooth height value; perform erosion processing on the binary mask using a first circular structuring element to obtain an eroded binary image, wherein the radius of the first circular structuring element is the product of a first preset multiple and the prior tooth height value; perform dilation processing on the binary mask using a second circular structuring element to obtain an dilated binary image, wherein the radius of the second circular structuring element is the product of a second preset multiple and the prior tooth height value; perform a set difference operation on the eroded binary image and the dilated binary image to obtain an intermediate difference image; and perform a pixel-by-pixel logical AND operation on the intermediate difference image and the binary mask to obtain a binary image of the tooth region.
[0077] In one embodiment, the transformation module 30 is further configured to determine the annular region to be transformed based on the binary image of the tooth region; determine the center point of the polar coordinate transformation based on the initial center; determine the radial scanning range based on the initial outer diameter and the prior value of the tooth height; establish a reverse mapping table based on the center point and the radial scanning range; and resample the pixels in the annular region according to the reverse mapping table to generate a rectangular unfolded image.
[0078] In one embodiment, the fitting module 40 is further configured to calculate the gradient magnitude along the radial direction in the rectangular unfolded diagram; perform non-maximum suppression on the calculated gradient magnitude to obtain the peak position with pixel precision; perform quadratic curve fitting on the gradient magnitude in the neighborhood of the peak position to calculate the sub-pixel offset of the peak position; and correct the peak position according to the sub-pixel offset to obtain the tooth vertex set with sub-pixel precision.
[0079] In one embodiment, the elimination module 50 is further configured to iteratively sample the tooth vertex set using a random sampling consensus algorithm to construct a candidate circle; calculate the distance from each point in the tooth vertex set to the candidate circle, and divide the points with a distance less than a preset threshold into an inner point set; determine the candidate circle with the most inner points in the inner point set as the target circle; determine the inner point set corresponding to the target circle as the effective tooth vertex set; and perform least squares circle fitting on the effective tooth vertex set to obtain the outer circle center and outer circle radius.
[0080] In one embodiment, the determining module 60 is further configured to compare the number of teeth with a preset threshold; if the number of teeth is less than the preset quantity threshold, then the polar coordinate transformation is re-executed and the tooth vertex set is extracted.
[0081] In one embodiment, the output module 70 is further configured to translate the rectangular unfolded image along the angular direction and perform polar coordinate transformation again to obtain a second unfolded image; to calculate the difference between the rectangular unfolded image and the second unfolded image pixel by pixel to obtain the radial deviation corresponding to each angular position, and to use the radial deviation as the tooth profile error; and to output the tooth profile error.
[0082] The gear parameter measuring device based on polar coordinate transformation provided in this application, employing the gear parameter measuring method based on polar coordinate transformation in the above embodiments, can solve the technical problem of how to improve the accuracy of gear parameter measurement. Compared with the prior art, the beneficial effects of the gear parameter measuring device based on polar coordinate transformation provided in this application are the same as those of the gear parameter measuring method based on polar coordinate transformation provided in the above embodiments, and other technical features in the gear parameter measuring device based on polar coordinate transformation are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0083] This application provides a gear parameter measurement device based on polar coordinate transformation. The gear parameter measurement device based on polar coordinate transformation includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the gear parameter measurement method based on polar coordinate transformation in the above embodiment 1.
[0084] The following is for reference. Figure 9 The diagram illustrates a structural schematic of a gear parameter measuring device based on polar coordinate transformation suitable for implementing embodiments of this application. The gear parameter measuring device based on polar coordinate transformation in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (Personal Digital Assistants), tablets, PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The gear parameter measuring device based on polar coordinate transformation shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0085] like Figure 9As shown, the gear parameter measuring device based on polar coordinate transformation may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the gear parameter measuring device based on polar coordinate transformation. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the gear parameter measuring device based on polar coordinate transformation to communicate wirelessly or wiredly with other devices to exchange data. Although a gear parameter measuring device based on polar coordinate transformation with various systems is shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0086] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0087] The gear parameter measuring device based on polar coordinate transformation provided in this application, employing the gear parameter measuring method based on polar coordinate transformation in the above embodiments, can solve the technical problem of how to improve the accuracy of gear parameter measurement. Compared with the prior art, the beneficial effects of the gear parameter measuring device based on polar coordinate transformation provided in this application are the same as those of the gear parameter measuring method based on polar coordinate transformation provided in the above embodiments, and other technical features in this gear parameter measuring device based on polar coordinate transformation are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0088] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0089] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0090] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the gear parameter measurement method based on polar coordinate transformation in the above embodiments.
[0091] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0092] The aforementioned computer-readable storage medium may be included in a gear parameter measuring device based on polar coordinate transformation; or it may exist independently and not assembled into a gear parameter measuring device based on polar coordinate transformation.
[0093] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a gear parameter measuring device based on polar coordinate transformation, the gear parameter measuring device based on polar coordinate transformation performs the following actions: acquires a grayscale image of the gear to be detected and a priori value of the tooth height; preprocesses and binarizes the grayscale image to obtain a binary mask; performs connected component analysis based on the binary mask to obtain an initial center and an initial outer diameter; performs morphological difference operations on the binary mask using a structuring element proportional to the prior value of the tooth height to extract a binary image of the tooth region; and extracts a binary image of the tooth region based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region. The process involves: performing polar coordinate transformation on the annular tooth region in the grayscale image to generate a rectangular unfolded image; detecting gradient peaks along the radial direction in the rectangular unfolded image; performing quadratic curve fitting on the neighborhood of the gradient peak position to obtain a set of tooth vertices; removing outliers from the set of tooth vertices; performing least-squares circle fitting on the removed set of tooth vertices to obtain the outer circle center and outer circle radius; counting the number of teeth based on the outer circle center and outer circle radius; determining the inner circle radius based on the product of the outer circle radius and a preset coefficient; calculating the tooth tip distance and tooth root distance based on the outer circle radius and inner circle radius; and outputting the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
[0094] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0095] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0096] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0097] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described gear parameter measurement method based on polar coordinate transformation, thereby solving the technical problem of how to improve the accuracy of gear parameter measurement. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the gear parameter measurement method based on polar coordinate transformation provided in the above embodiments, and will not be repeated here.
[0098] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the gear parameter measurement method based on polar coordinate transformation as described above.
[0099] The computer program product provided in this application can solve the technical problem of how to improve the accuracy of gear parameter measurement. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the gear parameter measurement method based on polar coordinate transformation provided in the above embodiments, and will not be repeated here.
[0100] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A method for measuring gear parameters based on polar coordinate transformation, characterized in that, The method includes: The grayscale image and tooth height prior value of the gear to be detected are obtained. The grayscale image is preprocessed and binarized to obtain a binary mask. Connected component analysis is performed based on the binary mask to obtain the initial center and initial outer diameter. Morphological difference operation is performed on the binary mask using a structuring element proportional to the prior value of the tooth height to extract the binary image of the tooth region; Based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region, polar coordinate transformation is performed on the annular tooth region in the grayscale image to generate a rectangular unfolded image. In the rectangular unfolded diagram, gradient peaks are detected along the radial direction, and quadratic curve fitting is performed on the neighborhood of the gradient peak location to obtain the tooth vertex set; Outlier points are removed from the set of tooth vertices, and least-squares circle fitting is performed on the removed set of tooth vertices to obtain the center and radius of the outer circle. The number of teeth is counted based on the outer circle center and the outer circle radius, and the inner circle radius is determined based on the product of the outer circle radius and a preset coefficient. Calculate the tooth tip distance and tooth root distance based on the outer circle radius and the inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
2. The method as described in claim 1, characterized in that, The step of performing morphological difference operations on the binary mask using a structuring element proportional to the prior value of the tooth height to extract the binary image of the tooth region includes: Obtain the binary mask and the prior value of the tooth height; The binary mask is eroded using a first circular structuring element to obtain an eroded binary image. The radius of the first circular structuring element is the product of a first preset multiple and the prior value of the tooth height. The binary mask is dilated using a second circular structuring element to obtain a dilated binary image. The radius of the second circular structuring element is the product of a second preset multiple and the prior value of the tooth height. Perform a set difference operation on the erosion binary image and the dilation binary image to obtain an intermediate difference image; The intermediate difference image and the binary mask are subjected to a pixel-by-pixel logical AND operation to obtain the binary image of the tooth region.
3. The method as described in claim 1, characterized in that, The step of performing polar coordinate transformation on the annular tooth region in the grayscale image based on the initial center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region to generate a rectangular unfolded image includes: The annular region to be transformed is determined based on the binary image of the tooth region; Determine the center point of the polar coordinate transformation based on the initial circle center; The radial scanning range is determined based on the initial outer diameter and the prior value of the tooth height. A reverse mapping table is established based on the center point and the radial scan range; The pixels within the annular region are resampled according to the inverse mapping table to generate a rectangular unfolded image.
4. The method as described in claim 1, characterized in that, The step of performing quadratic curve fitting on the neighborhood of the gradient peak position to obtain the tooth vertex set includes: Calculate the gradient magnitude along the radial direction in the rectangular unfolded diagram; Non-maximum suppression is applied to the calculated gradient magnitude to obtain the peak position with pixel precision; Perform quadratic curve fitting on the gradient magnitude in the neighborhood of the peak position to calculate the sub-pixel offset of the peak position; The peak position is corrected based on the sub-pixel offset to obtain a set of tooth vertices with sub-pixel precision.
5. The method as described in claim 1, characterized in that, The steps of removing outliers from the set of tooth vertices and performing least-squares circle fitting on the removed set of tooth vertices to obtain the outer circle center and outer circle radius include: The set of tooth vertices is iteratively sampled using a random sampling consensus algorithm to construct candidate circles. Calculate the distance from each point in the tooth vertex set to the candidate circle, and divide the points whose distance is less than a preset threshold into an interior point set; The candidate circle with the largest number of interior points in the interior point set is determined as the target circle; The set of interior points corresponding to the target circle is determined as the set of effective tooth vertices; The effective tooth vertex set is fitted with a least-squares circle to obtain the outer circle center and outer circle radius.
6. The method as described in claim 1, characterized in that, After the steps of counting the number of teeth based on the outer circle center and the outer circle radius, and determining the inner circle radius based on the product of the outer circle radius and a preset coefficient, the method further includes: The number of teeth is compared with a preset threshold. If the number of teeth is less than a preset threshold, then the polar coordinate transformation is re-executed and the set of tooth vertices is extracted.
7. The method as described in claim 1, characterized in that, After the steps of outputting the number of teeth, the outer radius, the inner radius, the tooth tip distance, and the tooth root distance, the method further includes: The rectangular unfolded diagram is translated along the angular direction and then subjected to polar coordinate transformation again to obtain the second unfolded diagram; The radial deviation corresponding to each angular position is obtained by subtracting the rectangular unfolded image from the second unfolded image pixel by pixel, and the radial deviation is used as the tooth profile error. Output the tooth profile error.
8. A gear parameter measuring device based on polar coordinate transformation, characterized in that, The device includes: The acquisition module is used to acquire the grayscale image and tooth height prior value of the gear to be detected, preprocess and binarize the grayscale image to obtain a binary mask, and perform connected component analysis based on the binary mask to obtain the initial center and initial outer diameter. The difference module is used to perform morphological difference operations on the binary mask using structuring elements proportional to the prior value of the tooth height, and extract the binary image of the tooth region. The transformation module is used to perform polar coordinate transformation on the annular tooth region in the grayscale image based on the initial circle center, the initial outer diameter, the prior value of the tooth height, and the binary image of the tooth region, to generate a rectangular unfolded image. The fitting module is used to detect gradient peaks in the radial direction in the rectangular unfolded diagram, and to perform quadratic curve fitting on the neighborhood of the gradient peak position to obtain a set of tooth vertices. The elimination module is used to eliminate outliers from the set of tooth vertices and perform least-squares circle fitting on the eliminated set of tooth vertices to obtain the center and radius of the outer circle. The determining module is used to count the number of teeth based on the outer circle center and the outer circle radius, and to determine the inner circle radius based on the product of the outer circle radius and a preset coefficient; The output module is used to calculate the tooth tip distance and tooth root distance based on the outer circle radius and the inner circle radius, and output the number of teeth, the outer circle radius, the inner circle radius, the tooth tip distance, and the tooth root distance.
9. A gear parameter measuring device based on polar coordinate transformation, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the gear parameter measurement method based on polar coordinate transformation as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the gear parameter measurement method based on polar coordinate transformation as described in any one of claims 1 to 7.
