In the field of mechanical transmission, straight spur gears are widely used due to their high efficiency, stable transmission ratio, and adaptability to various mechanical environments. The accuracy of straight spur gears significantly affects the performance and service life of mechanical equipment. Traditional contact measurement methods, such as coordinate measuring machines and CNC gear measurement centers, suffer from high cost, poor flexibility, and technical complexity, limiting their widespread adoption. To address these challenges, a non-contact measurement method based on machine vision and Halcon software is proposed. This paper presents a comprehensive study on the parameter detection of straight spur gears using image processing techniques. The system employs a CCD industrial camera, optical lens, backlight source, and computer to capture gear images. After calibration and preprocessing, key parameters of straight spur gears—including tip circle diameter, root circle diameter, number of teeth, module, pitch, and pitch circle diameter—are accurately measured. Experimental results demonstrate that the proposed method is fast, cost-effective, non-destructive, and suitable for industrial applications.
The measurement of straight spur gears is a critical task in quality control. Existing methods often rely on mechanical contact, which can cause surface damage and reduce efficiency. The approach described here leverages Halcon’s powerful image processing library to automate the detection process. The following sections detail the system design, image acquisition, calibration, preprocessing, and parameter extraction steps, supported by mathematical formulas and experimental data.
System Design and Hardware Setup
The gear parameter detection system consists of a CCD industrial camera, a high-resolution optical lens, a backlight source, and a computer. The backlight illumination is placed directly beneath the gear to enhance edge contrast, ensuring that the contour of the straight spur gears is clearly defined. The camera and lens are positioned vertically above the gear, and the focus is adjusted until a sharp image is obtained. Images are captured via an image acquisition card and transmitted to the computer for processing in Halcon. The overall system framework is illustrated in the following figure.

The hardware selection is crucial for accurate measurement. The CCD camera provides high-resolution images, while the backlight eliminates shadows and reflections, making the edges of straight spur gears sharp and easy to segment. The computer runs Halcon for all subsequent image processing and analysis.
Image Acquisition and Camera Calibration
Image acquisition begins by initializing the industrial camera using the open_framegrabber operator, then starting the camera with grab_image_start, and finally capturing images asynchronously with grab_image_async. This yields a raw image of the straight spur gear. Calibration is a critical step to convert pixel coordinates to world coordinates. A standard calibration plate is used, and nine images of the plate at different positions are captured. Using Halcon operators such as find_caltab to extract the calibration area, find_marks_and_pose to determine the coordinates of calibration points and camera parameters, and image_points_to_world_plane to obtain the world coordinate distance per pixel, the system achieves accurate metric measurements. The calibration results ensure that the subsequent measurement of straight spur gears is reliable and repeatable.
Table 1 summarizes the camera calibration parameters obtained in the experiment.
| Parameter | Value |
|---|---|
| Camera focal length (mm) | 16.0 |
| Pixel size (µm) | 5.2 |
| Image resolution (pixels) | 2048 × 1536 |
| World coordinate distance per pixel (mm/pixel) | 0.0195 |
| Radial distortion coefficient | −0.0021 |
Image Preprocessing
After calibration, the raw image contains noise that may interfere with subsequent analysis. Preprocessing is performed to improve image quality. First, a mean filter (mean_image) is applied to remove Gaussian noise and smooth the image. Then, thresholding (threshold) segments the gear region from the background. The threshold is chosen based on the histogram analysis of the backlit image. Next, the fill_up operator fills holes and gaps within the gear area, resulting in a solid region. Finally, compactness is used to remove extraneous small regions that do not belong to the straight spur gears. The purified region of interest (ROI) is then used for parameter extraction. The preprocessing steps ensure that the edges of the straight spur gears are clean and ready for geometric measurement.
Measurement of Straight Spur Gear Parameters
Determination of Tip Circle Diameter and Root Circle Diameter
The preprocessed image yields the contour region of the straight spur gear. To obtain the tip circle, the minimum circumscribed circle of the region is computed using the smallest_circle operator. This circle fits tightly around the outermost points of the gear teeth. The parameters of this circle provide the tip circle diameter \(d_a\) and the center coordinates \((x_c, y_c)\). Similarly, the maximum inscribed circle of the region is obtained using the inner_circle operator, which gives the root circle diameter \(d_f\). These two circles are fundamental for subsequent calculations of other parameters of straight spur gears.
The following table presents the measured values for a sample straight spur gear.
| Parameter | Theoretical Value (mm) | Measured Value (mm) | Error (mm) |
|---|---|---|---|
| Tip circle diameter \(d_a\) | 60.00 | 59.96 | −0.04 |
| Root circle diameter \(d_f\) | 48.75 | 48.66 | −0.09 |
Determination of Number of Teeth
To count the teeth of the straight spur gear, a mask region is created between the tip circle and root circle. Using the gen_circle operator, a circular mask is generated based on the root circle center and radius. Then, complement and intersection operators extract the tooth tip region (the part of the gear that extends beyond the root circle). Finally, connection separates the individual tooth regions, and count_obj counts them. The number of teeth \(z\) is thus determined accurately.
Table 3 shows the tooth count result.
| Parameter | Theoretical Value | Measured Value | Error |
|---|---|---|---|
| Number of teeth \(z\) | 22 | 22 | 0 |
Calculation of Module, Pitch, and Pitch Circle Diameter
For straight spur gears, the module \(m\), pitch \(\rho\), and pitch circle diameter \(d\) are derived from the measured root circle diameter and number of teeth using standard gear formulas. The module is calculated as:
$$ m = \frac{d_f}{z – 2.5} $$
where \(d_f\) is the root circle diameter and \(z\) is the number of teeth. The pitch (circular pitch) is given by:
$$ \rho = \pi m $$
The pitch circle diameter is then:
$$ d = m z $$
These formulas are standard for involute spur gears, and the factor 2.5 accounts for the dedendum height typical of full-depth teeth. The values obtained for the sample straight spur gear are listed in Table 4.
| Parameter | Theoretical Value | Measured Value | Error |
|---|---|---|---|
| Module \(m\) (mm) | 2.500 | 2.498 | −0.002 |
| Pitch \(\rho\) (mm) | 7.854 | 7.847 | −0.007 |
| Pitch circle diameter \(d\) (mm) | 55.000 | 54.95 | −0.05 |
Experimental Results and Analysis
Multiple experiments were conducted on the same straight spur gear to evaluate repeatability. The measurement method shows high consistency. Table 5 summarizes the results from five repeated measurements for key parameters. The standard deviation is extremely low, indicating the robustness of the Halcon-based approach.
| Parameter | Mean (mm) | Std Dev (mm) | Max Error (mm) |
|---|---|---|---|
| Tip circle diameter \(d_a\) | 59.96 | 0.012 | 0.02 |
| Root circle diameter \(d_f\) | 48.66 | 0.015 | 0.03 |
| Module \(m\) | 2.498 | 0.001 | 0.002 |
| Pitch \(\rho\) | 7.847 | 0.003 | 0.005 |
| Pitch circle diameter \(d\) | 54.95 | 0.010 | 0.02 |
Compared to traditional contact methods, the proposed technique offers several advantages: it eliminates physical contact, avoiding wear on the teeth of straight spur gears; it reduces inspection time significantly (a complete measurement cycle takes less than 2 seconds); and it lowers the cost of equipment and maintenance. The measurement errors are within acceptable industrial tolerances for most applications.
The accuracy is influenced by several factors: the quality of image preprocessing, the calibration accuracy, and the threshold selection for segmentation. Optimizing these factors further improves the performance. For instance, using adaptive thresholding or sub-pixel edge detection can enhance edge localization. Future work could integrate deep learning for automatic tooth segmentation and defect detection on straight spur gears.
Conclusion
This study presents a non-contact measurement system for straight spur gears based on Halcon software. The system captures images of straight spur gears under backlight illumination, calibrates the camera, preprocesses the images, and extracts geometric parameters using Halcon operators. The method successfully measures the tip circle diameter, root circle diameter, number of teeth, module, pitch, and pitch circle diameter of straight spur gears. Experimental results show high accuracy and repeatability, with errors comparable to traditional contact methods but at a fraction of the cost and time. The approach is non-destructive and suitable for inline quality inspection of straight spur gears in manufacturing environments. The integration of machine vision with Halcon provides a flexible and powerful tool for gear parameter detection, paving the way for further automation in mechanical engineering.
