Piston casting defect identification system based on visual inspection
By acquiring a continuous image sequence on the surface of a piston casting, analyzing the movement trajectory of the light spot, and identifying abnormal features, the problems of false detection and missed detection in piston casting defect identification in the prior art are solved, and high-reliability and high-precision defect detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAXIANG (YICHENG) IND EQUIP CO LTD
- Filing Date
- 2026-01-20
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies struggle to distinguish between stable optical features caused by geometric morphology and instantaneous dynamic reflections caused by process deposits under complex imaging conditions, resulting in high false detection or false negative rates for piston casting defect identification.
By rotating the piston casting at a constant speed and illuminating it with a fixed point light source, a continuous image sequence of reflected light spots on the surface is obtained. The movement trajectory of the light spots is analyzed, the brightness centroid is extracted using the trajectory generation module, and the trajectory abnormality features are identified by the data analysis module. The abnormal features are then located on the surface of the piston casting using the data mapping module, and a defect report is generated using the defect identification model.
It improves the accuracy of defect identification in piston castings, significantly reduces the false detection rate, and ensures high reliability and high precision detection in complex production environments.
Smart Images

Figure CN121937431A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of surface defect detection technology for castings, and specifically to a visual inspection-based defect identification system for piston castings. Background Technology
[0002] In the manufacturing process of piston castings, their surface quality (such as the presence of surface defects like scratches, dents, pits, and protrusions) directly affects the final performance and reliability of the engine. Therefore, defect detection of piston castings, especially their outer cylindrical working surfaces, before leaving the factory is a critical process.
[0003] Machine vision can quickly identify defects in piston castings. However, the specular reflective properties of piston casting surfaces can cause highlight areas in the acquired images. These highlights can severely obscure the true surface texture beneath, leading to missed defects. To overcome this interference, existing technologies employ special lighting (such as polarized light), multi-angle imaging, or complex image processing algorithms to suppress highlights. However, these methods rely on a fundamental technical premise: that by adjusting optical conditions or enhancing image processing, it is possible to separate the interfering specular reflections from the true surface morphology features in a single point-in-time image.
[0004] However, this premise is profoundly contradictory to the complex working conditions in the actual production of piston castings. In real machining and flow environments, the workpiece surface is usually covered with a non-structural fluid film composed of cutting fluid, rust-preventive oil, etc. Under illumination, the brightness distribution, color features, and even local textures formed by these deposits in a single frame image may be highly similar to permanent defects caused by changes in geometric morphology (such as pits and protrusions). Existing technologies attempt to solve an essential "one-to-many" classification problem within a single image frame, namely, distinguishing the completely different physical causes behind the same type of optical performance.
[0005] Therefore, existing methods relying on single-frame image analysis, regardless of the complexity of their front-end optical systems, have an inherent upper limit in their ability to distinguish between "geometric defects" and "fluid deposit artifacts." The direct technical consequence is that in subsequent defect identification and classification stages, transient artifacts are easily misclassified as real defects, leading to a significantly increased false detection rate. Conversely, setting overly strict discrimination thresholds to improve specificity may result in the failure to detect real morphological defects with low contrast. Existing technologies fail to capture and utilize the essential differences in the temporal dynamics of defects and artifacts, thus severely limiting the ability to achieve high-reliability, high-precision defect identification in complex industrial environments. Summary of the Invention
[0006] The purpose of this invention is to provide a visual inspection-based defect identification system for piston castings, addressing the following technical problems: Existing technologies struggle to distinguish between stable optical features caused by geometric morphology and instantaneous dynamic reflections caused by process deposits. This results in inaccurate identification of real surface defects and filtering of artifact interference under complex imaging conditions, thus limiting the overall reliability of automatic defect identification.
[0007] The objective of this invention can be achieved through the following technical solutions: A vision-based piston casting defect identification system includes: The image acquisition module is used to acquire a continuous image sequence of reflected light spots on the surface of the piston casting based on the illumination of the outer cylindrical surface of the piston casting at a uniform speed and a fixed point light source, through a synchronously triggered image acquisition device. The trajectory generation module is used to extract the high-brightness region and calculate the brightness centroid of the continuous image sequence frame by frame, and connect the centroid pixel coordinates of each frame according to the acquisition time order to generate a pixel trajectory sequence of the light spot movement path. The data analysis module is used to identify abrupt changes in the centroid pixel coordinates and abnormal slowdowns in the movement speed in the pixel trajectory sequence, locate and mark them as trajectory discontinuities and trajectory stalls, which together constitute a set of abnormal pixel trajectory features. The data mapping module is used to establish a mapping function between image acquisition time and piston casting rotation angle, and based on the mapping function, to map the pixel trajectory abnormal feature set to the outer cylindrical surface of the piston casting, thereby obtaining the circumferential position set and axial position set corresponding to any trajectory abnormal feature, forming a defect position coordinate set. The result generation module is used to extract local surface images corresponding to the circumferential and axial positions from the continuous image sequence according to the defect location coordinate set and input them into a preset defect recognition model. Based on the recognition results output by the defect recognition model, a structured defect recognition report containing the spatial location of the defect is generated.
[0008] As a further aspect of the present invention: the specific acquisition process of the continuous image sequence in the image acquisition module is as follows: The piston casting is driven to rotate at a constant speed around its central axis by a supporting mechanism. At the same time, a fixed point light source is used to illuminate the outer cylindrical surface of the piston casting at a constant incident angle. The image acquisition device is triggered synchronously with the rotation and illumination process, and continuously acquires images of the light spot area formed by specular reflection on the outer cylindrical surface of the piston casting under the rotation state, thereby obtaining an image sequence composed of multiple consecutive surface images in the time dimension.
[0009] As a further aspect of the present invention: the specific generation process of the pixel trajectory sequence in the trajectory generation module is as follows: The row and column distribution of the pixel matrix on the imaging target surface of the image acquisition device is obtained, and a corresponding two-dimensional pixel coordinate system is established; based on the two-dimensional pixel coordinate system, the horizontal coordinate, vertical coordinate, and brightness value of all pixels in each frame of the continuous image sequence are obtained; In each frame of the image, all pixels with brightness values higher than a preset grayscale threshold are selected. The selected pixels in each frame of the image are subjected to morphological closing operations to obtain a connected high-brightness region. For the high-brightness region in each frame of the image, the weighted average of the horizontal and vertical coordinates of all pixels in the region with their respective brightness values is calculated. The two weighted averages are used as the brightness centroid pixel coordinates of the high-brightness region in the frame of the image. According to the image frame acquisition time sequence of the continuous image sequence, the brightness centroid pixel coordinates obtained in each frame image are connected by line segments in the two-dimensional pixel coordinate system to generate a pixel trajectory sequence representing the movement path of the light spot.
[0010] As a further aspect of the present invention: the specific process for obtaining the pixel trajectory anomaly feature set in the data analysis module is as follows: Based on the sequentially arranged brightness centroid pixel coordinates in the pixel trajectory sequence, the Euclidean distance between every two adjacent coordinate points is calculated to obtain the displacement distance sequence; all displacement values in the displacement distance sequence are sorted, and the displacement fluctuation range is determined based on the box plot algorithm; displacements whose values are outside the displacement fluctuation range are identified as abnormal displacements, and the two brightness centroid pixel coordinates corresponding to each abnormal displacement are marked as a trajectory discontinuity point. On the pixel trajectory sequence, a fixed frame length window is used to slide and capture continuous coordinate subsequences from the starting point to generate several trajectory segments; for each trajectory segment, the sum of the displacement distances of all adjacent coordinate points in the trajectory segment is calculated as the ratio of the number of frames to obtain the average moving speed of the trajectory segment, and the average moving speed of all trajectory segments is obtained to form an average moving speed sequence. All speed values in the average moving speed sequence are sorted and the speed fluctuation range is determined based on the box plot algorithm; trajectory segments with average moving speeds lower than the lower limit of the speed fluctuation range are identified as abnormally slow trajectory segments, and each abnormally slow trajectory segment is marked as a trajectory stagnation segment; all marked trajectory discontinuities and trajectory stagnation segments are collected to form the pixel trajectory abnormal feature set.
[0011] As a further aspect of the present invention: the specific process of establishing the mapping function between image acquisition time and piston casting rotation angle in the data mapping module is as follows: Before the piston casting begins to rotate at a constant speed, a static image of it is acquired, and a preset visual marker point on the outer cylindrical surface of the piston casting in the static image is identified and located. The radial direction where the visual marker point is located is used as the zero point of the angle measurement and is defined as the initial angular position. Obtain the constant angular velocity of the bearing mechanism that drives the piston casting to rotate, and record the time point when the first frame image in the continuous image sequence is acquired as the time zero point; Based on the constant angular velocity, calculate the increment of the angle through which the piston casting rotates during the time interval from the zero point of time to any subsequent image acquisition time point; Add the angle increment to the initial angle position to obtain the absolute value of the piston casting rotation angle corresponding to the image acquisition time point, thus obtaining a mapping function that takes the image acquisition time point as input and the corresponding absolute value of the piston casting rotation angle as output.
[0012] As a further aspect of the present invention: the specific generation process of forming the defect location coordinate set in the data mapping module is as follows: For each abnormal feature point in the pixel trajectory abnormal feature set, the corresponding piston casting rotation angle is determined as the circumferential position of the point based on its image acquisition timestamp and the mapping function. Before the piston casting starts to rotate at a constant speed, a static image of it is acquired. In the static image, a first reference point preset at the top of the piston casting and a second reference point known at the bottom are selected. The actual physical height difference between the first reference point and the second reference point and the difference of their vertical coordinate pixel values are obtained, and the vertical pixel ratio coefficient is calculated. The vertical coordinate pixel value of each abnormal feature point is combined with the vertical pixel ratio coefficient and the vertical coordinate pixel value of the first reference point to calculate the physical distance of the point relative to the first reference point along the axis of the piston casting, which is used as its axial position. The circumferential and axial positions of each abnormal feature point are combined to form its position coordinates on the outer cylindrical surface of the piston casting; the position coordinates of all abnormal feature points are collected to form the defect position coordinate set.
[0013] As a further aspect of the present invention: the specific construction process of the defect identification model in the result generation module is as follows: Collect historical image samples containing defects on the outer cylindrical surface of piston castings, label the defect areas in the historical image samples according to preset categories and record their pixel positions, and establish a labeled defect image sample library. Local image patches corresponding to each defect region are extracted from the labeled defect image sample library, and each local image patch is associated with its labeled defect category to form a training sample pair set; A neural network model is pre-constructed. Local image patches from the training sample set are input into the neural network model for forward propagation calculation to obtain defect category prediction results. The difference between the prediction results and the corresponding real defect category labels is calculated, and the parameters of the neural network model are iteratively adjusted multiple times through the backpropagation algorithm. After each iteration, the model performance is evaluated using an independent validation set until the evaluation results reach the preset performance standard, thus obtaining a defect recognition model.
[0014] As a further aspect of the present invention: the result generation module further includes inputting the local surface image determined to be normal and the corresponding defect location coordinates into the manual annotation platform for manual calibration, and using the manual calibration result as the final recognition result; adding the defect categories in the local surface image involved in the manual calibration and the corresponding final recognition result to the training sample pair set, and iteratively training and updating the defect recognition model.
[0015] The beneficial effects of this invention are: 1) By establishing a "moving reflective probe" model, specular reflection is transformed from imaging interference into detection information. This invention uses the specular reflection highlights formed by a point light source on the surface of a rotating workpiece as a scanning probe. Understandably, on a normal casting surface, the movement trajectory of the highlight point is continuous and regular. When the casting surface has micro-pits or scratches, the surface geometry undergoes abrupt changes, leading to discontinuous changes in the surface normal direction. This physical change directly causes a detectable jump or interruption in the highlight point's movement trajectory at the corresponding position. Therefore, this invention, by analyzing the continuity of the trajectory, essentially perceives the continuity of the surface's micro-geometry, thereby penetrating the strong reflective appearance and directly and stably detecting depression-like defects masked by the highlight.
[0016] 2) This invention constructs a physical criterion for distinguishing between permanent deformation and transient attachments by analyzing the temporal stability of trajectory dynamics characteristics, significantly improving the accuracy of identification in complex production environments. It is understandable that trajectory velocity anomalies caused by inherent geometric deformations (such as protrusions) on the surface of casting workpieces will manifest as persistent abnormal segments with fixed positions and repetitive shapes during continuous workpiece rotation, exhibiting temporal stability. In contrast, interference caused by fluid attachments such as lubricating oil films, while potentially producing transient bright spots, cannot form stable, repetitive trajectory distortions at the same rotational phase. By analyzing the statistical distribution of trajectory velocity, "trajectory stagnation segments" that continuously and significantly deviate from the normal velocity band can be accurately identified. Their statistical significance allows them to be reliably separated from random transient noise. This mechanism ensures that this invention only responds to inherent morphological defects in the workpiece, effectively filtering out inherent, random attachment artifacts in the production process.
[0017] 3) This invention employs a collaborative architecture of "initial screening based on physical mechanisms, precise judgment using visual models, and closed-loop feedback optimization" to improve real-time processing efficiency while ensuring long-term system reliability and self-evolution capabilities. First, this invention utilizes trajectory analysis based on optical physics to quickly locate surface anomaly regions from massive images, precisely focusing computational resources on a small number of suspicious locations. This allows the recognition model to judge only local images, significantly increasing detection throughput to meet online processing speeds. Considering potential ambiguity or errors in model judgment during this process, a targeted error correction mechanism is implemented. Low-confidence results are submitted to a manual annotation platform for adjudication, leveraging expert experience to efficiently resolve difficult samples and ensuring the reliability of the final results. New samples and annotations generated by manual adjudication are immediately fed back to the model training library, driving iterative model updates. This transforms each manual intervention into system learning experience, forming a closed loop from "anomaly detection - manual verification - model learning," gradually reducing reliance on manual intervention and achieving continuous synergistic growth in recognition accuracy and processing efficiency. Attached Figure Description
[0018] The invention will now be further described with reference to the accompanying drawings.
[0019] Figure 1 This is a schematic diagram of the structure of a piston casting defect identification system based on visual inspection according to the present invention. Detailed Implementation
[0020] 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.
[0021] Please see Figure 1 As shown, the present invention is a visual inspection-based defect identification system for piston castings, comprising: The image acquisition module is used to acquire a continuous image sequence of reflected light spots on the surface of the piston casting based on the illumination of the outer cylindrical surface of the piston casting at a uniform speed and a fixed point light source, through a synchronously triggered image acquisition device. The trajectory generation module is used to extract the high-brightness region and calculate the brightness centroid of the continuous image sequence frame by frame, and connect the centroid pixel coordinates of each frame according to the acquisition time order to generate a pixel trajectory sequence of the light spot movement path. The data analysis module is used to identify abrupt changes in the centroid pixel coordinates and abnormal slowdowns in the movement speed in the pixel trajectory sequence, locate and mark them as trajectory discontinuities and trajectory stalls, which together constitute a set of abnormal pixel trajectory features. The data mapping module is used to establish a mapping function between image acquisition time and piston casting rotation angle, and based on the mapping function, to map the pixel trajectory abnormal feature set to the outer cylindrical surface of the piston casting, thereby obtaining the circumferential position set and axial position set corresponding to any trajectory abnormal feature, forming a defect position coordinate set. The result generation module is used to extract local surface images corresponding to the circumferential and axial positions from the continuous image sequence according to the defect location coordinate set and input them into a preset defect recognition model. Based on the recognition results output by the defect recognition model, a structured defect recognition report containing the spatial location of the defect is generated.
[0022] First, a piston casting is driven to rotate uniformly around its central axis by a supporting mechanism. Simultaneously, a fixed, high-brightness point light source illuminates the outer cylindrical surface of the piston casting at a constant and precisely calculated angle (typically 30 to 60 degrees). This point light source generates a highly concentrated specular reflection spot on the highly smooth metal surface. Uniform rotation provides a stable time reference for subsequent analysis. An image acquisition device (such as a high-speed industrial camera) is synchronously triggered with the rotary axis encoder or timer, ensuring that each frame precisely corresponds to a specific instantaneous phase during piston rotation. Images of the light spot area are continuously acquired during rotation, obtaining a time-strictly continuous sequence of multiple surface images. This transforms the originally static and difficult-to-analyze highly reflective area into a continuously varying optical signal sequence in both time and space, laying the foundation for converting reflection from interference into a detection medium. After acquiring a continuous image sequence, the system establishes a two-dimensional pixel coordinate system on the inherent pixel matrix of the image acquisition device. For each frame in the sequence, pixels with significantly higher brightness than the background are selected based on a preset grayscale threshold; these pixels correspond to areas of strong specular reflection. Through morphological closing operations, bright spot areas that may be broken due to noise or slight inhomogeneity are connected into a connected whole, thereby accurately extracting a unique and complete high-brightness region in each frame. Next, for this region, the weighted average of the horizontal and vertical coordinates of all pixels is calculated using the brightness value of each pixel as a weight, yielding the brightness centroid pixel coordinates of the spot in that frame. This coordinate represents the energy center of the spot region, is insensitive to minor changes in the spot shape, and has better stability. Finally, strictly following the temporal order of image acquisition, the brightness centroid pixel coordinates of all frames are sequentially connected in the two-dimensional coordinate system to generate a smooth pixel trajectory sequence. Physically, this trajectory is the projection path on the image plane caused by the continuous change in the normal direction of the piston surface, resulting in a shift in the direction of reflected light. The generated pixel trajectory sequence is analyzed to detect kinematic anomalies in the light spot caused by abrupt changes in surface geometry. First, the Euclidean distance between each pair of adjacent brightness centroid coordinates in the trajectory sequence is calculated, forming a displacement distance sequence. This sequence describes the instantaneous change in the light spot's movement speed. Then, a box-plot anomaly detection algorithm is applied to the displacement distance sequence. This algorithm objectively determines the statistical boundaries (upper and lower bounds) of normal data fluctuations by calculating the first quartile, third quartile, and interquartile range of the sequence data, without relying on manually set fixed thresholds. Values exceeding the statistical upper bound in the displacement distance sequence are identified as "abnormal displacements," which physically represent a sudden jump in the light spot. The two coordinate points corresponding to each abnormal displacement are marked as a trajectory discontinuity point. This discontinuity point directly maps to surface defects such as scratches or pits that cause discontinuous changes in the normal direction.
[0023] Simultaneously, continuous coordinate subsequences are extracted from the pixel trajectory sequence using a sliding window of preset length, forming multiple trajectory segments. The average displacement distance within each trajectory segment is calculated as the average moving speed of that segment, forming a speed sequence. A box plot algorithm is also applied to the speed sequence to determine its statistical lower bound for normal fluctuations. Trajectory segments with speed values below the statistical lower bound are identified as "abnormally slow trajectory segments," which physically mean that the light spot's movement is almost stagnant locally. Each abnormally slow trajectory segment is marked as a trajectory stagnation segment, which maps to surface defects such as protrusions or attachments that cause the local normal direction to be oriented towards the light source for an extended period. Finally, all trajectory discontinuities and trajectory stagnation segments are collected to form a pixel trajectory anomaly feature set. By using statistical methods, abnormal features strongly correlated with surface geometric defects are automatically and objectively separated from the kinematic data, effectively filtering out random noise. To locate anomalous features in an image to the physical surface of the piston casting, a mapping relationship between image time and spatial position needs to be established. First, when the piston is stationary, a pre-defined visual marker point (such as a machining feature point) on its outer cylindrical surface is located using image recognition methods, and the direction of this point is defined as the angular zero point (initial angular position). The constant angular velocity of the rotating mechanism is acquired, and the acquisition time of the first frame of the image sequence is recorded as the time zero point. Based on the principle of uniform circular motion, the piston rotation angle corresponding to any image acquisition timestamp can be accurately calculated using a linear mapping function: angle = initial angular position + angular velocity × time interval. Thus, the timestamp of each anomalous feature point can be converted into a precise circumferential position (angle).
[0024] To determine the axial position (height), camera calibration is performed during the initialization phase: with the piston stationary, two reference points with known actual physical distances at its top and bottom are identified, and their vertical pixel values in the image are recorded. A vertical pixel ratio coefficient is calculated using the physical height difference / pixel height difference. For any anomalous feature point, its actual physical distance from the top along the piston axis, i.e., its axial position, is obtained by combining the vertical coordinate of its brightness centroid with this ratio coefficient and the coordinates of the top reference point. By combining the circumferential and axial positions, each pixel-level anomalous feature is precisely mapped to a two-dimensional physical coordinate on the outer cylindrical surface of the piston. The set of all coordinates constitutes the defect location coordinate set. This step achieves the crucial transformation from the image domain to the physical domain. Based on the set of defect location coordinates, small-area local surface images around the corresponding coordinates are cropped from the original continuous image sequence. These image regions have been precisely located as highly suspected defect areas by previous steps. Subsequently, these local images are input into a pre-trained defect recognition model (such as a deep convolutional neural network). The role of this model is to perform fine-grained classification and verification of suspected regions, such as distinguishing different types of scratches, pores, or adhesions, and outputting the specific defect category and confidence level.
[0025] To handle challenging samples that the model may encounter (such as rare defects or complex interference coexisting), the system integrates a human-machine collaborative optimization mechanism: when the model's confidence level in a local image falls below a preset threshold, the image and its coordinates are automatically pushed to a manual annotation platform for final adjudication by professionals, and the adjudication result is used as the final identification result for that location. This mechanism ensures the absolute reliability of the results in extreme cases. All new samples and their annotations that have been manually adjudicated or confirmed are automatically added to the model's training sample library. The updated sample library can be used periodically or as needed to iteratively train and update the parameters of the defect identification model, enabling the model to continuously learn from real-world production, constantly improving its recognition ability and generalization performance, forming a self-optimizing closed loop. Finally, by integrating the identification results of all locations (including direct model output and manual adjudication results) and their precise physical coordinates, a complete structured defect identification report is automatically generated, achieving digital and traceable management of product quality.
[0026] It is worth noting that, considering the complex working conditions in actual production where the adhering material (such as oil film) partially or completely overlaps with the actual surface defects, this invention can effectively remove random interference and extract the actual defect location bound to the fixed geometric position by analyzing the repeatability of trajectory anomalies in continuous rotation cycles. Therefore, the data analysis module in this invention also includes obtaining several pixel trajectory sequences corresponding to N complete cycles of continuous rotation of the piston casting; for each single-cycle pixel trajectory sequence in the multi-cycle pixel trajectory sequence, a corresponding pixel trajectory anomaly feature set is generated, wherein the pixel trajectory anomaly feature set contains several trajectory discontinuities and trajectory stall segments; all single-cycle pixel trajectory anomaly feature sets are compared and analyzed, and the number of times each trajectory discontinuity and trajectory stall segment appears in different feature sets is counted; trajectory discontinuities and trajectory stall segments with an occurrence frequency greater than or equal to M are judged as repeatable anomaly features; all trajectory discontinuities and trajectory stall segments judged as repeatable anomaly features are collected to generate the final pixel trajectory anomaly feature set for subsequent mapping and recognition, wherein N and M are preset quantity thresholds, and M needs to be less than or equal to N.
[0027] It is understandable that even with oil contamination, the microscopic geometry of the defect itself remains the dominant factor. A pit or bump does not disappear simply because the surface is covered with a uniform medium; it still alters the surface normal distribution in that area. Under point light source illumination, this invention detects the trajectory of the light spot determined by the change in normal direction. Overlapping oil contaminants may alter local reflectivity, but they typically do not completely eliminate the "trajectory discontinuities" or "stagnations" caused by underlying geometric abrupt changes. Crucially, trajectory anomalies generated by stable geometric defects exhibit spatiotemporal repeatability and consistency (repeatedly appearing in the same rotation phase), while optical noise generated by simple oil contamination is random and unstable. Therefore, by analyzing the repeatability of trajectory anomalies in continuous rotation cycles, random interference can be effectively eliminated, and the true defect location bound to a fixed geometric position can be extracted; this will not be elaborated further here.
[0028] In a preferred embodiment of the present invention, the specific process for acquiring a continuous image sequence in the image acquisition module is as follows: The piston casting is driven to rotate at a constant speed around its central axis by a supporting mechanism. At the same time, a fixed point light source is used to illuminate the outer cylindrical surface of the piston casting at a constant incident angle. The image acquisition device is triggered synchronously with the rotation and illumination process, and continuously acquires images of the light spot area formed by specular reflection on the outer cylindrical surface of the piston casting under the rotation state, thereby obtaining an image sequence composed of multiple consecutive surface images in the time dimension.
[0029] In another preferred embodiment of the present invention, the specific generation process of the pixel trajectory sequence in the trajectory generation module is as follows: The row and column distribution of the pixel matrix on the imaging target surface of the image acquisition device is obtained, and a corresponding two-dimensional pixel coordinate system is established; based on the two-dimensional pixel coordinate system, the horizontal coordinate, vertical coordinate, and brightness value of all pixels in each frame of the continuous image sequence are obtained; In each frame of the image, all pixels with brightness values higher than a preset grayscale threshold are selected. The selected pixels in each frame of the image are subjected to morphological closing operations to obtain a connected high-brightness region. For the high-brightness region in each frame of the image, the weighted average of the horizontal and vertical coordinates of all pixels in the region with their respective brightness values is calculated. The two weighted averages are used as the brightness centroid pixel coordinates of the high-brightness region in the frame of the image. According to the image frame acquisition time sequence of the continuous image sequence, the brightness centroid pixel coordinates obtained in each frame image are connected by line segments in the two-dimensional pixel coordinate system to generate a pixel trajectory sequence representing the movement path of the light spot.
[0030] By condensing a series of instantaneous, static image observations into a continuous, dynamic motion trajectory, the detection dimension is elevated from the image space of a single frame to the behavioral space of a time series. Establishing a precise pixel coordinate system is the foundation of all quantization, ensuring that the analysis of each frame is performed under a unified reference frame. Thresholding and morphological closing operations are used to extract the spot region, eliminating interference from other irrelevant bright spots. Calculating the brightness centroid instead of a simple geometric center overcomes the potential expansion, contraction, or deformation of the spot shape due to surface curvature or impurities, obtaining a more sensitive and stable representative point of the spot's intrinsic energy distribution, preventing unnecessary jitter in subsequent trajectories due to minor changes in the spot's appearance. Finally, connecting these centroids in chronological order to form a trajectory faithfully reconstructs the continuous motion in the physical world (the spot sliding as the piston rotates) in the digital domain. It can be understood that a perfectly smooth cylindrical surface will produce a smooth, continuous, ideal trajectory; however, microscopic defects on the surface, such as pits or protrusions, will interfere with the movement of the spot, leaving abnormal features on this trajectory, such as sudden jumps or decelerations. This lays an irreplaceable data foundation for subsequent extraction of defect features from the trajectory.
[0031] In another preferred embodiment of the present invention, the specific process of obtaining the pixel trajectory anomaly feature set in the data analysis module is as follows: Based on the sequentially arranged brightness centroid pixel coordinates in the pixel trajectory sequence, the Euclidean distance between every two adjacent coordinate points is calculated to obtain the displacement distance sequence; all displacement values in the displacement distance sequence are sorted, and the displacement fluctuation range is determined based on the box plot algorithm; displacements whose values are outside the displacement fluctuation range are identified as abnormal displacements, and the two brightness centroid pixel coordinates corresponding to each abnormal displacement are marked as a trajectory discontinuity point. On the pixel trajectory sequence, a fixed frame length window is used to slide and capture continuous coordinate subsequences from the starting point to generate several trajectory segments; for each trajectory segment, the sum of the displacement distances of all adjacent coordinate points in the trajectory segment is calculated as the ratio of the number of frames to obtain the average moving speed of the trajectory segment, and the average moving speed of all trajectory segments is obtained to form an average moving speed sequence. All speed values in the average moving speed sequence are sorted and the speed fluctuation range is determined based on the box plot algorithm; trajectory segments with average moving speeds lower than the lower limit of the speed fluctuation range are identified as abnormally slow trajectory segments, and each abnormally slow trajectory segment is marked as a trajectory stagnation segment; all marked trajectory discontinuities and trajectory stagnation segments are collected to form the pixel trajectory abnormal feature set.
[0032] First, the pixel trajectory sequence output by the trajectory generation module is received. This sequence is a series of brightness centroid pixel coordinates precisely arranged in chronological order of acquisition time. Starting from the first coordinate point in the sequence, the straight-line distance (Euclidean distance) between each coordinate point and its immediately following coordinate point is calculated sequentially. This distance is calculated by taking the square root of the sum of the squares of the differences between the x-coordinates and y-coordinates of the two points, thus obtaining an instantaneous displacement value describing the speed of the light spot's movement between adjacent frames. Arranging these instantaneous displacement values between all adjacent frames in chronological order forms the position... The displacement distance sequence is then sorted in ascending order. Next, the internal distribution of the sequence is analyzed using a box plot algorithm from statistics. The box plot algorithm calculates the first quartile, median, and third quartile of the sorted sequence. The interquartile range is obtained by subtracting the first quartile from the third quartile. The lower limit of the normal fluctuation range is then defined as the first quartile minus a certain multiple of the interquartile range, and the upper limit is the third quartile plus the same multiple of the interquartile range. This range covers the normal fluctuation range of the main body of the data. Under ideal conditions where the piston rotates at a constant speed and the surface is smooth, the movement of the light spot should be uniform, and the displacement of adjacent frames should be concentrated within a narrow range. Therefore, this statistical interval can objectively describe the boundary of "normal" movement. Subsequently, each displacement value in the displacement distance sequence is compared with this calculated fluctuation interval. Any displacement with a value greater than the upper limit of the interval or less than the lower limit of the interval is identified as an "abnormal displacement." Its physical meaning is a displacement that is significantly greater than the normal value, which means that the position of the light spot has suddenly and discontinuously jumped. This usually corresponds to a situation where there are scratches, pits, or other abnormalities on the surface that cause a sudden change in the direction of reflected light. Therefore, the corresponding pair of front and rear coordinate points in the pixel trajectory sequence for each abnormal displacement are located, and these two points are marked as a "trajectory discontinuity".
[0033] Simultaneously, a sliding window analysis is performed on the complete pixel trajectory sequence. For each trajectory segment, the module calculates the sum of the displacement distances between all adjacent coordinate points within that segment, and then divides this sum by the number of image frames constituting that trajectory segment (i.e., the window length). The result is the "average moving speed" of the light spot within that trajectory segment. This speed value characterizes the overall movement speed of the light spot within this small time window, and is more stable than a single instantaneous displacement, smoothing out minor random jitters. After performing this calculation on all trajectory segments, an average moving speed sequence is obtained. Next, the same box plot algorithm used to process the displacement sequence is employed to sort all speed values in this average moving speed sequence and calculate its statistical fluctuation range. At this point, the module mainly focuses on the lower limit of the fluctuation range, because abnormally slow speed is a key feature. The entire trajectory segment with an average moving speed value below this statistical lower limit is identified as an "abnormally slow trajectory segment". It is understandable that when surface defects such as protrusions or attachments exist, the local surface normal at that point will point to the fixed light source for a longer period during piston rotation, causing the light spot to "stick" or move extremely slowly in this area. Therefore, each such abnormally slow trajectory segment is marked as a "trajectory stagnation segment." This phenomenon originates from a stable change in geometric shape, and its signal is repeatable in continuous rotation cycles. Conversely, abnormally fast trajectory segments with an average moving speed higher than the statistical upper bound are ignored in this invention. It is understandable that the dynamic response of the light spot caused by surface pits and other concave defects is essentially an instantaneous, discontinuous jump in the reflection direction. This feature is obtained in this invention by identifying the "abnormal large displacement" mechanism between adjacent frames, i.e., the detection of "trajectory discontinuities." It is also understandable that this instantaneous event cannot physically form a sustained, stable, high-speed motion segment within a time window. Secondly, a physical process that can cause the light spot to maintain stable, high-speed movement throughout the entire time period covered by the sliding window cannot be generated by any fixed, non-dynamic surface geometry under the constraints of uniform rotation of the piston casting and fixed illumination by the point light source. The physical root of such abnormal, continuous high-speed signals lies in non-structural, transient interference, such as a brief change in specular reflection conditions caused by flowing oil film, or the rapid passage of loosely attached highly reflective particles under centrifugal force. These interference events are random, transient, and non-repeatable, and the resulting optical signals do not belong to the inherent surface morphology features. Therefore, each feature (trajectory discontinuity and trajectory stagnation segment) clearly corresponds to a specific, stable surface geometric anomaly, thus ensuring the high reliability of defect determination in principle. Finally, the data analysis module gathers all the "trajectory discontinuities" and "trajectory stagnation segments" marked in the above process to form the final "pixel trajectory anomaly feature set".
[0034] By transforming the physical information reflecting surface health contained in pixel trajectory sequences into clear and locatable abnormal feature indicators, a direct basis for subsequent defect judgment is provided. Calculating the displacement of adjacent frames and analyzing their anomalies is to keenly capture geometric discontinuities on the surface, converting the geometric attribute of "continuity" into quantifiable distance values for judgment. This allows defects such as minor scratches, which may be invisible in a single frame image due to reflection, to be reliably detected through the "break" features of their motion trajectories. A box plot algorithm based on the statistical distribution of the data is used to set the judgment threshold. Its core advantages are adaptability, objectivity, and robustness. It does not require a fixed absolute threshold that may fail due to changes in light intensity, piston type, or camera parameters. Instead, it dynamically determines what is "normal" and what is "abnormal" based on the actual motion data generated in the current detection. This greatly improves the system's universality and stability under different production batches and operating conditions. The use of a sliding window to calculate local average velocity and detect anomalous slowdowns aims to identify a different defect mode from geometric continuity disruption—local curvature anomalies. The goal is to correlate changes in the "rate" of light spot movement with specific surface morphology (protrusions). By analyzing the overall behavior over a short period, transient noise is filtered out, ensuring that detected "stagnation" is a continuous and stable phenomenon, rather than random fluctuations. Ultimately, by simultaneously capturing these two kinematically distinct anomalous modes—"discontinuity" and "stagnation"—a more comprehensive defect feature profile is constructed. Against a highly reflective background, this model reliably distinguishes and locates true surface morphology defects based on the physical laws of object motion, rather than relying on texture and color.
[0035] In another preferred embodiment of the present invention, the specific process of establishing the mapping function between image acquisition time and piston casting rotation angle in the data mapping module is as follows: Before the piston casting begins to rotate at a constant speed, a static image of it is acquired, and a preset visual marker point on the outer cylindrical surface of the piston casting in the static image is identified and located. The radial direction where the visual marker point is located is used as the zero point of the angle measurement and is defined as the initial angular position. Obtain the constant angular velocity of the bearing mechanism that drives the piston casting to rotate, and record the time point when the first frame image in the continuous image sequence is acquired as the time zero point; Based on the constant angular velocity, calculate the increment of the angle through which the piston casting rotates during the time interval from the zero point of time to any subsequent image acquisition time point; Add the angle increment to the initial angle position to obtain the absolute value of the piston casting rotation angle corresponding to the image acquisition time point, thus obtaining a mapping function that takes the image acquisition time point as input and the corresponding absolute value of the piston casting rotation angle as output.
[0036] In another preferred embodiment of the present invention, the specific process for generating the defect location coordinate set in the data mapping module is as follows: Obtain the brightness centroid pixel coordinates and image acquisition timestamp of each abnormal feature point in the pixel trajectory abnormal feature set. Input each image acquisition timestamp into the mapping function between the image acquisition time and the piston casting rotation angle to obtain the corresponding piston casting rotation angle and use it as the circumferential position of the abnormal feature point. Before the piston casting starts to rotate at a constant speed, a static image of it is acquired. In the static image, a first reference point preset at the top of the piston casting and a second reference point known at the bottom are selected, and the vertical coordinate pixel value and physical height difference of the two are recorded. In this way, the actual physical length represented by a unit vertical coordinate pixel in the static image is calculated, and the vertical pixel ratio coefficient is obtained. The vertical coordinate value of the brightness centroid pixel coordinate of each abnormal feature point is converted with the vertical pixel ratio coefficient and the vertical coordinate pixel value of the first reference point to obtain the physical distance of the abnormal feature point from the first reference point along the axis of the piston casting, and is used as the axial position of the abnormal feature point. The circumferential and axial positions of each abnormal feature point are combined to form its position coordinates on the outer cylindrical surface of the piston casting; the position coordinates of all abnormal feature points are collected to form the defect position coordinate set.
[0037] In another preferred embodiment of the present invention, the specific construction process of the defect identification model in the result generation module is as follows: Collect historical image samples containing defects on the outer cylindrical surface of piston castings, label the defect areas in the historical image samples according to preset categories and record their pixel positions, and establish a labeled defect image sample library. Local image patches corresponding to each defect region are extracted from the labeled defect image sample library, and each local image patch is associated with its labeled defect category to form a training sample pair set; A neural network model is pre-constructed. Local image patches from the training sample set are input into the neural network model for forward propagation calculation to obtain defect category prediction results. The difference between the prediction results and the corresponding real defect category labels is calculated, and the parameters of the neural network model are iteratively adjusted multiple times through the backpropagation algorithm. After each iteration, the model performance is evaluated using an independent validation set until the evaluation results reach the preset performance standard, thus obtaining a defect recognition model.
[0038] In another preferred embodiment of the present invention, the result generation module further includes inputting the local surface image determined to be normal and the corresponding defect location coordinates into the manual annotation platform for manual calibration, and using the manual calibration result as the final recognition result; adding the defect category in the local surface image involved in the manual calibration and its corresponding final recognition result to the training sample set, and iteratively training and updating the defect recognition model.
[0039] The preceding data analysis module identifies and outputs a "pixel trajectory anomaly feature set" based on the geometric and statistical anomalies of the light spot's motion trajectory. This set is essentially a physical signal directly caused by stable, real microscopic geometric changes existing on the piston casting surface. These signals, whether the trajectory is discontinuous or stagnant, strictly correspond to discontinuous or continuous changes in the surface normal direction, thus theoretically eliminating optical interference caused by random attachments or instantaneous light shadows, which lack repeatability and stability. Therefore, each location pointed to by the "defect location coordinate set" transmitted to the result generation module physically represents a real surface morphology anomaly that requires further evaluation.
[0040] Although the preceding steps have physically confirmed the existence of an anomaly, determining the specific visual defect category (e.g., minor scratches, shallow pits, or small bumps) still requires a detailed interpretation of the local surface image by the defect recognition model. When the model classifies a physically confirmed anomaly as "normal," it may be because the specific visual pattern of the anomaly was not adequately covered in the model's training samples, its features are not typical enough, or its appearance is too similar to certain "normal" textures.
[0041] Therefore, all local images and their coordinates that are identified as "normal" by the model are automatically submitted to a manual annotation platform. Quality inspectors then make the final judgment based on their professional knowledge. Their task is no longer to determine "whether there is an anomaly," but rather to perform precise visual classification of physically confirmed anomalies. The correctly labeled category will replace the model's erroneous output as the final identification result for that location, thus ensuring the absolute reliability of the results at the classification level. These manually corrected samples—images that have been physically confirmed to have anomalies and have been assigned precise categories by humans—are added to the training sample library to drive iterative model training, thereby continuously optimizing its classification boundaries and feature extraction capabilities.
[0042] Through two clearly defined and mutually reinforcing levels: the first level (physical analysis), utilizing the principles of optical kinematics, is responsible for unwaveringly "discovering" real morphological anomalies, laying the foundation for high reliability in detection; the second level (visual recognition and learning) is responsible for "identifying" and "mastering" the discovered anomalies, and achieving continuous evolution of capabilities through human-machine collaboration. This not only ensures the mapping from "physical anomalies" to "defect categories" in the present, but also enables the intelligent recognition to closely align with actual production, continuously accumulate experience, and ultimately achieve a steady increase in detection accuracy and automation level, improving recognition precision and efficiency.
[0043] The foregoing has provided a detailed description of one embodiment of the present invention, but this description is merely a preferred embodiment and should not be construed as limiting the scope of the invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the patent coverage of this invention.
Claims
1. A visual inspection-based defect identification system for piston castings, characterized in that, include: The image acquisition module is used to acquire a continuous image sequence of reflected light spots on the surface of the piston casting based on the illumination of the outer cylindrical surface of the piston casting at a uniform speed and a fixed point light source, through a synchronously triggered image acquisition device. The trajectory generation module is used to extract the high-brightness region and calculate the brightness centroid of the continuous image sequence frame by frame, and connect the centroid pixel coordinates of each frame according to the acquisition time order to generate a pixel trajectory sequence of the light spot movement path. The data analysis module is used to identify abrupt changes in the centroid pixel coordinates and abnormal slowdowns in the movement speed in the pixel trajectory sequence, locate and mark them as trajectory discontinuities and trajectory stalls, which together constitute a set of abnormal pixel trajectory features. The data mapping module is used to establish a mapping function between image acquisition time and piston casting rotation angle, and based on the mapping function, to map the pixel trajectory abnormal feature set to the outer cylindrical surface of the piston casting, thereby obtaining the circumferential position set and axial position set corresponding to any trajectory abnormal feature, forming a defect position coordinate set. The result generation module is used to extract local surface images corresponding to the circumferential and axial positions from the continuous image sequence according to the defect location coordinate set and input them into a preset defect recognition model. Based on the recognition results output by the defect recognition model, a structured defect recognition report containing the spatial location of the defect is generated.
2. The piston casting defect identification system based on vision inspection according to claim 1, characterized in that, The specific process for acquiring continuous image sequences in the image acquisition module is as follows: The piston casting is driven to rotate at a constant speed around its central axis by a supporting mechanism. At the same time, a fixed point light source is used to illuminate the outer cylindrical surface of the piston casting at a constant incident angle. The image acquisition device is triggered synchronously with the rotation and illumination process, and continuously acquires images of the light spot area formed by specular reflection on the outer cylindrical surface of the piston casting under the rotation state, thereby obtaining an image sequence composed of multiple consecutive surface images in the time dimension.
3. The piston casting defect identification system based on vision inspection according to claim 1, characterized in that, The specific process for generating the pixel trajectory sequence in the trajectory generation module is as follows: The row and column distribution of the pixel matrix on the imaging target surface of the image acquisition device is obtained, and a corresponding two-dimensional pixel coordinate system is established; based on the two-dimensional pixel coordinate system, the horizontal coordinate, vertical coordinate, and brightness value of all pixels in each frame of the continuous image sequence are obtained; In each frame of the image, all pixels with brightness values higher than a preset grayscale threshold are selected. The selected pixels in each frame of the image are then subjected to morphological closing operations to obtain a connected high-brightness region. For each frame of the image, calculate the weighted average of the horizontal and vertical coordinates of all pixels in the region, with each pixel's brightness value as a weight. Use these two weighted averages as the brightness centroid pixel coordinates of the high-brightness region in the frame of the image. According to the image frame acquisition time sequence of the continuous image sequence, the brightness centroid pixel coordinates obtained in each frame image are connected by line segments in the two-dimensional pixel coordinate system to generate a pixel trajectory sequence representing the movement path of the light spot.
4. The piston casting defect identification system based on vision inspection according to claim 1, characterized in that, The specific process for obtaining the pixel trajectory anomaly feature set in the data analysis module is as follows: Based on the sequentially arranged brightness centroid pixel coordinates in the pixel trajectory sequence, the Euclidean distance between every two adjacent coordinate points is calculated to obtain the displacement distance sequence; all displacement values in the displacement distance sequence are sorted, and the displacement fluctuation range is determined based on the box plot algorithm; displacements whose values are outside the displacement fluctuation range are identified as abnormal displacements, and the two brightness centroid pixel coordinates corresponding to each abnormal displacement are marked as a trajectory discontinuity point. On the pixel trajectory sequence, a fixed frame length window is used to slide and capture continuous coordinate subsequences from the starting point to generate several trajectory segments; for each trajectory segment, the ratio of the sum of the displacement distances of all adjacent coordinate points in the trajectory segment to the number of frames is calculated to obtain the average moving speed of the trajectory segment, and the average moving speed of all trajectory segments is obtained to form an average moving speed sequence. All speed values in the average moving speed sequence are sorted and the speed fluctuation range is determined based on the box plot algorithm; trajectory segments with average moving speeds lower than the lower limit of the speed fluctuation range are identified as abnormally slow trajectory segments, and each abnormally slow trajectory segment is marked as a trajectory stagnation segment; all marked trajectory discontinuities and trajectory stagnation segments are collected to form the pixel trajectory abnormal feature set.
5. A visual inspection-based defect identification system for piston castings according to claim 1, characterized in that, In the data mapping module, the specific process of establishing the mapping function between image acquisition time and piston casting rotation angle is as follows: Before the piston casting begins to rotate at a constant speed, a static image of it is acquired, and a preset visual marker point on the outer cylindrical surface of the piston casting in the static image is identified and located. The radial direction where the visual marker point is located is used as the zero point of the angle measurement and is defined as the initial angular position. Obtain the constant angular velocity of the bearing mechanism that drives the piston casting to rotate, and record the time point when the first frame image in the continuous image sequence is acquired as the time zero point; calculate the angular increment of the piston casting during the time interval from the time zero point to any subsequent image acquisition time point based on the constant angular velocity. Add the angle increment to the initial angle position to obtain the absolute value of the piston casting rotation angle corresponding to the image acquisition time point, thus obtaining a mapping function that takes the image acquisition time point as input and the corresponding absolute value of the piston casting rotation angle as output.
6. A visual inspection-based defect identification system for piston castings according to claim 1, characterized in that, In the data mapping module, the specific process for generating the defect location coordinate set is as follows: For each abnormal feature point in the pixel trajectory abnormal feature set, the corresponding piston casting rotation angle is determined as the circumferential position of the point based on its image acquisition timestamp and the mapping function. Before the piston casting starts to rotate at a constant speed, a static image of it is acquired. In the static image, a first reference point preset at the top of the piston casting and a second reference point known at the bottom are selected. The actual physical height difference between the first reference point and the second reference point and the difference of their vertical coordinate pixel values are obtained, and the vertical pixel ratio coefficient is calculated. The vertical coordinate pixel value of each abnormal feature point is combined with the vertical pixel ratio coefficient and the vertical coordinate pixel value of the first reference point to calculate the physical distance of the point relative to the first reference point along the axis of the piston casting, which is used as its axial position. The circumferential and axial positions of each abnormal feature point are combined to form its position coordinates on the outer cylindrical surface of the piston casting; the position coordinates of all abnormal feature points are collected to form the defect position coordinate set.
7. A visual inspection-based defect identification system for piston castings according to claim 1, characterized in that, The specific construction process of the defect identification model in the result generation module is as follows: Collect historical image samples containing defects on the outer cylindrical surface of piston castings, label the defect areas in the historical image samples according to preset categories and record their pixel positions, and establish a labeled defect image sample library. Local image patches corresponding to each defect region are extracted from the labeled defect image sample library, and each local image patch is associated with its labeled defect category to form a training sample pair set; A neural network model is pre-constructed. Local image patches from the training sample set are input into the neural network model for forward propagation calculation to obtain defect category prediction results. The difference between the prediction results and the corresponding real defect category labels is calculated, and the parameters of the neural network model are iteratively adjusted multiple times through the backpropagation algorithm. After each iteration, the model performance is evaluated using an independent validation set until the evaluation results reach the preset performance standard, thus obtaining a defect recognition model.
8. A visual inspection-based defect identification system for piston castings according to claim 7, characterized in that, The result generation module further includes inputting the local surface image determined to be normal and the corresponding defect location coordinates into the manual annotation platform for manual calibration, and using the manual calibration result as the final recognition result; adding the defect categories in the local surface image involved in the manual calibration and the corresponding final recognition result to the training sample set, and iteratively training and updating the defect recognition model.