Piston rod surface defect detection method and system based on visual detection
By acquiring depth-of-field image data of the piston rod surface, calculating color saturation features, and constructing a three-dimensional model, the problem of insufficient detection accuracy of oxidation corrosion in existing technologies is solved, and accurate detection and quantitative grading of defects on the piston rod surface are achieved.
Patent Information
- Application Number
- CN202511084872.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-10-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing piston rod surface defect detection technologies are unable to fully capture the multidimensional features of oxidation and corrosion, especially lacking precision in the correlation between color features and depth information, resulting in inaccurate detection results and failing to meet the high-precision industrial requirements.
By acquiring depth image data of the piston rod surface, calculating the overall color perception shift of color saturation features, constructing a three-dimensional model of the oxidized region, dividing it into grid cells, calculating the depth gradient vector field and local curvature features, generating an oxidation degree distribution map, and correcting the boundary of the three-dimensional model, the accurate positioning and quantification of the oxidized region are achieved.
It achieves precise positioning and quantitative classification of oxidation and corrosion areas, improves detection efficiency, reduces computing power consumption, and provides reliable spatial quantitative data, providing a scientific basis for subsequent repair decisions.
Smart Images

Figure CN120852399A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual inspection technology, and in particular to a method and system for detecting surface defects in piston rods based on visual inspection. Background Technology
[0002] As a core transmission component of mechanical equipment, the piston rod's surface quality directly determines the equipment's operational accuracy, sealing performance, and service life. Surface defect detection is a crucial step in ensuring equipment reliability in industrial manufacturing. Accurately detecting the location, depth, and distribution characteristics of oxidation and corrosion on the piston rod surface not only improves equipment reliability but also proactively mitigates safety hazards caused by defects, significantly reducing maintenance costs and ensuring industrial production safety.
[0003] Existing piston rod surface defect detection technologies have significant limitations: most schemes rely on a single image acquisition method, or determine the degree of corrosion solely through the color features of two-dimensional images, or simply rely on three-dimensional modeling to obtain surface morphology, making it difficult to comprehensively capture multi-dimensional surface features. In particular, they are insufficient in understanding the correlation between the depth of oxidation corrosion and color changes—subtle differences in color saturation often correspond to different corrosion depths, but existing methods cannot establish a precise mapping between the two, resulting in insufficient accuracy in the detection results and failing to meet the demands of high-precision industrial inspection.
[0004] The core technological challenges lie in the effective fusion and accurate quantification of multi-dimensional visual information. On the one hand, the color features and depth information of oxidation corrosion lack a reliable correlation mechanism, and corrosion areas of different depths corresponding to slight color differences on the surface are often misjudged as being of the same level. On the other hand, insufficient information fusion leads to difficulties in extracting three-dimensional spatial contours. Due to the lack of effective color-depth mapping, the three-dimensional reconstruction results cannot accurately reflect the true gradient changes and curvature characteristics of the corrosion area, making it difficult to generate accurate spatial distribution contours, which directly affects the scientific nature of subsequent repair decisions. Therefore, how to fuse color features and depth information, construct an accurate three-dimensional quantification model of oxidation corrosion, and achieve accurate extraction of spatial contours has become the core bottleneck in piston rod surface defect detection. Summary of the Invention
[0005] This invention provides a method and system for detecting surface defects on piston rods based on vision inspection, so as to achieve accurate positioning, quantitative classification and boundary correction of oxidation and corrosion areas, and provide reliable support for the automated detection of surface defects on piston rods.
[0006] In a first aspect, to solve the above-mentioned technical problems, the present invention provides a method for detecting surface defects on a piston rod based on visual inspection, comprising: Acquire depth image data of the piston rod surface to generate a first image dataset; wherein the first image dataset includes at least the color saturation features of each depth level; The overall color vision shift is calculated based on the color saturation features in the first image dataset and the preset baseline color saturation features. If the overall color vision shift exceeds a preset color vision shift threshold, point cloud data is extracted from the first image dataset, and a three-dimensional model of the oxidized region is constructed by fitting the surface contour, and the first spatial contour data is output. The first spatial contour data is divided into multiple grid cells to generate a grid dataset containing grid cell size and grid cell boundary. Based on the grid dataset, the depth gradient vector field and local curvature features are calculated to obtain the oxidation depth distribution data of each grid cell; Based on the oxidation depth distribution data, the oxidation degree is classified and an oxidation degree distribution map is generated; Based on the oxidation degree distribution map and the first image dataset, the boundaries of the oxidized regions in the three-dimensional model are corrected to generate corrected second spatial contour data.
[0007] In one optional implementation, calculating the overall color perception shift based on the color saturation features in the first image dataset and a preset reference color saturation feature includes: Obtain the color saturation features for each depth level from the first image dataset; The average color saturation feature value of each depth of field level is obtained by averaging the color saturation features of each depth of field level. For each depth of field level, the average color saturation feature value of the corresponding level is substituted into the preset multi-level color vision shift calculation formula to calculate the color vision shift of each depth of field level. The overall color shift is obtained by integrating the color shifts at all depth levels.
[0008] In one optional implementation, the step of extracting point cloud data from the first image dataset, constructing a three-dimensional model of the oxidized region through surface contour fitting, and outputting first spatial contour data includes: Point cloud data is extracted from the first image dataset using a preset point cloud generation algorithm to obtain a point cloud dataset; Based on the point cloud dataset, a preset surface contour fitting algorithm is used to perform fitting processing to generate surface contour data of the oxidized region. Based on the surface contour data, a 3D reconstruction algorithm is used to perform 3D reconstruction and generate the 3D model. Based on the three-dimensional model, the spatial contour data of the oxidized region is extracted to obtain the first spatial contour data.
[0009] In one optional implementation, the step of dividing the first spatial contour data into multiple grid cells to generate a grid dataset containing grid cell sizes and grid cell boundaries includes: Extract the three-dimensional coordinate point set from the first spatial contour data, determine the spatial contour boundary of the oxidized region, and obtain the contour point set covering the entire oxidized region. Based on the spatial distribution density of the contour point set, a preset adaptive grid segmentation algorithm is used for initial partitioning to obtain preliminary grid units; Edge detection is performed on the preliminary grid cells using a boundary extraction algorithm to extract the geometric boundary coordinates and size parameters of each grid cell, generating cell boundary data that includes the grid cell size and cell boundary coordinates. The cell boundary data is processed using a lightweight compression algorithm to remove duplicate coordinate information, resulting in the grid dataset.
[0010] In one optional implementation, the step of calculating the depth gradient vector field and local curvature features based on the grid dataset to obtain the oxidation depth distribution data for each grid cell includes: The three-dimensional coordinate information of each grid cell is extracted from the grid dataset, and the actual depth value of each grid cell is determined based on the depth component in the coordinates to generate a grid cell depth dataset. Based on the grid cell depth dataset, the depth gradient vector field of each grid cell is calculated using the three-dimensional discrete difference method to obtain the depth gradient data of each grid cell. Based on the depth gradient data, a local surface model for each mesh unit is constructed using a surface fitting algorithm; The Gaussian curvature and mean curvature of the local surface are calculated using the Gaussian curvature calculation formula, and the local curvature features reflecting the surface unevenness are extracted. By combining the actual depth value, depth gradient data, and local curvature characteristics of each grid cell, the oxidation depth distribution data is generated using a spatial interpolation algorithm.
[0011] In one optional implementation, the step of classifying the degree of oxidation based on the oxidation depth distribution data and generating an oxidation degree distribution map includes: Based on the oxidation depth distribution data, a preset multi-level threshold algorithm is used to perform quantification and classification, generating oxidation degree classification results. Based on the oxidation degree grading results and combined with the spatial coordinate information of the grid dataset, the oxidation degree level of each grid cell is mapped to the three-dimensional model, and pseudo-color rendering technology is used for differentiated coloring to generate a preliminary oxidation distribution feature map. The preliminary oxidation distribution feature map is smoothed at the boundaries, and the area ratio and maximum depth value of each level region are marked to generate an oxidation degree distribution map that includes spatial distribution, level division and key quantitative indicators.
[0012] In one optional implementation, the step of correcting the boundaries of oxidized regions in the 3D model and generating corrected second spatial contour data based on the oxidation degree distribution map and the first image dataset includes: The severity classification data of each level of oxidation region is extracted from the oxidation degree distribution map, and the oxidation region is initially spatially divided to determine the three-dimensional coordinate range of the initial oxidation region. Image data corresponding to the initial oxidation region is extracted from the first image dataset, and the color saturation features of that region are extracted. Histogram analysis is used to calculate the color distribution peak, saturation mean, and gradient change rate to generate a color saturation feature vector containing the correspondence between spatial location and saturation parameters. Using the three-dimensional coordinate range of the initial oxidation region as a spatial constraint, and combining the pixel coordinates of the region corresponding to the color saturation feature vector, a preset edge detection algorithm is used to extract the color boundary feature point set of the oxidation region. The set of color boundary feature points is converted into three-dimensional spatial coordinates through calibration, and the Euclidean distance deviation between it and the boundary of the current oxidized region in the three-dimensional model is calculated. When the maximum deviation of the Euclidean distance exceeds the preset boundary error threshold, the thin plate spline interpolation algorithm is used. The three-dimensional coordinates of the color boundary feature point set are used as the reference control points to perform nonlinear coordinate adjustment on the boundary of the oxide region in the three-dimensional model that exceeds the deviation, so as to obtain the corrected oxide region boundary. Based on the corrected boundary of the oxidized region, the Bézier surface fitting algorithm is used to reconstruct the contour of the depth data of the grid cells within the boundary, generating second spatial contour data containing the boundary three-dimensional coordinates, depth gradient vector, and curvature features.
[0013] In one alternative implementation, after generating the corrected second spatial contour data, the method further includes: Based on the second spatial contour data, the depth value of each grid cell is extracted, and the mean, standard deviation and maximum deviation of the oxidation corrosion depth are calculated as statistical parameters of the depth distribution. By combining the preset accuracy evaluation indicators, the depth distribution statistical parameters are compared with the corresponding indicator thresholds to generate a detection accuracy evaluation result; If any parameter in the detection accuracy evaluation result fails to reach the preset accuracy threshold, the acquisition parameters of the depth image acquisition system are adjusted. Based on the adjusted acquisition parameters, depth image data of the piston rod surface are reacquired to generate a second image dataset; Replace the original first image dataset with the second image dataset to regenerate the second spatial contour data; The accuracy evaluation indicators include depth measurement error threshold, standard deviation threshold, and maximum deviation threshold, and the acquisition parameters include focal length, exposure time, and sampling frequency.
[0014] Secondly, the present invention also provides a piston rod surface defect detection system based on vision inspection, comprising: Image acquisition module: acquires depth image data of the piston rod surface and generates a first image dataset; wherein the first image dataset includes at least the color saturation features of each depth level; Offset calculation module: Calculates the overall color perception offset based on the color saturation features in the first image dataset and the preset reference color saturation features; 3D model construction module: If the overall color vision offset exceeds the preset color vision offset threshold, point cloud data is extracted from the first image dataset, and a 3D model of the oxidized region is constructed by fitting the surface contour, and the first spatial contour data is output. Cell partitioning module: Divides the first spatial contour data into multiple grid cells, generating a grid dataset containing grid cell sizes and grid cell boundaries; Oxidation analysis module: Based on the grid dataset, calculate the depth gradient vector field and local curvature features to obtain the oxidation depth distribution data for each grid cell; Distribution map output module: Based on the oxidation depth distribution data, classify the oxidation degree and generate an oxidation degree distribution map; 3D correction module: Based on the oxidation degree distribution map and the first image dataset, correct the boundaries of the oxidation regions in the 3D model and generate corrected second spatial contour data.
[0015] In one alternative implementation, the system further includes: Statistical analysis module: Based on the second spatial contour data, extract the depth value of each grid cell, and calculate the mean, standard deviation and maximum deviation of oxidation corrosion depth as statistical parameters of depth distribution; Accuracy assessment module: Combines the preset accuracy evaluation index, compares the depth distribution statistical parameters with the corresponding index threshold, and generates the detection accuracy assessment result; Parameter adjustment module: If any parameter in the detection accuracy evaluation result does not reach the preset accuracy threshold, the acquisition parameters of the depth image acquisition system are adjusted. Image reacquisition module: Based on the adjusted acquisition parameters, reacquire depth image data of the piston rod surface to generate a second image dataset; Loop module: Replaces the original first image dataset with the second image dataset and regenerates the second spatial contour data; The accuracy evaluation indicators include depth measurement error threshold, standard deviation threshold, and maximum deviation threshold, and the acquisition parameters include focal length, exposure time, and sampling frequency.
[0016] Compared with the prior art, the present invention has the following beneficial effects:
[0017] (1) By calculating the overall color perception offset between the color saturation features and the baseline features in the first image dataset, the oxidation corrosion detection is accurately triggered. The three-dimensional modeling process is started only when the offset exceeds the threshold, thus avoiding invalid detection operations, improving detection efficiency and reducing computing power consumption.
[0018] (2) Extract point cloud from image data and construct a three-dimensional model by fitting surface contours, output the first spatial contour data, provide a structured basis for the spatial positioning of the oxidation area, transform two-dimensional visual information into three-dimensional spatial data, and lay the geometric framework for subsequent quantitative analysis.
[0019] (3) Calculate the depth gradient vector field and local curvature features based on the grid dataset to achieve refined quantification of oxidation corrosion: the depth gradient captures the steepness of the corrosion area, and the local curvature reflects the surface concavity and convexity. The combination of the two generates accurate oxidation depth distribution data, breaking through the limitations of single feature detection.
[0020] (4) The oxidation depth distribution data is classified and an oxidation degree distribution map is generated. Through pseudo-color rendering and key indicator labeling, the spatial distribution, severity and quantitative parameters of the corrosion area are presented intuitively, providing a visual basis for corrosion assessment and improving the intuitiveness and scientific nature of defect judgment.
[0021] (5) Combine the oxidation degree distribution map with the first image dataset to correct the boundary of the three-dimensional model and generate the second spatial contour data. By fusion optimization of color boundary features and three-dimensional geometric information, the initial modeling deviation is eliminated, ensuring that the contour of the oxidation area is highly matched with the actual corrosion state, and providing reliable spatial quantitative data for subsequent repair decisions. Attached Figure Description
[0022] Figure 1 This is a schematic flowchart of a vision-based method for detecting surface defects in a piston rod, provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of a vision-based piston rod surface defect detection system provided in an embodiment of the present invention. Detailed Implementation
[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] Reference Figure 1 This invention provides a method for detecting surface defects in piston rods based on visual inspection, comprising the following steps: S11, acquire depth image data of the piston rod surface and generate a first image dataset; wherein, the first image dataset includes at least the color saturation features of each depth level; S12, calculate the overall color vision shift based on the color saturation features in the first image dataset and the preset reference color saturation features; S13, if the overall color vision shift exceeds the preset color vision shift threshold, then extract point cloud data from the first image dataset, and construct a three-dimensional model of the oxidized region by fitting the surface contour, and output the first spatial contour data. S14, the first spatial contour data is divided into multiple grid cells to generate a grid dataset containing grid cell size and grid cell boundary; S15, Based on the grid dataset, calculate the depth gradient vector field and local curvature features to obtain the oxidation depth distribution data of each grid cell; S16. Based on the oxidation depth distribution data, the oxidation degree is classified and an oxidation degree distribution map is generated; S17, Based on the oxidation degree distribution map and the first image dataset, correct the oxidation region boundaries in the three-dimensional model to generate corrected second spatial contour data.
[0025] In step S11, depth image data of the piston rod surface is acquired to generate a first image dataset; wherein, the first image dataset includes at least the color saturation features of each depth level; In one embodiment, a multi-level depth-of-field image acquisition system is used to perform the operation when acquiring depth-of-field image data of the piston rod surface to generate a first image dataset. This system is equipped with a high-resolution industrial camera (1920x1080 resolution, 60fps frame rate) and an adjustable focal length lens (focal length range 8-50mm), paired with a white LED light source (color temperature 5500K, illuminance 10000 lux). The camera adjusts its focal length every 0.5mm in a step-focusing manner, acquiring images at 10 depth-of-field levels: 0.5mm, 1.0mm…4.5mm. Each image is stored in 24-bit RGB format. For each depth-of-field level, the image is converted to the HSV color space using the cvtColor function of the OpenCV library, the S channel (saturation) data is extracted, the saturation value per pixel within that level (range 0-255) is calculated, and a normalized saturation histogram corresponding to 256 bins is generated. Simultaneously, the K-means clustering algorithm (K=3) was used to classify the saturation data at each depth level, and the degree of oxidation was labeled with preset intervals (mild oxidation 100-150, moderate 50-100, severe 0-50). The final generated first image dataset is stored in JSON format, containing the number of each depth level, the mean saturation value (e.g., 120.5), the standard deviation (e.g., 15.3), the saturation histogram data, and the oxidation degree category, fully preserving the color saturation features of each depth level.
[0026] In step S12, the overall color vision shift is calculated based on the color saturation features in the first image dataset and the preset reference color saturation features. In one implementation, when calculating the overall color perception shift, the color saturation features of each depth level are first obtained from a first image dataset. This dataset contains 10 depth-of-field images, with level numbers 1 to 10 corresponding to a depth range of 0.5 mm to 5.0 mm (each level is 0.5 mm apart). The color saturation features of each level are derived from the pixel data of the S channel in the HSV color space (range 0-255).
[0027] The average color saturation feature of each depth level is calculated: for example, the average color saturation feature value of the saturation pixel value of level 1 (0.5mm) is 145, that of level 2 (1.0mm) is 138, that of level 3 (1.5mm) is 130, and so on, until level 10 (5.0mm) has an average value of 102.
[0028] The preset multi-level color vision offset calculation formula is as follows: S n S is the average color saturation characteristic value of the nth level. 0nThe reference color saturation characteristic values for the corresponding levels are (pre-calibrated using standard non-oxidized piston rod samples; the reference values for levels 1 to 10 are 160, 155, 150, 145, 140, 135, 130, 125, 120, and 115, respectively). Substituting the data, the color vision shift for each level is calculated: Level 1 is ΔS1 = |145-160| = 15, Level 2 is ΔS2 = |138-155| = 17, Level 3 is ΔS3 = |130-150| = 20, and so on, ultimately yielding shifts of 15, 17, 20, 18, 22, 25, 23, 21, 19, and 16 for the 10 levels. A weighted average method was used to integrate the color shift values across all depth-of-field levels. For example, the weights of each level were set to be positively correlated with depth-of-field accuracy (weights for levels 1 to 10 were 0.08, 0.09, 0.10, 0.10, 0.11, 0.11, 0.10, 0.10, 0.09, and 0.08, respectively). The results were then calculated using the formula... ), where: ΔS z ΔS represents the overall color vision shift after integration. n w represents the color vision shift at the nth level. n This represents the weighting coefficient for the nth level. Substituting this value into the calculation yields an overall color vision shift of 19.2, thus completing the quantitative assessment of the color vision shift.
[0029] In step S13, if the overall color vision shift exceeds a preset color vision shift threshold, point cloud data is extracted from the first image dataset, and a three-dimensional model of the oxidized region is constructed by fitting the surface contour, and the first spatial contour data is output. In one implementation, firstly, point cloud data is extracted using a preset point cloud generation algorithm. Based on the depth image information in the first image dataset, a structured light-based point cloud generation algorithm (equipped with a Kinectv2 depth camera) is used to perform a 3D scan of the oxidized area on the piston rod surface. This algorithm converts pixel coordinates into 3D spatial coordinates by analyzing the depth differences at different depth levels, generating a point cloud dataset containing 200,000 points. The coordinate format of each point is (x, y, z) (unit: mm), and the point cloud resolution is 512×424, ensuring complete coverage of the details in the oxidized area.
[0030] Next, based on the surface contour fitting process of the point cloud dataset, with accurate registration as the core, the geometric correction and feature extraction of the point cloud data are achieved through algorithmic iterative optimization. The specific process is as follows: First, the preset surface contour fitting algorithm—the Iterative Closest Point (ICP) algorithm—is started, using the original point cloud data as input for registration optimization. Key parameters of the algorithm are set: a maximum number of iterations of 50 (to control computational efficiency) and a convergence threshold of 0.001 meters (defining the registration accuracy standard). During the iteration process, the algorithm iteratively optimizes through two core operations: first, it calculates the Euclidean distance deviation between the current point cloud and the target reference point cloud (such as the baseline model point cloud), quantifying the spatial position difference of each pair of points; second, it dynamically adjusts the point cloud coordinates according to the deviation value, minimizing the overall deviation through rigid transformations (translation, rotation). When the maximum number of iterations is reached or the deviation value is less than the convergence threshold, the registration terminates. At this time, the average error of the point cloud is controlled within 0.005 meters, ensuring the geometric consistency between the point cloud data and the actual surface morphology. Finally, based on the registered high-precision point cloud, surface normal vectors (reflecting local orientation) and curvature change trends (characterizing the degree of concavity and convexity) are further extracted, and surface contour data of the oxidized region are integrated to provide a precise geometric feature basis for subsequent 3D reconstruction.
[0031] Then, 3D reconstruction is performed based on the surface contour data. A 3D reconstruction algorithm (Poisson surface reconstruction algorithm) is used to model the surface contour data. The octree depth is set to 8 to balance detail accuracy and computational efficiency. Through topological analysis of the surface contour data and generation of triangular patches, a 3D model of the oxide region composed of 100,000 triangular patches is constructed. The side length error of the triangular patches is ≤0.01mm, accurately restoring the concave and convex shape of the oxide region.
[0032] Finally, the first spatial contour data is extracted from the 3D model. A 3D contour extraction algorithm is used to analyze the geometric features of the 3D model, extracting the boundary 3D coordinates of the oxidized region (e.g., minimum bounding box coordinates x∈[50,200]mm, y∈[30,180]mm, z∈[0,5]mm), depth extrema (maximum oxidation depth 3.2mm), and gradient curves. These are then combined with the Gaussian curvature calculation results (maximum curvature value 0.02mm). -1 This data is integrated to form the first spatial contour data, which includes geometric parameters, topological relationships, and surface features, providing a precise three-dimensional spatial reference for subsequent mesh segmentation steps.
[0033] In step S14, the first spatial contour data is divided into multiple grid cells to generate a grid dataset containing grid cell sizes and grid cell boundaries; In one implementation, the process of dividing the aforementioned first spatial contour data (including the three-dimensional coordinates, depth gradient, and curvature features of the oxidized region) into mesh cells and generating a mesh dataset is as follows:
[0034] First, a three-dimensional coordinate point set is extracted from the first spatial contour data, which contains the vertex coordinates of 100,000 triangular facets in the oxidized region. Using the piston rod axis as the X-axis (axis coordinate X=125mm), the radial direction as the Y-axis (distance from the axis), and the axial depth as the Z-axis (surface reference plane Z=0), a boundary recognition algorithm is used to filter out 5000 contour boundary vertices. The spatial contour boundary of the oxidized region is defined by feature point coordinates, such as key boundary points (50,30,0), (200,30,0), (200,180,0), (50,180,0) (bottom boundary) and (50,30,5), (200,30,5) etc. (top boundary), forming a contour point set covering the entire oxidized region.
[0035] Initial partitioning is performed based on the spatial distribution density of the contour point set: a preset adaptive mesh partitioning algorithm (quadtree partitioning algorithm) is used to dynamically adjust the mesh size according to the point set density. In regions with drastic changes in oxidation depth gradient > 0.1 mm / mm (such as the concentrated oxidation area in the middle section of the piston rod), the point set density reaches 80 points / mm², and the mesh size is set to 1 mm × 1 mm; in regions with a gentle gradient ≤ 0.1 mm / mm, the point set density is 30 points / mm², and the mesh size is set to 2 mm × 2 mm, ultimately resulting in a partitioning result containing 800 initial mesh units.
[0036] Edge detection is performed on the initial mesh cells using a boundary extraction algorithm (a 3D extension of the Canny edge detection algorithm), extracting the geometric boundary coordinates and size parameters of each mesh cell. For example, the boundary coordinates of a cell in a drastically affected region are (80,100,z1), (81,100,z2), (81,101,z3), and (80,101,z4) (z1-z4 are the depth values of the corresponding points), with a size of 1mm×1mm; the boundary of a cell in a gentle region is (150,120,z5), (152,120,z6), (152,122,z7), and (150,122,z8), with a size of 2mm×2mm. This generates cell boundary data containing the size and boundary coordinates of each cell.
[0037] A lightweight compression algorithm was used to process the cell boundary data. By retaining the boundary feature points and removing duplicate coordinate information, the original 500KB boundary data was compressed to 120KB. More than 3,000 redundant coordinates were removed, and finally a grid dataset containing the grid cell size (1mm×1mm or 2mm×2mm) and boundary coordinates was obtained, which provides a structured data foundation for subsequent oxidation depth distribution calculation.
[0038] In step S15, based on the grid dataset, the depth gradient vector field and local curvature features are calculated to obtain the oxidation depth distribution data of each grid cell; In one implementation, the process of calculating the depth gradient vector field and local curvature features and generating oxidation depth distribution data based on the aforementioned generated mesh dataset (containing 800 mesh cells, with sizes of 1mm×1mm and 2mm×2mm) is as follows:
[0039] First, the 3D coordinate information of each grid cell is extracted. The 3D coordinates (x, y, z) of the boundary vertices of each cell are obtained from the grid dataset, where the z-component is the depth value (unit: mm). For example, the boundary vertex coordinates of a 1mm×1mm cell are (80, 100, 2.1), (81, 100, 2.3), (81, 101, 2.5), and (80, 101, 2.2). By taking the average vertex depth, the actual depth value of this cell is determined to be 2.275mm. The actual depth value of a 2mm×2mm cell is calculated to be 1.85mm. Finally, a grid cell depth dataset containing the actual depth values of all cells is generated.
[0040] Based on the mesh cell depth dataset, the depth gradient vector field is calculated using the three-dimensional discrete difference method. For a 1mm × 1mm cell, the gradient in the x-direction is calculated using the depth values of adjacent cells. gradient in the y-direction Where Δx represents the size of the mesh element in the x-direction, and for a 1mm × 1mm element Δx = 1, z i-1 j represents the depth value of the adjacent cell to the right of the current cell (along the positive x-axis), and z represents the depth value of the cell to the right of the current cell. i-1 j represents the depth value of the adjacent cell to the left of the current cell (along the negative x-axis), Δy represents the size of the mesh cell in the y-direction, and for a 1mm × 1mm cell, Δy = 1mm, z i j+1 represents the depth value (in mm) of the adjacent cell above the current cell (along the positive y-axis), z i , j-1 is the depth value of the adjacent cell below the current cell (along the negative y-axis); the depth gradient vector of this cell is obtained as (0.2mm). -1 0.3mm -1 Similarly, the gradient vector (0.1mm) of the 2mm×2mm element is calculated. -1 0.15mm -1 This process generates depth gradient data for each mesh element. Based on this depth gradient data, a quadratic surface fitting algorithm is used to construct a local surface model for each mesh element. Taking a 1mm × 1mm element as an example, the surface equation is fitted using the least squares method. By substituting the coordinates and depth values of the element and adjacent elements, the coefficients are solved to obtain a surface model that reflects the local surface morphology. The Gaussian curvature calculation formula is then used. Formula for calculating mean curvature Where k1 and k2 are the two principal curvatures of the surface in this element (unit: mm). -1 The principal curvature is the maximum and minimum value of the curvature of the surface in all directions at that point, used to calculate the local curvature characteristics. A 1mm × 1mm element is calculated to have a Gaussian curvature K = 0.02mm. -2 The average curvature H = 0.015 mm -1 For a 2mm × 2mm element, K = 0.005mm. -2 H=0.008mm -1 This allows us to extract local curvature features that reflect the surface's unevenness.
[0041] Finally, combining the actual depth values, depth gradient data, and local curvature characteristics of each grid cell, the Kriging space interpolation algorithm is used to interpolate and complete the areas not directly covered by the cells, generating oxidation depth distribution data containing the oxidation depth values of each location. The data is stored in grid cells and covers the depth value range, gradient direction, and curvature level, providing a quantitative basis for subsequent oxidation degree classification.
[0042] In step S16, the oxidation degree is graded based on the oxidation depth distribution data to generate an oxidation degree distribution map; In one embodiment, the process of classifying the degree of oxidation and generating an oxidation degree distribution map based on the aforementioned generated oxidation depth distribution data (including the actual depth values, gradient data, and curvature features of 800 grid cells) is as follows:
[0043] First, a pre-set multi-level threshold algorithm is used to quantify and classify the oxidation depth distribution data. Three levels of depth thresholds are set: light oxidation (depth ≤ 1.5 mm), moderate oxidation (depth ≤ 3.0 mm, depth > 1.5 mm), and severe oxidation (depth > 3.0 mm). The threshold range is matched to each of the 800 grid cells. For example, a 1 mm × 1 mm cell (actual depth 2.275 mm) is classified as moderate oxidation, and a 2 mm × 2 mm cell (actual depth 1.85 mm) is also classified as moderate oxidation. The final oxidation degree classification results are: 280 lightly oxidized cells, 360 moderately oxidized cells, and 160 severely oxidized cells.
[0044] Based on the grading results and the spatial coordinate information of the grid dataset, the oxidation level of each grid cell is mapped to the 3D model of the piston rod. A pseudo-color rendering technique is used for differentiated coloring: lightly oxidized areas are rendered as green (RGB value (0,255,0)), moderately oxidized areas as yellow (RGB value (255,255,0)), and heavily oxidized areas as red (RGB value (255,0,0)). This generates a preliminary oxidation distribution feature map, which visually distinguishes the spatial distribution of areas with different oxidation levels. The heavily oxidized areas are concentrated in the 1mm×1mm dense grid area in the middle section of the piston rod.
[0045] The preliminary oxidation distribution feature map undergoes boundary smoothing, and a Gaussian filtering algorithm is used to blur and optimize the region edges, eliminating jagged boundaries caused by mesh division. Quantitative indicators for each oxidation level are labeled on the map: lightly oxidized areas account for 35% of the area (corresponding to an actual area of 2100 mm²) with a maximum depth of 1.2 mm; moderately oxidized areas account for 45% of the area (corresponding to an actual area of 2700 mm²) with a maximum depth of 2.5 mm; and heavily oxidized areas account for 20% of the area (corresponding to an actual area of 1200 mm²) with a maximum depth of 4.0 mm. The final oxidation degree distribution map includes the spatial distribution of oxidation degree, the three-level classification, and key quantitative indicators, providing accurate region division criteria for subsequent boundary correction.
[0046] In step S17, based on the oxidation degree distribution map and the first image dataset, the boundaries of the oxidation regions in the three-dimensional model are corrected to generate corrected second spatial contour data.
[0047] In one embodiment, the process of correcting the boundaries of the oxidized regions in the 3D model and generating the second spatial contour data based on the aforementioned generated oxidation degree distribution map (including light, moderate, and heavy oxidation region classifications) and the first image dataset is as follows: The severity grading data of each oxidation level was extracted from the oxidation degree distribution map. The lightly oxidized area accounted for 35% of the total area with a maximum depth of 1.2 mm; the moderately oxidized area accounted for 45% with a maximum depth of 2.5 mm; and the heavily oxidized area accounted for 20% with a maximum depth of 4.0 mm. The oxidation area was initially spatially divided using the piston rod axis as the X-axis reference (axis coordinate X=125 mm), the radial direction as the Y-axis (farthest point from the axis Y=180 mm), and the axial depth as the Z-axis (surface reference plane Z=0). The initial three-dimensional coordinate range of the oxidation area was determined as follows: axial direction X∈[50,200] mm (covering the entire 150 mm length of the piston rod detection section), radial direction Y∈[30,180] mm (range 25-155 mm from the axis), and axial depth Z∈[0,5] mm (the depth of the depression relative to the surface reference plane).
[0048] Image data within this coordinate range is extracted from the first image dataset. After extracting color saturation features, histogram analysis is performed to obtain a distribution peak of 120, a mean saturation of 95, and a gradient change rate of 0.15. A color saturation feature vector containing the correspondence between pixel coordinates and saturation parameters is generated, where the heavily oxidized region corresponds to a mean saturation of 55, and the lightly oxidized region corresponds to a mean of 130.
[0049] Using the initial 3D coordinates of the oxidized region as spatial constraints, and combining the pixel coordinates of the feature vector, the Canny edge detection algorithm was used to extract the color boundary feature point set of the oxidized region, resulting in 2000 boundary feature points with pixel coordinates ranging from u∈[800,1500] to v∈[500,1200], where u is the horizontal direction and v is the vertical direction. These pixels were converted into 3D spatial coordinates using the camera intrinsic and extrinsic parameter calibration matrix. For example, a feature point was converted to (120,90,2.5)mm (meaning it is located at 120mm along the axis, 90mm radially, and 2.5mm deep).
[0050] The Euclidean distance deviation between the 3D coordinates of the color boundary feature point set and the corresponding points on the current oxidation region boundary of the 3D model is calculated using the formula. , where (x i ,y i ,z i (x) represents the three-dimensional coordinates of the feature point. i ′,y i ′,z i ′) represents the coordinates of the point corresponding to the model boundary. The maximum deviation max(d) is calculated. i =3.2mm, exceeding the preset boundary error threshold of 2mm, triggering boundary correction.
[0051] A thin-plate spline interpolation algorithm was used, with the 3D coordinates of 2000 color boundary feature points as reference control points, to perform nonlinear coordinate adjustment on the boundary of the oxide region in the 3D model where the deviation exceeded the standard. After adjustment, the maximum deviation of the boundary points was reduced to 0.8 mm. Based on the corrected boundary, a Bezier surface fitting algorithm was used to reconstruct the contour of the depth data of 800 mesh cells within the boundary, generating a depth gradient vector including the boundary 3D coordinates (e.g., corrected boundary vertices (52,31,0.2) mm, (198,179,4.8) mm) and the depth gradient vector (e.g., (0.15,0.22) mm). -1 ) and curvature characteristics (maximum Gaussian curvature 0.025mm) -2 The second spatial contour data provides a precise three-dimensional morphological basis for defect assessment.
[0052] In one optional implementation, based on the aforementioned generated second spatial contour data (including corrected depth values, gradient vectors, and curvature features of 800 grid cells), the process for evaluating detection accuracy and optimizing parameters is as follows: The depth value (unit: mm) of each grid cell is extracted from the second spatial contour data, where the depth value range for a 1mm × 1mm cell is 1.8-3.2mm, and for a 2mm × 2mm cell it is 0.5-2.0mm. Three types of depth distribution statistical parameters are calculated through statistical analysis: the mean oxidation corrosion depth is 1.95mm, reflecting the overall corrosion depth level; the standard deviation is 0.82mm, reflecting the dispersion of depth values; and the maximum deviation is 2.7mm, which is the difference between the deepest and shallowest depths among all cells. The results are compared with preset accuracy evaluation indicators, where the depth measurement error threshold is set to 0.1mm, the standard deviation threshold is set to 0.6mm, and the maximum deviation threshold is set to 2.0mm. After comparison, it was found that both the standard deviation (0.82mm) and the maximum deviation (2.7mm) exceeded the corresponding thresholds, and the detection accuracy assessment result was "unsatisfactory," requiring the parameter adjustment process to be initiated. The acquisition parameters of the depth-of-field image acquisition system were adjusted: the focal length was increased from 25mm to 30mm to improve local detail resolution, the exposure time was extended from 20ms to 25ms to reduce image noise, and the sampling frequency was increased from 10Hz to 15Hz to increase point cloud data density. Based on the adjusted parameters, depth-of-field images of the piston rod surface were reacquired, generating a second image dataset containing 12 depth levels (saturation feature signal-to-noise ratio improved by 30%). The second image dataset replaced the original first image dataset, and the 3D modeling, mesh generation, depth analysis, and boundary correction steps were repeated to generate new second spatial contour data. Statistical parameters were recalculated on the new data, yielding a mean depth of 1.92mm, a standard deviation of 0.55mm (below the threshold), and a maximum deviation of 2.0mm (just meeting the standard). All parameters met the accuracy evaluation criteria, the detection process terminated, and the final second spatial contour data was output. This closed-loop optimization mechanism enables dynamic feedback from accuracy assessment to parameter adjustment, effectively improving the stability and accuracy of piston rod surface defect detection.
[0053] refer to Figure 2 The second embodiment of the invention provides a vision-based piston rod surface defect detection system, comprising: Image acquisition module: acquires depth image data of the piston rod surface and generates a first image dataset; wherein the first image dataset includes at least the color saturation features of each depth level; Offset calculation module: Calculates the overall color perception offset based on the color saturation features in the first image dataset and the preset reference color saturation features; 3D model construction module: If the overall color vision offset exceeds the preset color vision offset threshold, point cloud data is extracted from the first image dataset, and a 3D model of the oxidized region is constructed by fitting the surface contour, and the first spatial contour data is output. Cell partitioning module: Divides the first spatial contour data into multiple grid cells, generating a grid dataset containing grid cell sizes and grid cell boundaries; Oxidation analysis module: Based on the grid dataset, calculate the depth gradient vector field and local curvature features to obtain the oxidation depth distribution data for each grid cell; Distribution map output module: Based on the oxidation depth distribution data, classify the oxidation degree and generate an oxidation degree distribution map; 3D correction module: Based on the oxidation degree distribution map and the first image dataset, correct the boundaries of the oxidation regions in the 3D model and generate corrected second spatial contour data.
[0054] In one alternative implementation, the system further includes: Statistical analysis module: Based on the second spatial contour data, extract the depth value of each grid cell, and calculate the mean, standard deviation and maximum deviation of oxidation corrosion depth as statistical parameters of depth distribution; Accuracy assessment module: Combines the preset accuracy evaluation index, compares the depth distribution statistical parameters with the corresponding index threshold, and generates the detection accuracy assessment result; Parameter adjustment module: If any parameter in the detection accuracy evaluation result does not reach the preset accuracy threshold, the acquisition parameters of the depth image acquisition system are adjusted. Image reacquisition module: Based on the adjusted acquisition parameters, reacquire depth image data of the piston rod surface to generate a second image dataset; Loop module: Replaces the original first image dataset with the second image dataset and regenerates the second spatial contour data; The accuracy evaluation indicators include depth measurement error threshold, standard deviation threshold, and maximum deviation threshold, and the acquisition parameters include focal length, exposure time, and sampling frequency.
[0055] It should be noted that the vision-based piston rod surface defect detection system provided in this embodiment of the invention is used to execute all the process steps of the vision-based piston rod surface defect detection method in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.
[0056] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for detecting surface defects in a piston rod based on visual inspection, characterized in that, include: Acquire depth image data of the piston rod surface to generate a first image dataset; wherein the first image dataset includes at least the color saturation features of each depth level; The overall color vision shift is calculated based on the color saturation features in the first image dataset and the preset baseline color saturation features. If the overall color vision shift exceeds a preset color vision shift threshold, point cloud data is extracted from the first image dataset, and a three-dimensional model of the oxidized region is constructed by fitting the surface contour, and the first spatial contour data is output. The first spatial contour data is divided into multiple grid cells to generate a grid dataset containing grid cell size and grid cell boundary. Based on the grid dataset, the depth gradient vector field and local curvature features are calculated to obtain the oxidation depth distribution data of each grid cell; Based on the oxidation depth distribution data, the oxidation degree is classified and an oxidation degree distribution map is generated; Based on the oxidation degree distribution map and the first image dataset, the boundaries of the oxidized regions in the three-dimensional model are corrected to generate corrected second spatial contour data.
2. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, The step of calculating the overall color perception shift based on the color saturation features in the first image dataset and the preset reference color saturation features includes: Obtain the color saturation features for each depth level from the first image dataset; The average color saturation feature value of each depth of field level is obtained by averaging the color saturation features of each depth of field level. For each depth of field level, the average color saturation feature value of the corresponding level is substituted into the preset multi-level color vision shift calculation formula to calculate the color vision shift of each depth of field level. The overall color shift is obtained by integrating the color shifts at all depth levels.
3. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, The step of extracting point cloud data from the first image dataset, constructing a three-dimensional model of the oxidized region through surface contour fitting, and outputting first spatial contour data includes: Point cloud data is extracted from the first image dataset using a preset point cloud generation algorithm to obtain a point cloud dataset; Based on the point cloud dataset, a preset surface contour fitting algorithm is used to perform fitting processing to generate surface contour data of the oxidized region. Based on the surface contour data, a 3D reconstruction algorithm is used to perform 3D reconstruction and generate the 3D model. Based on the three-dimensional model, the spatial contour data of the oxidized region is extracted to obtain the first spatial contour data.
4. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, The step of dividing the first spatial contour data into multiple grid cells to generate a grid dataset containing grid cell sizes and grid cell boundaries includes: Extract the three-dimensional coordinate point set from the first spatial contour data, determine the spatial contour boundary of the oxidized region, and obtain the contour point set covering the entire oxidized region. Based on the spatial distribution density of the contour point set, a preset adaptive grid segmentation algorithm is used for initial partitioning to obtain preliminary grid units; Edge detection is performed on the preliminary grid cells using a boundary extraction algorithm to extract the geometric boundary coordinates and size parameters of each grid cell, generating cell boundary data that includes the grid cell size and cell boundary coordinates. The cell boundary data is processed using a lightweight compression algorithm to remove duplicate coordinate information, resulting in the grid dataset.
5. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, The step of calculating the depth gradient vector field and local curvature features based on the grid dataset to obtain the oxidation depth distribution data for each grid cell includes: The three-dimensional coordinate information of each grid cell is extracted from the grid dataset, and the actual depth value of each grid cell is determined based on the depth component in the coordinates to generate a grid cell depth dataset. Based on the grid cell depth dataset, the depth gradient vector field of each grid cell is calculated using the three-dimensional discrete difference method to obtain the depth gradient data of each grid cell. Based on the depth gradient data, a local surface model for each mesh unit is constructed using a surface fitting algorithm; The Gaussian curvature and mean curvature of the local surface are calculated using the Gaussian curvature calculation formula, and the local curvature features reflecting the surface unevenness are extracted. By combining the actual depth value, depth gradient data, and local curvature characteristics of each grid cell, the oxidation depth distribution data is generated using a spatial interpolation algorithm.
6. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, The step of classifying the degree of oxidation based on the oxidation depth distribution data and generating an oxidation degree distribution map includes: Based on the oxidation depth distribution data, a preset multi-level threshold algorithm is used to perform quantification and classification, generating oxidation degree classification results. Based on the oxidation degree grading results and combined with the spatial coordinate information of the grid dataset, the oxidation degree level of each grid cell is mapped to the three-dimensional model, and pseudo-color rendering technology is used for differentiated coloring to generate a preliminary oxidation distribution feature map. The preliminary oxidation distribution feature map is smoothed at the boundaries, and the area ratio and maximum depth value of each level region are marked to generate an oxidation degree distribution map that includes spatial distribution, level division and key quantitative indicators.
7. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, The step of correcting the boundaries of oxidized regions in the 3D model and generating corrected second spatial contour data based on the oxidation degree distribution map and the first image dataset includes: The severity classification data of each level of oxidation region is extracted from the oxidation degree distribution map, and the oxidation region is initially spatially divided to determine the three-dimensional coordinate range of the initial oxidation region. Image data corresponding to the initial oxidation region is extracted from the first image dataset, and the color saturation features of that region are extracted. Histogram analysis is used to calculate the color distribution peak, saturation mean, and gradient change rate to generate a color saturation feature vector containing the correspondence between spatial location and saturation parameters. Using the three-dimensional coordinate range of the initial oxidation region as a spatial constraint, and combining the pixel coordinates of the region corresponding to the color saturation feature vector, a preset edge detection algorithm is used to extract the color boundary feature point set of the oxidation region. The set of color boundary feature points is converted into three-dimensional spatial coordinates through calibration, and the Euclidean distance deviation between it and the boundary of the current oxidized region in the three-dimensional model is calculated. When the maximum deviation of the Euclidean distance exceeds the preset boundary error threshold, the thin plate spline interpolation algorithm is used. The three-dimensional coordinates of the color boundary feature point set are used as the reference control points to perform nonlinear coordinate adjustment on the boundary of the oxide region in the three-dimensional model that exceeds the deviation, so as to obtain the corrected oxide region boundary. Based on the corrected boundary of the oxidized region, the Bézier surface fitting algorithm is used to reconstruct the contour of the depth data of the grid cells within the boundary, generating second spatial contour data containing the boundary three-dimensional coordinates, depth gradient vector, and curvature features.
8. The method for detecting surface defects of a piston rod based on vision inspection according to claim 1, characterized in that, After generating the corrected second spatial contour data, the following is also included: Based on the second spatial contour data, the depth value of each grid cell is extracted, and the mean, standard deviation and maximum deviation of the oxidation corrosion depth are calculated as statistical parameters of the depth distribution. By combining the preset accuracy evaluation indicators, the depth distribution statistical parameters are compared with the corresponding indicator thresholds to generate a detection accuracy evaluation result; If any parameter in the detection accuracy evaluation result fails to reach the preset accuracy threshold, the acquisition parameters of the depth image acquisition system are adjusted. Based on the adjusted acquisition parameters, depth image data of the piston rod surface are reacquired to generate a second image dataset; Replace the original first image dataset with the second image dataset to regenerate the second spatial contour data; The accuracy evaluation indicators include depth measurement error threshold, standard deviation threshold, and maximum deviation threshold, and the acquisition parameters include focal length, exposure time, and sampling frequency.
9. A vision-based piston rod surface defect detection system, characterized in that, include: Image acquisition module: acquires depth image data of the piston rod surface and generates a first image dataset; wherein the first image dataset includes at least the color saturation features of each depth level; Offset calculation module: Calculates the overall color perception offset based on the color saturation features in the first image dataset and the preset reference color saturation features; 3D model construction module: If the overall color vision offset exceeds the preset color vision offset threshold, point cloud data is extracted from the first image dataset, and a 3D model of the oxidized region is constructed by fitting the surface contour, and the first spatial contour data is output. Cell partitioning module: Divides the first spatial contour data into multiple grid cells, generating a grid dataset containing grid cell sizes and grid cell boundaries; Oxidation analysis module: Based on the grid dataset, calculate the depth gradient vector field and local curvature features to obtain the oxidation depth distribution data for each grid cell; Distribution map output module: Based on the oxidation depth distribution data, classify the oxidation degree and generate an oxidation degree distribution map; 3D correction module: Based on the oxidation degree distribution map and the first image dataset, correct the boundaries of the oxidation regions in the 3D model and generate corrected second spatial contour data.
10. A piston rod surface defect detection system based on vision inspection according to claim 9, characterized in that, The system further comprises: Statistical analysis module: Based on the second spatial contour data, extract the depth value of each grid cell, and calculate the mean, standard deviation and maximum deviation of oxidation corrosion depth as statistical parameters of depth distribution; Accuracy assessment module: Combines the preset accuracy evaluation index, compares the depth distribution statistical parameters with the corresponding index threshold, and generates the detection accuracy assessment result; Parameter adjustment module: If any parameter in the detection accuracy evaluation result does not reach the preset accuracy threshold, the acquisition parameters of the depth image acquisition system are adjusted. Image reacquisition module: Based on the adjusted acquisition parameters, reacquire depth image data of the piston rod surface to generate a second image dataset; Loop module: Replaces the original first image dataset with the second image dataset and regenerates the second spatial contour data; The accuracy evaluation indicators include depth measurement error threshold, standard deviation threshold, and maximum deviation threshold, and the acquisition parameters include focal length, exposure time, and sampling frequency.
Citation Information
Cited By
Sweet menu embryo pelleting seed breakage rate detection method based on machine vision
CN121033039A
