Machine Vision Measurement for Cylindrical Gear Parameters

The cylindrical gear is a crucial transmission component widely used in fields such as equipment manufacturing, instrumentation, and aerospace. The quality of gear machining directly impacts equipment performance and service life. Ensuring gears meet quality standards is therefore paramount for the reliable operation of machinery. Consequently, precise gear measurement holds significant importance. Measurement methods based on machine vision are increasingly becoming a key trend in the metrology field, as they address the limitations of traditional contact methods—such as relatively low efficiency, high cost, and challenges for integration into production lines.

This study focuses on the measurement of fundamental geometric parameters and single-flank errors of spur cylindrical gears. A novel non-contact measurement method based on machine vision is proposed, and a corresponding gear parameter measurement system is developed. The primary research contributions of this work are as follows:

(1) Based on the requirements for cylindrical gear parameter measurement, the overall design of the measurement system was completed. This included the selection and configuration of system hardware components. The software development environment was established. Critical calibration procedures, namely lens distortion correction and pixel equivalent calibration, were performed. Furthermore, various error factors affecting the system were analyzed and corresponding compensation strategies were implemented.

(2) To overcome the inefficiency of manual focusing, a method utilizing an improved Brenner function as the evaluation metric for image sharpness was proposed. Experiments demonstrated that this function exhibits excellent characteristics such as strong unimodality and stability. For locating the extremum of the evaluation curve, a novel search algorithm combining Gaussian curve fitting for coarse adjustment and hill-climbing search for fine adjustment was developed to achieve automatic focusing. This algorithm effectively mitigates the issue of traditional hill-climbing methods easily converging to local extrema.

(3) Classical edge detection algorithms were investigated. A hybrid method was proposed, which first employs the Canny operator for coarse extraction of gear edges, followed by sub-pixel localization using an optimized Zernike moment algorithm. Experimental results validated the effectiveness of this approach.

(4) Measurement algorithms were designed for fundamental geometric parameters of spur cylindrical gears—such as addendum circle diameter, root circle diameter, number of teeth—and for single-flank errors, including total profile deviation and single pitch deviation. Comparative experiments with a gear measurement center were conducted to verify the measurement accuracy of the proposed system. Analysis of the results provided insights into the sources of error.

Overall Design of the Spur Cylindrical Gear Parameter Measurement System

A machine vision measurement system for cylindrical gears primarily consists of hardware and software components. Ensuring system measurement accuracy requires careful consideration of both aspects. This section details the overall design and analysis of the measurement system.

Determination of Measurement Items

Parameters for standard involute spur cylindrical gears are categorized into fundamental geometric parameters and single-flank errors. Fundamental parameters include addendum circle diameter, module, pressure angle, and addendum coefficient. Single-flank errors encompass items like single pitch deviation, total profile deviation, profile form deviation, and tangential composite deviation.

For fundamental parameters, the number of teeth, addendum circle diameter, and root circle diameter can be directly obtained from the gear image via detection algorithms. Other parameters like module and pitch circle diameter can then be derived from these three. Therefore, this study focuses on measuring these five fundamental geometric parameters.

Regarding single-flank errors, according to national standards, not all errors are mandatory for inspection in practice. The primary items inspected are those critically affecting transmission accuracy and smoothness. Considering the capabilities and conditions of the developed system, this research primarily measures the following four single-flank errors: total profile deviation, single pitch deviation, k-tooth cumulative pitch deviation, and total cumulative pitch deviation.

For a cylindrical gear with accuracy Grade 9, national standards specify tolerance requirements: 0.087 mm for both addendum and root circle diameters, and 0.032 mm, 0.026 mm, 0.076 mm, 0.076 mm for the four single-flank errors, respectively. The measurement results from this system must satisfy these accuracy requirements.

System Composition and Working Principle

The designed vision measurement system mainly includes hardware components—such as an industrial camera, lens, light source, stepper motor, ball screw module, Arduino control board, and computer—and software components comprising the development environment and measurement algorithms. The development software used is Matlab 2019b under Windows 10, with specific measurement algorithms detailed in subsequent sections. A schematic of the system’s measurement principle is illustrated below.

The measurement principle operates as follows: When initiating measurement for a new specification of spur cylindrical gear, the first step involves accurate focusing via the system’s autofocus function before the industrial camera captures the gear image, ensuring clarity for subsequent processing. The second step entails system calibration using a calibration target to correct lens distortion and obtain the pixel equivalent. Third, the industrial camera formally captures a clear image of the gear under test, which is transmitted and stored on the computer. Fourth, the image undergoes pre-processing, edge detection, and sub-pixel edge localization. Finally, program algorithms calculate the pixel dimensions of each target parameter. These pixel dimensions are then converted into physical dimensions using the pixel equivalent, completing the parameter measurements.

Hardware Design of the Measurement System

Industrial Camera and Lens
The industrial camera is a critical component whose performance significantly impacts measurement accuracy. Based on chip type, industrial cameras are classified into CCD (Charge-Coupled Device) and CMOS (Complementary Metal-Oxide-Semiconductor) cameras. Considering the practical measurement requirements—a field of view around 70 mm and a minimum required accuracy among all parameters of 0.026 mm—the resolution must be at least 70/0.026 ≈ 2692 pixels. The selected camera is a Daheng Imaging Mercury series MER-630-60U3C area-scan CMOS camera. Key parameters are summarized in Table 1.

Specification MER-630-60U3C
Resolution 3088 × 2064
Pixel Size 2.4 µm × 2.4 µm
Optical Format 1/1.8″
Frame Rate 60 fps @ full resolution
Data Interface USB 3.0

Selecting a suitable optical lens is equally important. Factors considered include focal length, distortion, image circle size, working distance, and interface type. The chosen lens is a Computar H0514-MP2 model with a focal length of 5 mm, C-mount interface, and a minimum object distance of 0.1 m.

Light Source and Illumination Mode
High-quality illumination is crucial for reducing subsequent image processing complexity. Common light sources in machine vision include fluorescent lamps, LED lights, and halogen lamps. LED lights were selected for their long lifespan, fast response, and design flexibility.

Illumination modes primarily include front lighting and back lighting. Front lighting highlights surface features, while back lighting emphasizes edges. To meet the dual requirements of edge detection (needing clear edges) and autofocus (needing surface texture for sharpness evaluation), a combined illumination scheme using a parallel backlight and a front ring light was adopted. This combination provides uniform edge contrast from the backlight while eliminating shadows from directional lighting via the ring light.

Mechanical Motion and Control Components
To accommodate gears of different widths (axial thickness), an automatic focusing mechanism is necessary. A PX1204-200 ball screw module with a 4 mm lead and 200 mm travel was selected as the carrier for the camera. A 57-series two-phase stepper motor drives the screw. The motor is controlled by a DM542 stepper driver powered by an S-120-24 switching power supply.

For communication between the hardware and computer software, an Arduino UNO R3 control board is used. It receives serial commands from the Matlab software, processes them, and sends pulse signals to the stepper driver to move the camera for autofocus.

Software Design of the Measurement System

The software component processes images captured by the hardware. Its processing precision and efficiency significantly influence the overall system accuracy. Matlab was chosen as the development platform due to its straightforward syntax and rich library of functions and toolboxes. The main software functional modules are designed as follows:

  • Image Acquisition & Communication Module
  • System Calibration Module
  • Autofocus Control Module
  • Image Processing & Analysis Module
  • Parameter Calculation & Output Module

The software measurement workflow is: Autofocus -> System Calibration -> Image Capture -> Image Pre-processing -> Edge Detection & Sub-pixel Localization -> Parameter Calculation (pixel to physical conversion) -> Result Output.

Calibration of the Spur Cylindrical Gear Measurement System

System calibration is a vital step in vision metrology, critically affecting measurement accuracy. Factors like lens distortion and installation errors must be corrected before measurement. This section details the system calibration procedures.

Camera Parameter Solution and Distortion Correction

Camera Imaging Model
The imaging process involves four coordinate systems: pixel coordinates $(u, v)$, image coordinates $(x, y)$, camera coordinates $(X_C, Y_C, Z_C)$, and world coordinates $(X_W, Y_W, Z_W)$. The transformation from world to camera coordinates involves rotation $\mathbf{R}$ and translation $\mathbf{t}$:

$$
\begin{bmatrix} X_C \\ Y_C \\ Z_C \\ 1 \end{bmatrix} = \begin{bmatrix} \mathbf{R} & \mathbf{t} \\ \mathbf{0}^T & 1 \end{bmatrix} \begin{bmatrix} X_W \\ Y_W \\ Z_W \\ 1 \end{bmatrix}
$$

The pinhole camera model governs the perspective projection from camera to image coordinates:

$$
\begin{cases}
x = f \frac{X_C}{Z_C} \\
y = f \frac{Y_C}{Z_C}
\end{cases}
\quad \text{or} \quad s \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} = \begin{bmatrix} f & 0 & 0 & 0 \\ 0 & f & 0 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} X_C \\ Y_C \\ Z_C \\ 1 \end{bmatrix}
$$

where $f$ is the focal length and $s$ is a scale factor. The image coordinates are related to pixel coordinates by:

$$
\begin{cases}
u = \frac{x}{dX} + u_0 \\
v = \frac{y}{dY} + v_0
\end{cases}
\quad \text{or} \quad \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \begin{bmatrix} \frac{1}{dX} & 0 & u_0 \\ 0 & \frac{1}{dY} & v_0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}
$$

where $(u_0, v_0)$ is the principal point, and $dX$, $dY$ are the physical dimensions of a pixel. Combining these transformations yields the complete projection:

$$
s \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \begin{bmatrix} \frac{f}{dX} & 0 & u_0 & 0 \\ 0 & \frac{f}{dY} & v_0 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} \mathbf{R} & \mathbf{t} \\ \mathbf{0}^T & 1 \end{bmatrix} \begin{bmatrix} X_W \\ Y_W \\ Z_W \\ 1 \end{bmatrix} = \mathbf{M}_{int} \mathbf{M}_{ext} \begin{bmatrix} X_W \\ Y_W \\ Z_W \\ 1 \end{bmatrix}
$$

where $\mathbf{M}_{int}$ is the intrinsic matrix and $\mathbf{M}_{ext}$ is the extrinsic matrix.

Camera Distortion Model
Real lenses deviate from the ideal pinhole model, causing radial and tangential distortion. The complete distortion correction model is:

$$
\begin{aligned}
x’ &= x + \delta_{rx} + \delta_{tx} = x + x(k_1 r^2 + k_2 r^4 + k_3 r^6) + [2p_1 xy + p_2(r^2+2x^2)] \\
y’ &= y + \delta_{ry} + \delta_{ty} = y + y(k_1 r^2 + k_2 r^4 + k_3 r^6) + [p_1(r^2+2y^2) + 2p_2 xy]
\end{aligned}
$$

where $(x’, y’)$ are corrected coordinates, $r^2 = x^2 + y^2$, $k_1, k_2, k_3$ are radial distortion coefficients, and $p_1, p_2$ are tangential distortion coefficients.

Parameter Solution and Distortion Correction
A checkerboard calibration target was used. Fifteen images of the target at different poses were captured. Using the Matlab Camera Calibrator toolbox, the intrinsic parameters and distortion coefficients were solved. The results are shown in Table 2.

Parameter Value
$f/dX$ 1393.6108
$f/dY$ 1394.0418
$u_0$ 642.2743
$v_0$ 525.1442
Radial $k_1$ 0.1488
Radial $k_2$ -0.2047
Tangential $p_1$ $1.4136 \times 10^{-4}$
Tangential $p_2$ $-1.6984 \times 10^{-4}$

The undistortImage function in Matlab was then used to correct distortion in subsequent gear images.

Pixel Equivalent Calibration

Pixel equivalent calibration typically involves measuring a known physical dimension in an image. A novel method using the center-to-center distance of circles on a dot-pattern calibration target is proposed. This method avoids edge localization errors caused by varying illumination that affect diameter measurement. The steps are: 1) Extract sub-pixel edges of calibration circles, 2) Fit circle centers using least squares, 3) Calculate the pixel distance between adjacent centers $l_i$, 4) The pixel equivalent $K$ is the ratio of the known physical center distance $L$ to the average pixel distance:

$$
K = \frac{1}{n} \sum_{i=1}^{n} \frac{L}{l_i}
$$

A 7×7 dot target with a nominal center distance of 7.0000 mm was used. After multiple experiments, the average pixel equivalent was determined to be $K = 0.0864$ mm/pixel.

Analysis and Correction of Camera Installation Perpendicularity Error

If the camera’s optical axis is not perpendicular to the gear’s face, measurement errors occur. An area-based method using the calibration target is proposed to assess and adjust perpendicularity. The principle is that if the camera is tilted, circles closer to the camera appear larger in the image. The method involves capturing an image of the central 3×3 array of circles, calculating their fitted areas $S_i$, and comparing the sum of areas for the top row ($S_{up}$), bottom row ($S_{down}$), left column ($S_{left}$), and right column ($S_{right}$). Differences $a_1 = S_{up} – S_{down}$ and $a_2 = S_{left} – S_{right}$ are computed. If $|a_1|$ and $|a_2|$ are within a threshold $\epsilon$ (set to 5 pixels²), perpendicularity is deemed acceptable. Otherwise, the camera angle is adjusted accordingly (e.g., if $a_1 > \epsilon$, the top is closer, so tilt the camera away from the top). This method provides a practical guide for manual adjustment.

Analysis and Compensation of Illumination Intensity’s Effect on Edge Position

Illumination intensity affects the output grayscale of CMOS pixels, leading to edge position errors. At very high intensities, background grayscale saturates near 255, while foreground grayscale continues to increase, causing the detected edge to shift towards the darker side.

Edge Position Error Model and Compensation Method
The error $\Delta$ is defined as the difference between the known physical diameter $D$ of a calibration circle and its measured pixel diameter $d$ converted via pixel equivalent $K$:

$$
\Delta = \frac{D – d \cdot K}{2}
$$

This $\Delta$ serves as the compensation value for a given illumination level.

Influence Analysis of Illumination Intensity
Experiments were conducted by varying the intensity levels of the ring light (4,5) and backlight (5-30). The average grayscale of the calibration target image was used as an indicator of overall illumination. The edge position error compensation value $\Delta$ was calculated for each setting. Results indicated that for backlight level 11 (with ring light at level 4), the image had moderate saturation and stable edge extraction, with a compensation value $\Delta = 0.0059$ mm. Higher backlight levels caused significantly larger errors.

Edge Position Error Compensation Experiment
Compensation was applied by adding $\Delta$ to the measured radius. The residual root-mean-square error between the compensated diameters and the theoretical diameter was calculated for ring light levels 4 and 5. The error was smaller for level 4 ($1.319 \times 10^{-4}$) than for level 5 ($1.773 \times 10^{-4}$). Therefore, the final illumination settings were selected as ring light level 4 and backlight level 11, with a compensation value of $\delta = 0.0059$ mm applied to all subsequent edge-based dimensional measurements.

Development of Autofocus Function Based on Image Processing

Obtaining a clear image is a prerequisite for accurate edge detection. Autofocus technology is therefore essential. This study employs a passive, image-based autofocus method, which involves moving the camera, capturing images at different positions, evaluating their sharpness, and searching for the position with maximum sharpness.

Autofocus Principle

When the object plane coincides with the lens’s ideal in-focus plane, a sharp image is formed on the sensor. By adjusting the object distance $u$ and evaluating image sharpness at discrete positions, the optimal focus position can be found by fitting the sharpness evaluation curve and locating its peak.

Sharpness Evaluation Function

An ideal sharpness evaluation function should exhibit strong unimodality, no bias, robustness to noise, and high computational efficiency. In-focus images have more pronounced spatial grayscale gradients. Several gradient-based functions were evaluated and improved:

Improved Brenner Function: The original function calculates the squared difference between pixels two columns apart: $F = \sum (I(x+2,y) – I(x,y))^2$. It uses a horizontal template $[1, 0, -1]$. To capture gradients in all directions, additional templates for vertical and diagonal directions were added:
$$M_1=[1,0,-1],\ M_2=[1;0;-1],\ M_3=\begin{bmatrix}1&0&0\\0&0&0\\0&0&-1\end{bmatrix},\ M_4=\begin{bmatrix}0&0&1\\0&0&0\\-1&0&0\end{bmatrix}$$
The improved function is: $F = \sum (|\mathbf{M}_1 * I|^2 + |\mathbf{M}_2 * I|^2 + |\mathbf{M}_3 * I|^2 + |\mathbf{M}_4 * I|^2)$.

Improved Energy of Gradient (EOG) Function: Original: $F = \sum [(I(x+1,y)-I(x,y))^2 + (I(x,y+1)-I(x,y))^2]$. Diagonal templates were added.

Improved Tenengrad Function: Based on Sobel operator. Original templates for horizontal and vertical edges were supplemented with templates for diagonal edges.

Improved Laplace Function: Based on the Laplacian operator. Diagonal templates were added.

Experiments comparing efficiency, unimodality, and robustness (by adding salt & pepper noise) showed that the Improved Brenner function offered the best overall performance: high efficiency, good unimodality, and strong robustness. Therefore, it was selected as the sharpness evaluation function.

Focus Position Search Algorithm

Common search algorithms include exhaustive search, Fibonacci search, curve fitting, and hill-climbing search. Hill-climbing is efficient but prone to getting trapped in local maxima. A novel hybrid algorithm combining Gaussian curve fitting (coarse) and hill-climbing (fine) was proposed.

Coarse Adjustment Stage:
1. Start from an initial position, capture image, compute sharpness $F_1$.
2. Move with a fixed large step $L=3$ mm in the correct direction (determined by comparing $F_1$ and $F_2$). Capture 9 images in total at positions $x_i$, obtaining sharpness values $F_i$.
3. Fit the nine $(x_i, F_i)$ points to a Gaussian function using least squares:
$$F(x) = A \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) + C$$
4. Obtain the fitted peak position $x_G$. Define a fine search interval as $[x_G – 1.5, x_G + 1.5]$ mm.

Fine Adjustment Stage:
Use hill-climbing search within the fine interval.
1. Start from the interval’s left bound, sharpness $M_1$.
2. Set initial step $l=0.64$ mm and final step $l_0=0.01$ mm. Determine correct search direction.
3. Move in the current direction. When $M_{j+1} < M_j$, reverse direction and halve the step size: $l = l/2$.
4. Stop when $l \leq l_0$. The optimal position corresponds to $\max(M_j, M_{j-1})$.

This hybrid approach efficiently finds the global sharpness peak without being trapped locally.

Autofocus Results

Three cylindrical gears of different models (A, B, C) were used to validate the autofocus function. Manual focusing was performed first to establish a reference sharpness value. The autofocus algorithm was then run. For all three gears, the sharpness value at the automatically found focus position exceeded 95% of the manual reference value, confirming the effectiveness of the autofocus method.

Image Pre-processing and Edge Detection Algorithm Research

Image Pre-processing

Grayscale Conversion: Color images are converted to grayscale using the weighted average method: $Gray = 0.2989R + 0.5870G + 0.1140B$.

Image Filtering: To suppress noise, median filtering was chosen for its effectiveness against salt-and-pepper noise while preserving edges. A 3×3 median filter was applied.

Image Segmentation: Due to the high contrast between the gear and background from the backlight, the image histogram is bimodal. Otsu’s method (maximizing inter-class variance) was used for automatic thresholding to obtain a binary image.

Pixel-Level Edge Detection Algorithm

Edges are characterized by abrupt changes in grayscale. First-derivative operators (Roberts, Sobel, Prewitt) detect edges by finding gradient maxima. Second-derivative operators (Laplacian, LoG) find zero-crossings. The Canny operator was selected for its optimal balance between good detection, good localization, and minimal multiple responses. Its steps are: 1) Gaussian filtering, 2) Gradient magnitude and direction computation, 3) Non-maximum suppression, 4) Double thresholding and edge linking.

Comparative experiments on standard images (Lenna) and gear images under noisy conditions confirmed that the Canny operator provides the best performance for this application, yielding thin, well-localized, and robust edges.

Sub-pixel Level Edge Detection Algorithm

To achieve measurement precision beyond the pixel level, sub-pixel edge localization is necessary. The Zernike moment method was chosen for its accuracy, rotational invariance, and noise resistance.

Principle of Zernike Moment-Based Edge Detection
The method is based on an ideal step edge model characterized by four parameters: background intensity $h$, step intensity $k$, perpendicular distance $l$ from the center of a circular mask to the edge, and angle $\phi$ between the edge and the y-axis. The complex Zernike moments $Z_{nm}$ of an image are calculated using orthogonal Zernike polynomials $V_{nm}(\rho,\theta)$ over the unit disk. For a given $N \times N$ convolution mask (e.g., 7×7), the moments $Z’_{00}, Z’_{11}, Z’_{20}, Z’_{31}, Z’_{40}$ after image rotation by $\phi$ can be derived. The edge parameters are then solved from a system of equations derived from these moments:

$$
\begin{aligned}
\phi &= \arctan\left(\frac{\text{Im}(Z_{11})}{\text{Re}(Z_{11})}\right) \\
l &= \frac{Z’_{00}}{Z’_{11}} \quad \text{(for a specific relation derived from the 7×7 mask)} \\
h &= Z’_{00} – \frac{k}{2} + \frac{k}{\pi} \arcsin(l) + \frac{2k}{\pi} l \sqrt{1-l^2} \\
k &= \frac{3 Z’_{11}}{2 (1-l^2)^{3/2}}
\end{aligned}
$$

(The exact expressions for $l$, $h$, $k$ depend on the mask size and the specific Zernike moments used; the above is illustrative). A threshold $k_0$ for the step $k$ is applied to identify edge pixels. For such pixels, the sub-pixel edge coordinates $(x_s, y_s)$ are calculated from the pixel coordinates $(x, y)$ as:

$$
\begin{bmatrix} x_s \\ y_s \end{bmatrix} = \begin{bmatrix} x \\ y \end{bmatrix} + \frac{N}{2} l \begin{bmatrix} \cos \phi \\ \sin \phi \end{bmatrix}
$$

Zernike Moment Optimization Algorithm
The traditional Zernike method is computationally expensive as it computes moments for all image pixels. Two major optimizations were implemented:
1. Coarse-to-Fine Localization: First, apply the Canny operator to get pixel-level edge points. Only these candidate points undergo the subsequent Zernike moment calculation, drastically reducing computation.
2. Automatic Threshold Selection: Instead of manually setting the step threshold $k_0$, Otsu’s method is applied to the calculated $k$ values of all candidate points to automatically determine the optimal threshold, improving robustness and automation.
3. Extended Mask: A 7×7 mask was used instead of 5×5 for higher accuracy, calculating moments up to $Z_{40}$.

Validation of the Optimized Algorithm
Two experiments validated the algorithm:
Experiment 1: A synthetic 256×256 image with a 100×100 white square on a black background. The known top edge is at row 78.5. The optimized Zernike algorithm achieved sub-pixel coordinate errors as low as 0.1129 pixels, outperforming the traditional Zernike method (min error 0.2961 pixels) and the pixel-level Canny (error 0.5 pixels).
Experiment 2: Measurement of a circular laser-cut standard part with a known radius of 30.0125 mm (measured by CMM). The optimized Zernike algorithm yielded a radius of 30.0298 mm (error 0.0173 mm), more accurate than the traditional Zernike (30.0356 mm, error 0.0231 mm) and Canny (30.0492 mm, error 0.0367 mm). The processing time was also significantly lower than the traditional Zernike method.

These results confirm the effectiveness of the optimized Canny + Zernike sub-pixel edge detection method for cylindrical gear measurement.

Spur Cylindrical Gear Parameter Measurement Experiments

Based on the established system and algorithms, measurement experiments were conducted on a standard spur cylindrical gear (Model A from earlier). The fundamental geometric parameters and single-flank errors were measured according to the following algorithms.

Measurement Experiments for Fundamental Geometric Parameters

Addendum and Root Circle Diameter Measurement
Process for Addendum Circle Diameter ($d_a$):
1. Pre-process the gear image (grayscale, median filter, Otsu thresholding).
2. Invert the binary image and fill holes to remove internal reflections and the central bore.
3. Remove small connected regions (area < 20 pixels) to eliminate noise.
4. Extract sub-pixel edge points using the optimized Zernike algorithm.
5. Among all edge points, find the pair with the maximum Euclidean distance. This distance is the pixel diameter of the addendum circle. Points satisfying a distance threshold near this maximum are selected as candidate addendum edge points.
6. Fit a circle to the candidate addendum points using least squares to obtain the center $(x_c, y_c)$ and pixel diameter $d_a^{px}$.
7. Convert to physical diameter: $d_a = d_a^{px} \cdot K + 2\delta$, where $K$ is the pixel equivalent and $\delta$ is the illumination compensation value.

Process for Root Circle Diameter ($d_f$):
1. Using the gear center $(x_c, y_c)$ from the addendum circle fit, calculate the distance from all sub-pixel edge points to the center.
2. The minimum distance corresponds to the root circle radius. Points with a distance below a threshold are selected as candidate root edge points.
3. Fit a circle to these points to obtain the pixel diameter $d_f^{px}$.
4. Convert: $d_f = d_f^{px} \cdot K + 2\delta$.

Number of Teeth ($z$), Module ($m$), and Pitch Circle Diameter ($d$) Measurement
Number of Teeth: A circular mask with a radius equal to the average of the addendum and root circle radii is created centered at $(x_c, y_c)$. The inverted binary gear image is logically ANDed with this mask, isolating the tooth regions. The number of connected components (teeth) in the resulting image is counted using bwlabel.

Module and Pitch Circle Diameter: Using the measured $d_a$, $d_f$, and $z$, the module can be estimated from two formulas derived from gear geometry:
$$ m_1 = \frac{d_a}{z + 2}, \quad m_2 = \frac{d_f}{z – 2.5} $$
The average $\bar{m} = (m_1 + m_2)/2$ is computed. The standard module $m$ from the national standard series closest to $\bar{m}$ is selected as the final module. The pitch circle diameter is then calculated as $d = m \cdot z$.

Measurement Results
The measurement results for a gear with nominal values ($d_a=66$ mm, $d_f=52.5$ mm, $z=20$, $m=3$ mm, $d=60$ mm) are compared in Table 3.

Measurement Method $d_a$ (mm) $d_f$ (mm) $z$ $m$ (mm) $d$ (mm)
Nominal Value 66.0000 52.5000 20 3.000 60.000
Vernier Caliper 66.08 52.60 20 3 60
Our System (Canny pixel) 66.0427 52.5408 20 3 60
Our System (Zernike sub-pixel) 66.0261 52.5307 20 3 60
Gear Measurement Center 66.0129 52.5134 20 3 60

The sub-pixel method shows improved accuracy over the pixel-level method and manual measurement, though a slight gap remains compared to the high-precision gear measurement center.

Measurement Experiments for Single-Flank Errors

Involute Equation
The geometry of an involute curve, traced by a point on a taut string unwinding from a base circle of radius $r_b$, is given by:
$$ \begin{cases}
r_k = \frac{r_b}{\cos \alpha_k} \\
\theta_k = \operatorname{inv} \alpha_k = \tan \alpha_k – \alpha_k
\end{cases} $$
where $\alpha_k$ is the pressure angle at point $K$ on the involute, and $\theta_k$ is the involute roll angle.

Total Profile Deviation ($F_\alpha$) Measurement
The total profile deviation is the distance between two design involute profiles that fully enclose the actual measured profile within the evaluation range. The evaluation range starts at the diameter of the start of active profile circle $d_{Nf}$ and ends at 95% of the addendum circle diameter $d_a$.

For each sub-pixel edge point $K_i(x_i, y_i)$ on a tooth flank, the angle $\angle AOD_i$ subtended at the gear center $O$ between the point and the starting point of the involute is calculated using gear geometry and the fitted base circle radius $r_b = (m z \cos \alpha)/2$, where $\alpha=20^\circ$ is the standard pressure angle.
Across all points on a single flank, the minimum and maximum values $\angle AOD_{\min}$ and $\angle AOD_{\max}$ are found. These correspond to the two enclosing design involutes. The distance between these two involutes along their common normal (which is constant and equals the arc length on the base circle) gives $F_\alpha$:
$$ F_\alpha = r_b \cdot (\angle AOD_{\max} – \angle AOD_{\min}) $$
This process is repeated for all left and right flanks. For the test gear, the maximum $F_\alpha$ values were 0.0305 mm (left) and 0.0314 mm (right). Compared to the gear measurement center, the maximum differences were 0.0137 mm and 0.0150 mm, respectively.

Pitch Deviation Measurement
Pitch deviations are measured precisely on the pitch circle. The intersections of the pitch circle (diameter $d$) with all tooth flanks are needed.
1. From all sub-pixel edge points, select those whose distance to the gear center is within a threshold of the pitch radius $d/2$.
2. Apply the DBSCAN clustering algorithm to these selected points. This yields 40 clusters (for 20 teeth × 2 flanks). The centroid of each cluster gives the approximate intersection point coordinates.
3. For each flank, calculate the central angle $\beta_i$ (or $\gamma_i$ for the opposite flank) between consecutive intersection points $i$ and $i+1$ using the dot product of their vectors from the center.
4. The actual pitch $p_i$ on the pitch circle is: $p_i = \frac{d}{2} \cdot \beta_i$.

Single Pitch Deviation ($f_{pt}$): The difference between the actual pitch and the theoretical pitch $p = \pi m$:
$$ f_{pt}(i) = p_i – \pi m $$
$k$-Tooth Cumulative Pitch Deviation ($F_{pk}$): The algebraic sum of $k$ consecutive single pitch deviations. Typically, $k = z/8$ (rounded to integer):
$$ F_{pk}(i) = \sum_{j=i}^{i+k-1} f_{pt}(j) $$
Total Cumulative Pitch Deviation ($F_p$): The difference between the maximum and minimum single pitch deviation across all teeth on a flank:
$$ F_p = \max(f_{pt}) – \min(f_{pt}) $$

Measurement results for the test gear are summarized in Table 4.

Flank max $|f_{pt}|$ (mm) max $|F_{pk}|$ (mm) $F_p$ (mm)
Left 0.0228 0.0418 0.0455
Right 0.0225 0.0444 0.0450

Compared to the gear measurement center, the differences for left/right flanks were: 0.0057/0.0091 mm for $f_{pt}$, 0.0231/0.0239 mm for $F_{pk}$, and 0.0152/0.0174 mm for $F_p$.

Gear Accuracy Rating
Based on ISO 1328-1:2013 tolerance tables, the measured deviations correspond to an accuracy grade of 9 for all inspected items, which matches the rating from the gear measurement center and falls within the required tolerances specified at the beginning.

Measurement Repeatability
Five consecutive measurements of the same gear under identical conditions were performed to assess repeatability. The maximum range (max-min) of the results for each error item across the five trials was calculated. The repeatability values were: $F_\alpha$: 0.0091 mm, $f_{pt}$: 0.0083 mm, $F_{pk}$: 0.0074 mm, $F_p$: 0.0088 mm. These indicate good stability of the measurement system.

Error Analysis

The main sources of error in the system can be categorized as follows:
1. Hardware Equipment Errors: CMOS sensor noise and non-linearity; residual lens distortion despite calibration; mechanical positioning inaccuracy and vibration of the motion stage; instability of LED light source intensity.
2. Software Algorithm Errors: Calibration accuracy limited by the calibration target’s own precision; approximations in sub-pixel edge modeling and threshold selection during point filtering; inherent numerical precision of algorithms.
3. Environmental Influence Errors: Temperature variations affecting camera performance; platform vibration during calibration or measurement; dust particles on optical surfaces.

Conclusion

This research has conducted an in-depth investigation into machine vision-based measurement methods for spur cylindrical gears, focusing on system calibration, autofocus functionality, and algorithms for measuring both fundamental geometric parameters and single-flank errors. The key accomplishments include:

The successful design and implementation of a complete vision-based measurement system for cylindrical gear parameters, including hardware selection and software development. A comprehensive calibration methodology was established, featuring a novel pixel equivalent calibration method using center distances, an area-based technique for correcting camera perpendicularity, and analysis and compensation of illumination-induced edge errors.

The development of an effective autofocus function. An improved Brenner sharpness evaluation function with multi-directional templates was proposed, alongside a hybrid search algorithm combining Gaussian curve fitting for coarse adjustment and hill-climbing for fine adjustment. This system reliably achieves sharp focus.

The investigation and optimization of image processing and edge detection algorithms. A robust pipeline employing median filtering and Otsu thresholding was used for pre-processing. For edge detection, a hybrid coarse-to-fine strategy was implemented, using the Canny operator for initial pixel-level detection followed by an optimized Zernike moment algorithm for precise sub-pixel localization. This method proved accurate and efficient.

The design and experimental validation of specific measurement algorithms for gear parameters. The system successfully measured addendum circle diameter, root circle diameter, number of teeth, module, pitch circle diameter, total profile deviation, single pitch deviation, k-tooth cumulative pitch deviation, and total cumulative pitch deviation. The results, when compared against a gear measurement center, confirmed that the system meets the accuracy requirements for Grade 9 cylindrical gears. Repeatability tests demonstrated good system stability. A detailed error analysis identified potential sources of inaccuracy.

While the developed system is effective for measuring spur cylindrical gears, limitations remain. The system is currently tailored for spur gears; future work could extend it to measure helical gears, bevel gears, or other gear types. Furthermore, the system is best suited for medium-to-small module gears. Measuring large-module gears that may not fit completely within the field of view would require algorithmic modifications or hardware upgrades.

Scroll to Top